Skip to content

Instantly share code, notes, and snippets.

@gabmontes
gabmontes / create-bitcoin-tx.js
Created December 7, 2017 01:36
Create bitcoin transaction from BIP38 private key
const { Transaction } = require('bitcore-lib')
const { decrypt } = require('bip38')
const encryptedKey = '<private key beginning with 6>'
const password = '<private key password>'
const privateKey = decrypt(encryptedKey, password).privateKey
// Check UTXO info at https://insight.bitpay.com/api/addr/<origin address>/utxo
const utxo = {
@rauchg
rauchg / README.md
Last active January 6, 2024 07:19
require-from-twitter
@eteeselink
eteeselink / delay.js
Created November 13, 2015 13:55
ES7 async/await version of setTimeout
const delay = ms => new Promise(resolve => setTimeout(resolve, ms));
async function something() {
console.log("this might take some time....");
await delay(5000);
console.log("done!")
}
something();
@jthomas
jthomas / n-queens.js
Last active August 10, 2022 12:49
Solving "N Queens Problem" with JavaScript
var iterations = 0
var print_board = function (columns) {
var n = columns.length, row = 0, col = 0
while (row < n) {
while (col < n) {
process.stdout.write(columns[row] === col ? 'Q ' : '# ')
col++
}
@celeryclub
celeryclub / Setting up headless Raspberry Pi OS on macOS.md
Last active May 2, 2024 02:21
Setting up headless Raspberry Pi OS on macOS

Download the latest Raspberry Pi OS Lite image from https://www.raspberrypi.com/software/operating-systems/ (2022-04-04 at the time of this writing).

Insert your microSD card. Use Raspberry Pi Imager to burn the image to your microSD card. Make to select "Set username and password" in the config before starting. Name the user pi and select your own password.

Ensure the disk is mounted again, then enable SSH.

$ touch /Volumes/boot/ssh
@RedBeard0531
RedBeard0531 / functions.js
Created February 22, 2012 20:13
Min, Max, Sum, Count, Avg, and Std deviation using MongoDB MapReduce
// derived from http://en.wikipedia.org/wiki/Algorithms_for_calculating_variance#Parallel_algorithm
function map() {
emit(1, // Or put a GROUP BY key here
{sum: this.value, // the field you want stats for
min: this.value,
max: this.value,
count:1,
diff: 0, // M2,n: sum((val-mean)^2)
});