Skip to content

Instantly share code, notes, and snippets.

View mfcodeworks's full-sized avatar
🗺️
Working Remotely

MF Codeworks mfcodeworks

🗺️
Working Remotely
View GitHub Profile
@mfcodeworks
mfcodeworks / encrypted-forage.js
Created November 1, 2019 04:25
Encrypted storage with localforage.js
// Constants
const passphrase = 'A3PnGzWjxGuAYtFu',
key = 'data',
object = { foo: 'bar' };
// Log original item
console.log('Original object', object);
// Store item with encryption
setItem(key, object, passphrase)
@mfcodeworks
mfcodeworks / encrypted-storage.js
Last active August 3, 2023 05:08
Encrypted storage with localstorage
// Constants
const passphrase = 'password',
key = 'data',
object = { foo: 'bar' };
// Log original item
console.log('Original object', object);
// Store item with encryption
setItem(key, object, passphrase);
@mfcodeworks
mfcodeworks / traverse-object.ts
Last active July 30, 2021 10:17
Dynamically get the nested value from an object, update or delete flags for modification
/**
* 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
*/
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>;
@mfcodeworks
mfcodeworks / setup.bat
Last active November 16, 2020 15:24
Windows Setup Script
@echo THIS MUST BE RUN WITH WINDOWS POWERSHELL FOR INITIAL CHOCOLATEY INSTALLATION
Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
choco install brave jre8 firefox 7zip vlc notepadplusplus git openssh putty nodejs sysinternals jdk8 chocolatey-windowsupdate.extension vcredist140 netfx-4.7.1-devpack filezilla teamviewer dotnetfx dotnet3.5 vcredist2015 dotnet4.5 python winscp vscode rainmeter sourcetree qbittorrent androidstudio composer goggalaxy gimp irfanview spotify
@mfcodeworks
mfcodeworks / drag.js
Created June 18, 2020 16:53
Drag HTML Elements
const {
fromEvent,
interval,
merge
} = rxjs
const {
takeUntil,
repeat,
throttle,
#!/bin/bash
php artisan migrate
php artisan key:generate
php artisan passport:install
sudo apt update
sudo apt upgrade -y
sudo apt dist-upgrade -y
sudo apt install nginx redis-server curl dirmngr apt-transport-https lsb-release ca-certificates -y
curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -
sudo apt -y install nodejs
sudo apt -y install gcc g++ make
sudo ufw allow 'Nginx HTTP'
sudo apt install mariadb-server -y
sudo mysql_secure_installation
#!/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
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