Skip to content

Instantly share code, notes, and snippets.

View sdesalas's full-sized avatar
💻

Steven de Salas sdesalas

💻
View GitHub Profile
#!/bin/sh
# Roll your own DDNS
# Shell script to update namecheap.com dynamic dns
# for a domain to your external IP address
HOSTNAME=$MYSUBDOMAIN
DOMAIN=$MYDOMAIN
PASSWORD=$MYSECRETPASSWORD
@sdesalas
sdesalas / test_bin
Last active March 22, 2022 18:42
ESM in extensionless executable files (`import` statement inside dependency chain)
#!/usr/bin/env node
/**
* This is a POC of https://github.com/nodejs/modules/issues/152#issuecomment-1068515887
*
* The requires statement below should fail with an error while
* using an ESM import buried inside the module dependency chain:
* import crypto from 'crypto';
* ^^^^^^
* SyntaxError: Cannot use import statement outside a module
@sdesalas
sdesalas / createWallet.js
Created March 5, 2022 16:03 — forked from PraneshASP/createWallet.js
Create a bitcoin wallet with this simple script.
//Import dependencies
const bip32 = require('bip32')
const bip39 = require('bip39')
const bitcoin = require('bitcoinjs-lib')
//Define the network
const network = bitcoin.networks.bitcoin //use networks.testnet for testnet
// Derivation path
const path = `m/49'/0'/0'/0` // Use m/49'/1'/0'/0 for testnet
@sdesalas
sdesalas / docker-cockpit-portainer.sh
Last active February 26, 2025 19:33
Docker + Portainer + Cockpit
#1 Openssh server
sudo apt install -y openssh-server
sudo systemctl enable ssh
sudo systemctl start ssh
sudo ufw enable
sudo ufw allow ssh
#2 Docker (https://docs.docker.com/engine/install/ubuntu/)
sudo apt-get install -y apt-transport-https ca-certificates curl gnupg-agent software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
// @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER
// @see https://en.wikipedia.org/wiki/Double-precision_floating-point_format
console.log(Number.MAX_SAFE_INTEGER);
const z = 4153000000000000000 + 99;
console.log(z);
console.log('Thats why.');
//
const util = require('util');
setTimeout(async () => {
db.getData = util.promisify(db.getData);
db.processData = util.promisify(db.processData);
db.saveData = util.promisify(db.saveData);
try {
@sdesalas
sdesalas / docker.alpine.install.awscliv2.sh
Last active March 26, 2024 14:50
Install AWSCLIv2 in `docker:latest` alpine image for running docker-dn-docker depoyments in Gitlab
# `docker:latest` image uses base alpine linux
# This script allows installing awscliv2 which requires
# gcc buildtools (instead of default `musl` in alpine)
# https://stackoverflow.com/questions/60298619/awscli-version-2-on-alpine-linux
GLIBC_VER=2.31-r0
# install glibc compatibility for alpine
apk --no-cache add \
binutils \
jq \
@sdesalas
sdesalas / gitlab-runner-install.sh
Last active January 24, 2022 17:36
Gitlab Runner in Ubuntu 18/20 with TLS enabled (for docker:dind)
# 0. SET YOUR GROUP REGISTRATION TOKEN
# @see https://gitlab.com/groups/mygroup/-/settings/ci_cd#runners-settings
export GITLAB_REGISTRATION_TOKEN=abc123def456
# 1. INSTALL GITLAB RUNNER
# @see https://docs.gitlab.com/runner/install/linux-repository.html
curl -L https://packages.gitlab.com/install/repositories/runner/gitlab-runner/script.deb.sh | sudo bash
export GITLAB_RUNNER_DISABLE_SKEL=true; sudo -E apt-get install gitlab-runner
@sdesalas
sdesalas / parse_dotenv.bash
Created March 30, 2020 11:11 — forked from judy2k/parse_dotenv.bash
Parse a .env (dotenv) file directly using BASH
# Pass the env-vars to MYCOMMAND
eval $(egrep -v '^#' .env | xargs) MYCOMMAND
# … or ...
# Export the vars in .env into your shell:
export $(egrep -v '^#' .env | xargs)
@sdesalas
sdesalas / md5.js
Created February 6, 2020 18:28
Native MD5 in node.js
var crypto = require('crypto');
module.exports = function(data) {
return crypto.createHash('md5').update(data).digest("hex");
};