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
/** | |
* Traverse object path and optionally update value | |
* @param obj Object to traverse | |
* @param path Object path - | |
* Include array indexes as a regular dot-key notation e.g. `parent.0.key` - | |
* *Doesn't support keys with a . inside* | |
* @param flags Flags object for modifying key value | |
* - `newValue` New value to set the key to | |
* - `deleteValue` If true the key will be deleted from object | |
*/ |
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 Redis from 'ioredis'; | |
type CallbackFn<T = any, S = any> = ( | |
value: T, | |
key: string, | |
store: S | |
) => void | Promise<void>; | |
interface IRedisHashMap<T = any> { | |
delete(key: string): Promise<number>; |
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 { | |
fromEvent, | |
interval, | |
merge | |
} = rxjs | |
const { | |
takeUntil, | |
repeat, | |
throttle, |
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
#!/bin/bash | |
php artisan migrate | |
php artisan key:generate | |
php artisan passport:install |
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
#!/bin/bash | |
sudo apt install apt-transport-https curl | |
curl -s https://brave-browser-apt-release.s3.brave.com/brave-core.asc | sudo apt-key --keyring /etc/apt/trusted.gpg.d/brave-browser-release.gpg add - | |
echo "deb [arch=amd64] https://brave-browser-apt-release.s3.brave.com/ stable main" | sudo tee /etc/apt/sources.list.d/brave-browser-release.list | |
curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > packages.microsoft.gpg |
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
sudo apt-get install apt-transport-https | |
curl -fsSL https://github.com/rabbitmq/signing-keys/releases/download/2.0/rabbitmq-release-signing-key.asc | sudo apt-key add - | |
wget -O- https://dl.bintray.com/rabbitmq/Keys/rabbitmq-release-signing-key.asc | sudo apt-key add - | |
wget -O- https://www.rabbitmq.com/rabbitmq-release-signing-key.asc | sudo apt-key add - | |
echo "deb http://dl.bintray.com/rabbitmq-erlang/debian $(lsb_release -sc) erlang" | sudo tee -a /etc/apt/sources.list.d/rabbitmq.list | |
echo "deb https://dl.bintray.com/rabbitmq/debian $(lsb_release -sc) main" | sudo tee -a /etc/apt/sources.list.d/rabbitmq.list | |
sudo apt-get install -y erlang-base \ | |
erlang-asn1 erlang-crypto erlang-eldap erlang-ftp erlang-inets \ | |
erlang-mnesia erlang-os-mon erlang-parsetools erlang-public-key \ | |
erlang-runtime-tools erlang-snmp erlang-ssl \ |
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
sudo mkdir -p /var/swaps/ | |
sudo dd if=/dev/zero of=/var/swaps/swap.1 bs=1M count=4096 | |
sudo mkswap /var/swaps/swap.1 | |
sudo chmod 600 /var/swaps/swap.1 | |
echo "/var/swaps/swap.1 swap swap defaults 0 0" | sudo tee -a /etc/fstab | |
sudo swapon -a |
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 secureMathRandom = () => { | |
// Divide a random UInt32 by the maximum value (2^32 -1) to get a result between 0 and 1 | |
return window.crypto.getRandomValues(new Uint32Array(1))[0] / 4294967295; | |
} |
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
export default class Miner { | |
constructor(difficulty = 1, block = undefined) { | |
this.difficulty = difficulty; | |
this.block = block || { | |
id: 1, | |
time: new Date().getTime(), | |
prevHash: 'd5cd02605f5dd530caa73c799ee75d92b8e637986ab4b23875c2fa95da7d5674', | |
data: { | |
foo: 42 | |
} |
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
// Declare for typescript | |
declare var CryptoJS: any; | |
declare var localforage: any; | |
// Constants | |
const passphrase = 'A3PnGzWjxGuAYtFu', | |
key = 'data', | |
object = { foo: 'bar' }; | |
// Log original item |
NewerOlder