const jwt = require('jsonwebtoken');
const bcrypt = require('bcryptjs');
const payload = {
sub: 1,
email: 'testt@test.test'
}
const token1 = jwt.sign(payload, 'secret_1');
const token1Signature = token1.split('.').pop()
const token1SignatureHashed = bcrypt.hashSync(token1Signature, 5);
const token2 = jwt.sign(payload, 'secret_2');
const token2Signature = token2.split('.').pop()
const token2SignatureHashed = bcrypt.hashSync(token2Signature, 5);
console.log(`Token1 sig: ${token1Signature}\n`);
console.log(`Token1 sig hashed: ${token1SignatureHashed}\n`);
console.log(`Token2 sig: ${token2Signature}\n`);
console.log(`Token2 sig hashed: ${token2SignatureHashed}\n`);
console.log(`Compare token1Sig vs token1SigHashed: ${bcrypt.compareSync(token1Signature, token1SignatureHashed)}`);
console.log(`Compare token1Sig vs token2SigHashed: ${bcrypt.compareSync(token1Signature, token2SignatureHashed)}`);
console.log(`Compare token2Sig vs token2SigHashed: ${bcrypt.compareSync(token2Signature, token2SignatureHashed)}`);
console.log(`Compare token2Sig vs token1SigHashed: ${bcrypt.compareSync(token2Signature, token1SignatureHashed)}`);
Token1 sig: Z_cIJxKYkQsUWbu1hiRBiFjQOVGehfvcEH1SxJtBBvM
Token1 sig hashed: $2a$05$4yGh8r.YeNsrV3D9i/snMe6QMT1Pt7ZKBOlCZpSypcEdO4xZEnx7K
Token2 sig: XCVtQYxAGDcMMqCQBIitRyok61zJhzcr3c6PZppID2I
Token2 sig hashed: $2a$05$okXRKv85XY88Tg/RhBwuoOwNfGNtjVm8gFI8dzm79SXSvWMTKrULa
Compare token1Sig vs token1SigHashed: true
Compare token1Sig vs token2SigHashed: false
Compare token2Sig vs token2SigHashed: true
Compare token2Sig vs token1SigHashed: false
const someSchema = mongoose.Schema(
{
lastActivityAt: { type: Date, default: Date.now },
},
{ timestamps: true }
)
const instance = await someModel.findOne( <FilterQuery> )
? await someModel.findOneAndUpdate(
<FilterQuery>,
{ lastActivityAt: Date.now() }
)
: await someModel.create( <ObjectQuery> );
from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
from selenium.webdriver.firefox.options import Options as FirefoxOptnions
webdriver_host = "http://127.0.0.1:4444/wd/hub"
desired_capabilities = DesiredCapabilities.FIREFOX
options = FirefoxOptnions()
# Вот тут указываем путь к папке профиля
options.profile = "../profiles/c63u9jz2.default-release-1"
driver = webdriver.Remote(
webdriver_host,
desired_capabilities,
options=options,
)
print(file_serializer.errors)
{'video_file': [ErrorDetail(string='Ensure this filename has at most 100 characters (it has 120).', code='max_length')]}
video_file = models.FileField("Clip", upload_to=get_new_video_file_path, null=True, blank=True, max_length=255)
class Clip(models.Model):
parent = models.ForeignKey('self', on_delete=models.CASCADE, null=True, blank=True)
name = models.CharField("Clip name", max_length=150)
video_file = models.FileField("Clip", upload_to="clips", null=True)
thumbnail = models.ImageField("Thumbnail", upload_to="thumbnails/", null=True)
youtube_link = models.URLField("Link to clip on YouTube", blank=True)
@property
def get_name(self):
if self.parent is not None:
return Clip.objects.get(id=self.parent.id).name
return self.name
@property
def get_artist(self):
if self.parent is not None:
return Clip.objects.get(id=self.parent.id).artist
return self.artist
@property
def get_thumbnail(self):
if self.parent is not None:
return Clip.objects.get(id=self.parent.id).thumbnail.name
return self.thumbnail.name
@property
def get_youtube_link(self):
if self.parent is not None:
return Clip.objects.get(id=self.parent.id).youtube_link
return self.youtube_link
class ClipSerializer(serializers.ModelSerializer):
name = serializers.ReadOnlyField(source="get_name")
artist = serializers.ReadOnlyField(source="get_artist")
thumbnail = serializers.ReadOnlyField(source="get_thumbnail")
youtube_link = serializers.ReadOnlyField(source="get_youtube_link")
class Meta:
model = Clip
exclude = [
"video_file",
]
using UnityEngine;
public class Wheel : MonoBehaviour {
[SerializeField] // Теперь поле Cup появится у компонента скрипта в Inspector
SpriteRenderer Cup;
void OnMouseDown(){
Cup.enabled = !Cup.enabled; // переключаем видимость спрайта
}
}