This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const randomRouletteWinBet = () => { | |
// The possible win bet numbers on an American roulette wheel | |
const possibleWinBets = [ | |
'0', | |
'00', | |
...Array.from({length: 36}, (_, i) => String(i+1)) | |
]; | |
// Generate a cryptographically secure random index | |
const randomIndex = window.crypto.getRandomValues(new Uint32Array(1))[0] % possibleWinBets.length; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const express = require('express'); | |
const { Telegraf } = require('telegraf'); | |
const app = express(); | |
const port = process.env.PORT || 3000; | |
// Set up the webhook URL | |
const webhookUrl = `https://your-webhook-url.com/telegraf-bot`; | |
// Create a new instance of the Telegraf class |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
from cryptography.fernet import Fernet | |
def encrypt_or_decrypt_files(dir_path, should_encrypt, key): | |
f = Fernet(key) | |
for filename in os.listdir(dir_path): | |
file_path = os.path.join(dir_path, filename) | |
if os.path.isfile(file_path): | |
with open(file_path, 'rb') as f_in: | |
data = f_in.read() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { readdir, readFile, writeFile } = require('fs/promises'); | |
const { | |
randomBytes, | |
createCipheriv, | |
createDecipheriv, | |
createHash, | |
} = require('crypto'); | |
const { join } = require('path'); | |
/** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { getTimeDifferenceBetweenTwoDates } from './getTimeDifferenceBetweenTwoDates'; | |
describe('getTimeDifferenceBetweenTwoDates', () => { | |
it('should return a correct result', () => { | |
const date1 = new Date( | |
'Thu Nov 24 2022 13:50:50 GMT-0500 (Eastern Standard Time)' | |
); | |
const date2 = new Date( | |
'Thu Nov 25 2022 13:50:50 GMT-0500 (Eastern Standard Time)' | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import fs from 'fs/promises'; | |
import path from 'path'; | |
import axios from 'axios'; | |
import { checkImageUrl, allowedFormats, requestWaitingTimeInMs } from '..'; | |
jest.useFakeTimers(); | |
describe('checkImageUrl', () => { | |
it('should return a correct result for jpeg', async () => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const currentYear = new Date().getFullYear(); | |
const deadlineDate = new Date(`12/25/${currentYear}`); | |
const between = Math.abs(Date.now() - deadlineDate.getTime()) / 1000; | |
const timestampInSeconds = Date.now() / 1000 + between; | |
new FlipDown(timestampInSeconds).start(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { getTimeGreetings, welcomes } from '.'; | |
describe('getTimeGreetings', () => { | |
beforeEach(() => { | |
jest.useFakeTimers(); | |
}); | |
it('should return night greetings', () => { | |
jest.setSystemTime( | |
new Date('Thu Oct 06 2022 00:00:54 GMT-0400 (Eastern Daylight Time)') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const items = [ | |
{ | |
name: 'Apple', | |
dropChance: 0.7 | |
}, | |
{ | |
name: 'Knife', | |
dropChance: 0.25 | |
}, | |
{ |
NewerOlder