Instantly share code, notes, and snippets.

View btc_opreturn.js
// // 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 )
View try_bch_insight.js
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 }
View try_bitcoincashjs.js
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)
View try_core_client.js
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",
})
View try_bch_zeromq.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) => {
View foo.rb
BAZ = MODULE_EXPORTS.fetch :baz
module Foo
bar = -> {
baz = BAZ
baz.()
}
BAR = bar
end
View bindings.txt
1 - alt1
2 - alt2
3 - alt3
4 - ±
View bitcore-lib-privatekey-to-web3-account.js
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()}`)
View bucket_policy.json
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": "s3:*",
"Resource": [
"arn:aws:s3:::BUCKET_NAME",
"arn:aws:s3:::BUCKET_NAME/*"
]
View run-latest-cmd.applescript
# focus terminal
tell application "Terminal"
activate
end tell
# up arrow - enter (run last command)
tell application "System Events"
key code 126
key code 36
end tell