Skip to content

Instantly share code, notes, and snippets.

View sdesalas's full-sized avatar
🕹️

Steven de Salas sdesalas

🕹️
View GitHub Profile
var AWS = require('aws-sdk');
console.log(process.env);
var sts = new AWS.STS();
sts.getCallerIdentity({},
(err, data) => err && console.log("Error", err) || console.log(JSON.stringify(data.Account)));
@sdesalas
sdesalas / hero-on-docker.bulleye-slim.log
Last active March 11, 2023 12:50
Compiling reasoning hero/zero
$ docker run -it --rm debian:bullseye-slim /bin/bash
root@789bc626502d:/# apt update && apt install -y git build-essential cmake
Get:1 http://deb.debian.org/debian bullseye InRelease [116 kB]
Get:2 http://deb.debian.org/debian-security bullseye-security InRelease [48.4 kB]
Get:3 http://deb.debian.org/debian bullseye-updates InRelease [44.1 kB]
Get:4 http://deb.debian.org/debian bullseye/main amd64 Packages [8183 kB]
Get:5 http://deb.debian.org/debian-security bullseye-security/main amd64 Packages [234 kB]
Get:6 http://deb.debian.org/debian bullseye-updates/main amd64 Packages [14.6 kB]
Fetched 8640 kB in 4s (2393 kB/s)
Reading package lists... Done
@sdesalas
sdesalas / fancy.git.commands.sh
Last active March 10, 2023 15:31
Git like a pro
# Remove commit from current branch. Remote branch is MINE: I dont care about other people's commits (bad).
git rebase --onto $COMMIT_HASH^ $COMMIT_HASH && git push --force
# Remove commit from current branch. Remote branch is SHARED: Be careful with other people's commits.
git rebase --onto $COMMIT_HASH^ $COMMIT_HASH && git push --force-with-lease
# Alternate to rebasing
git reset --soft $COMMIT_HASH_BEFORE_CHANGES or HEAD~$NO_COMMITS_BEHIND
git stash
git checkout uat
@sdesalas
sdesalas / echo.js
Created August 3, 2022 09:30 — forked from bszwej/echo.js
Pure Node.js echo server, that logs all incoming http requests (method, path, headers, body).
const http = require('http');
const server = http.createServer();
server.on('request', (request, response) => {
let body = [];
request.on('data', (chunk) => {
body.push(chunk);
}).on('end', () => {
body = Buffer.concat(body).toString();
@sdesalas
sdesalas / various.sh
Created May 22, 2022 17:35
Db backup scripts
for DB in $(mysql -u root -p<password> -h <IP of DB> -e 'show databases' -s --skip-column-names); do
mysqldump -u root -p<password> -h<IP of DB> $DB > "$DB.sql";
#!/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 12, 2024 20:15
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.');
//