Skip to content

Instantly share code, notes, and snippets.

View gabmontes's full-sized avatar

Gabriel Montes gabmontes

View GitHub Profile
@tblobaum
tblobaum / rename-redis-keys.js
Created July 22, 2012 13:19
script to rename lots of redis keys
var Redis = require('redis-stream')
, client = new Redis(6379, 'localhost', process.argv[2] || 0)
, stream = client.stream()
var keys = client.stream('keys')
process.stdin
.pipe(Redis.es.split())
.pipe(keys)
.pipe(Redis.es.mapSync(function (key) {
@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 = {
@hrobeers
hrobeers / gist:214b2a7199875c477f13f48e5f675c4a
Last active February 3, 2021 10:39
Generate compressed and uncompressed bitcoin addresses from a private key with bitcore.
var bitcore = require("bitcore-lib");
var Buffer = require("buffer").Buffer;
var value = new Buffer.from("test", "utf8");
var hash = bitcore.crypto.Hash.sha256(value);
// Compressed Key (nu skool)
var bn = bitcore.crypto.BN.fromBuffer(hash);
var privateKey = new bitcore.PrivateKey(bn);
@shazron
shazron / delete_all_greenkeeper_branches.sh
Last active April 8, 2021 13:44
Delete all Greenkeeper branches
#!/bin/bash
# Description:
# Delete all `greenkeeper/*` branches of your remote.
# Instructions:
# Run the script with the `--help` flag.
ORIGIN=origin
DRY_RUN=0
THIS=`basename "$0"`
@zeuxisoo
zeuxisoo / gist:980174
Created May 19, 2011 04:15
How to use git diff to patch file

Create patch file

git diff --no-prefix > [path file name]

Apply path file

patch -p0 < [path file name]

@kristopherjohnson
kristopherjohnson / formatjson.js
Last active November 29, 2023 02:47
Read JSON from standard input and writes formatted JSON to standard output. Requires Node.js.
#!/usr/bin/env node
// Reads JSON from stdin and writes equivalent
// nicely-formatted JSON to stdout.
var stdin = process.stdin,
stdout = process.stdout,
inputChunks = [];
stdin.resume();
@trey
trey / happy_git_on_osx.md
Last active February 18, 2024 10:46
Creating a Happy Git Environment on OS X

Creating a Happy Git Environment on OS X

Step 1: Install Git

brew install git bash-completion

Configure things:

git config --global user.name "Your Name"

git config --global user.email "you@example.com"

@spalladino
spalladino / falsehoods-that-ethereum-programmers-believe.md
Last active March 8, 2024 14:34
Falsehoods that Ethereum programmers believe

Falsehoods that Ethereum programmers believe

I recently stumbled upon Falsehoods programmers believe about time zones, which got a good laugh out of me. It reminded me of other great lists of falsehoods, such as about names or time, and made me look for an equivalent for Ethereum. Having found none, here is my humble contribution to this set.

About Gas

Calling estimateGas will return the gas required by my transaction

Calling estimateGas will return the gas that your transaction would require if it were mined now. The current state of the chain may be very different to the state in which your tx will get mined. So when your tx i

@ishu3101
ishu3101 / read_arguments.js
Last active March 12, 2024 18:10
Accept input via stdin and arguments in a command line application in node.js
#!/usr/bin/env node
var args = process.argv.slice(2);
var input = args[0];
var isTTY = process.stdin.isTTY;
var stdin = process.stdin;
var stdout = process.stdout;
// If no STDIN and no arguments, display usage message
@TOMOAKI12345
TOMOAKI12345 / bitcoin_spv_wallet_overview.md
Created August 31, 2015 11:37
Bitcoin SPV Wallet Flow Overview