Skip to content

Instantly share code, notes, and snippets.

View makevoid's full-sized avatar
:atom:
coding

Francesco 'makevoid' Canessa makevoid

:atom:
coding
View GitHub Profile
@makevoid
makevoid / install-ruby-2.3-debian.sh
Last active March 25, 2019 02:50
Install ruby 2.3 on Debian 9
# example usage:
# bash <(curl -s https://gist.githubusercontent.com/makevoid/.../raw/.../install-ruby-2.6-debian.sh)
# bash <(curl -s https://gist.githubusercontent.com/makevoid/5920d782ea4ae28f29b7b137e3399499/raw/d5275487d1dcd3c838178d8bff9cf7660a011ec8/install-ruby-2.3-debian.sh)
set -xe
apt update -y
apt-get install -y ruby-full
gem i bundler
@makevoid
makevoid / install-ruby-2.6-ubuntu.sh
Last active May 18, 2019 10:03
Install ruby 2.6 on ubuntu via PPA (brightbox)
# example usage:
# bash <(curl -s https://gist.githubusercontent.com/makevoid/05824727e45adde87672ae9787524433/raw/5c53711d582c849f8a1f9c33675a78ab34878dee/install-ruby-2.5-ubuntu.sh)
set -xe
apt-add-repository ppa:brightbox/ruby-ng
apt update -y
apt install -y ruby2.6 ruby2.6-dev
@makevoid
makevoid / Dockerfile
Created November 20, 2018 04:34
Ruby 2.5 Dockerfile - using multi staged builds
FROM ubuntu:cosmic as ruby
RUN apt update -y
RUN apt install -y ruby-dev git
RUN gem i bundler
FROM ruby as ruby-build
RUN apt install -y build-essential
@makevoid
makevoid / curl-bitcoin.sh
Created November 17, 2018 22:25
Test Curl to Bitcoin RPC (getinfo call)
curl --user bitcoin:PASSWORD --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "getinfo", "params": [] }' -H 'content-type: text/plain;' http://localhost:8332/
@makevoid
makevoid / install_node_10.js
Last active September 23, 2022 14:50
Install node 10
# bash <(curl -s https://gist.githubusercontent.com/makevoid/0ace4d915b37a3e57a7aead6397525c9/raw/1fe13cbb52a3068f8d9b4e05f8fd306d1d2714ce/install_latest_node.js)
set -xe
sudo apt-get update -y
sudo apt-get install -y curl apt-transport-https ca-certificates
curl --fail -ssL -o setup-nodejs https://deb.nodesource.com/setup_10.x
@makevoid
makevoid / btc_opreturn.js
Last active September 21, 2018 13:24
BTC OP_RETURN
// // package.json
// {
// "dependencies": {
// "bitcoincashjs": "^0.1.10",
// "bitcore-explorers": "^1.0.1",
// }
// }
const fs = require('fs')
const bitcoin = require('bitcoincashjs') // npm i bitcoincashjs --save
// ( see https://bitcore.io/api/lib for docs )
@makevoid
makevoid / try_bch_insight.js
Created September 14, 2018 14:14
Bitpay/insight-client demonstration against BCH insight hosted by blockdozer.com
const Insight = require("insight-client")
const insightHost = "https://blockdozer.com/insight-api"
const insight = new Insight(insightHost)
const addrInfo = () => {
return new Promise((resolve, reject) => {
insight.addr(address, (err, data) => {
if (err) { reject(err); return }
@makevoid
makevoid / try_bitcoincashjs.js
Created September 14, 2018 14:06
BCH create address and private key via bitcoincashjs node module (JS - bitcore-lib)
const fs = require('fs')
const bitcoin = require('bitcoincashjs') // npm i bitcoincashjs --save
// ( see https://bitcore.io/api/lib for docs )
// // generate and save private key
// const pvt = new bitcoin.PrivateKey()
// console.log(pvt.toString('hex'))
const privateKeyString = fs.readFileSync('./private-key.txt').toString().trim()
const privateKey = new bitcoin.PrivateKey(privateKeyString)
@makevoid
makevoid / try_core_client.js
Created September 14, 2018 14:03
NodeJS "core-client" module for interacting with Bitcoin Core via RPC
const CoreClient = require('bitcoin-core') // npm i --save bitcoinc-re
const host = '127.0.0.1' // ssh -L 8332:localhost:8332 root@YOUR_SERVER_IP -N # (ssh tunnel)
const core = new CoreClient({ // you have to
host: host,
username: 'bitcoin',
password: "PASSWORD",
})
@makevoid
makevoid / try_bch_zeromq.js
Created September 14, 2018 13:53
Try Bitcoin (Cash) ZeroMQ Api to retrieve and parse raw transactions (JS)
const zmq = require('zeromq')
const BitcoinCashZMQDecoder = require('bitcoincash-zmq-decoder')
const decoder = new BitcoinCashZMQDecoder("mainnet")
const subscriber = zmq.socket("sub")
const host = 'tcp://34.245.188.100:28332'
subscriber.subscribe("") // subscribe to all
const parseTransaction = (data) => {