Skip to content

Instantly share code, notes, and snippets.

View makevoid's full-sized avatar

Francesco 'makevoid' Canessa makevoid

View GitHub Profile
@makevoid
makevoid / bucket_policy.json
Created December 18, 2017 18:11
S3 AWS Policy - Allow access and management of a single bucket + list buckets permission (so most S3 clients don't complain - remove the ListAllMyBuckets and restrict bucket management for extra security)
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": "s3:*",
"Resource": [
"arn:aws:s3:::BUCKET_NAME",
"arn:aws:s3:::BUCKET_NAME/*"
]
@makevoid
makevoid / bitcore-lib-privatekey-to-web3-account.js
Last active January 24, 2018 23:22
Bitcore-lib PrivateKey to Web3 account
const Web3 = require('web3')
const web3 = new Web3("http://mainnet.infura.io")
const eth = web3.eth
const bitcore = require('bitcore-lib')
const PrivateKey = bitcore.PrivateKey
const privateKey = new PrivateKey()
eth.accounts.privateKeyToAccount(`0x${privateKey.toString()}`)
@makevoid
makevoid / bindings.txt
Created March 29, 2018 22:37
Fastscript applescripts
1 - alt1
2 - alt2
3 - alt3
4 - ±
@makevoid
makevoid / foo.rb
Last active June 23, 2018 02:27
ruby module with js-style imports/exports
BAZ = MODULE_EXPORTS.fetch :baz
module Foo
bar = -> {
baz = BAZ
baz.()
}
BAR = bar
end
@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) => {
@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_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_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 / 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 / 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