Skip to content

Instantly share code, notes, and snippets.

View rigwild's full-sized avatar

rigwild

View GitHub Profile
@rigwild
rigwild / README.md
Last active April 28, 2024 17:45
Cache a function locally and automatically - With a lockable cache version if using multi threading

Using withCache

const myFriends: CacheMap<{ name: string; age: number }> = {}

async function fetchMyFriendsFromCity(fromCity: string) {
  // This is to preserve the name of the function in the stack trace
  const fetchMyFriendsFromCity = async () => {
    console.log('Fetching my friends from the database...')
    return (await db.query('SELECT * FROM friends WHERE city = ?', [fromCity])).rows
@rigwild
rigwild / aes.js
Last active April 28, 2024 12:47
Easily encrypt string or object using Crypto-JS AES encryption
'use strict'
const password = 'secure secret key'
const encrypt = (content, password) => CryptoJS.AES.encrypt(JSON.stringify({ content }), password).toString()
const decrypt = (crypted, password) => JSON.parse(CryptoJS.AES.decrypt(crypted, password).toString(CryptoJS.enc.Utf8)).content
// Encrypt
const encryptedString = encrypt('This is a string', password)
const encryptedObject = encrypt({ test: 'This is an object' }, password)
@rigwild
rigwild / codeMirror_languageModuleLoader.js
Last active March 24, 2024 07:54
Asynchronously load a CodeMirror language module 🔍🤷‍♀️
/**
* CodeMirror NPM dynamic language module loader.
* To be used with WebPack.
*
* @example
* loadCodeMirrorModule(codeMirrorLanguages.JavaScript.codeMirrorMode)
*
* @author rigwild <https://github.com/rigwild>
* @see https://gist.github.com/rigwild/ce6b4c6a893c3a95f75cc0aca633f037
* @license MIT
@rigwild
rigwild / README.md
Last active March 20, 2024 13:08
Red Hat free repositories

Red Hat free repositories

You need a subscription to access Red Hat sources servers.

Fortunately, you can access most of the packages freely with other sources.

Note: Edit scripts to match your RHEL version! You can view it with hostnamectl.

EPEL repository

EPEL is a repository targetted at Fedora users. It can be used with the following systems:

@rigwild
rigwild / .bashrc
Last active March 19, 2024 20:31
my wsl bash .bashrc configs
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
# If not running interactively, don't do anything
case $- in
*i*) ;;
*) return;;
esac
@rigwild
rigwild / patch_apk.md
Last active March 11, 2024 14:43
Full tutorial to patch APKs on Android using apk-mitm and APKLab. Support for bundle APKs.

Patch APK

Full tutorial to patch APKs on Android using apk-mitm and APKLab. Support for bundle APKs.

Pull APK

adb shell pm list packages
adb shell pm path <package_name>
@rigwild
rigwild / README.md
Created February 17, 2024 21:38
Super simple helper class to use OpenPGP.js without getting an headache
@rigwild
rigwild / coolcats_download.sh
Created January 13, 2024 16:50
Download all Cool Cats NFT metadata and images
#!/bin/bash
set -e
set -x
# Directory to save the JSON files and images
mkdir -p coolcats
cd coolcats
# Loop from 1 to 9999
@rigwild
rigwild / record.vb
Created March 7, 2022 11:17
Export Powerpoint presentation as a 60 fps video
' Save presentation as pptm then create a macro in "View > Macros", run it
Sub MkVideo()
If ActivePresentation.CreateVideoStatus <> ppMediaTaskStatusInProgress Then
ActivePresentation.CreateVideo FileName:=Environ("USERPROFILE") & "\Desktop\video.wmv", _
UseTimingsAndNarrations:=True, _
VertResolution:=1080, _
FramesPerSecond:=60, _
Quality:=100
Else: MsgBox "There is another conversion to video in progress"
End If
@rigwild
rigwild / 0_README.md
Last active December 3, 2023 01:18
VM Setup for dockerized apps and Portainer, including exposed NGINX with TLS configuration

Introduction

The goal of this this tutorial is to fully deploy a VM with multiple apps.

All the apps data will be stored in Docker volumes mounted to the host at /var/www/my-deploys for easy edit and backup. The benefit of this is you can create a GitHub repository and store all your configuration files in one place.

To deploy the docker-compose.yml of the apps below into Portainer, go to Stacks > Add stack.

Pre-requisites