Skip to content

Instantly share code, notes, and snippets.

@rigwild
rigwild / web3mail.ts
Last active May 9, 2024 20:38
Register an email, grant access to someone, then send me an email - iExec Web3Mail
import { IExecDataProtectorCore, getWeb3Provider } from '@iexec/dataprotector'
import { IExecWeb3mail } from '@iexec/web3mail'
const WALLET_ADMIN_ADDRESS = '0xAA0b58975c43b1Fd0b49E6d50F018b8e8451805e'
const WALLET_ADMIN_PRIVATE_KEY = '5e1ffa8ae0d1c6727c86290b6b69391c813f17f1f7642eb9a5e28fcb9e348309'
const WALLET_CUSTOMER_ADDRESS = '0xFF1CBA1Dba9879d7Fa32a776d8e9166Dc9A2F173'
const WALLET_CUSTOMER_PRIVATE_KEY = 'c3fce58c12d1845a8104183b872af124a1bd7f563645fe3630e127644fcfaa6e'
const dataProtector = new IExecDataProtectorCore(getWeb3Provider(WALLET_CUSTOMER_PRIVATE_KEY))
@rigwild
rigwild / renameImportsForEsmSupport.mjs
Last active May 5, 2024 13:30
Script to recursively convert all imports from a directory to ESM compatible imports with `.js` file extensions, will also replace directory imports with direct `/index.js` imports.
// @ts-check
/**
* This script is used to fix imports in the generated typechain types.
*
* The generated typechain types are not compatible with ESM imports.
* They use directory imports and imports without file extensions.
*
* Usage:
*
@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 / 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 / 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

cd /var/www
git clone [email protected]:dgtlmoon/changedetection.io.git
cd changedetection.io

Edit the configuation

nano docker-compose.yml
@rigwild
rigwild / README.md
Last active September 27, 2023 23:31
Install Prometheus, Prometheus Pushgateway and Grafana and add them to systemd startup

Install and use metrics with Prometheus and Grafana

Install metrics agents

Install Prometheus, Prometheus Pushgateway and Grafana. Put them behind NGINX reverse proxy, get a TLS certificate, and run the service on startup with systemd.

Do a replace all of prometheus-pushgateway.example.com and grafana.example.com with your own domains.

chmod u+x ./install_metrics_agents.sh
@rigwild
rigwild / evmTokens.js
Last active May 15, 2024 08:35
List of EVM (Ethereum-based) networks including its explorer and top most used smart contracts tokens addresses (ERC20) - On 2023-01-07
/*
Networks:
* ethereum
* binanceSmartChain
* polygon
* fantom
* optimism
* arbitrum
* avalanche
/**
* Convert any string to kebab-case.
* Removes accents, multiples whitespaces and symbols to one "-" and converts to lower case.
* Removes any leading and leading "-".
*
* @param {string} str string to convert
* @returns {string} string in kebab-case
* @author rigwild <[email protected]>
* @see https://gist.github.com/rigwild/3e4d30bd269535b7508926c8beaeef90
*/