Skip to content

Instantly share code, notes, and snippets.

View fanatid's full-sized avatar

Kirill Fomichev fanatid

View GitHub Profile
@fanatid
fanatid / main.js
Last active May 26, 2019 06:58
Download custom emojis from slack
const fs = require('fs')
const fetch = require('node-fetch')
;(async () => {
const data = JSON.parse(fs.readFileSync('./data.json', 'utf-8'))
// const html = fs.readFileSync('./x.html', 'utf-8')
// const customTag = '<h3 class="p-emoji_picker__heading">Custom</h3>'
// const text = html.includes(customTag) ? html.slice(html.indexOf(customTag)) : html
// const re = /<span class="emoji emoji-sizer" style="background-image:url\((.*?)\)" data-codepoints="(.*?)">/g
@fanatid
fanatid / analyze-stat.js
Last active November 26, 2018 19:35
Slack private messages history export
const msgs = require('./history.json')
const data = {}
const usersObj = {}
for (const msg of msgs) {
const msgTs = new Date(parseFloat(msg.ts) * 1000)
const ts = new Date(msgTs.getFullYear(), msgTs.getMonth(), msgTs.getDate())
const key = `${ts.getFullYear()}/${ts.getMonth()+1}/${ts.getDate()}`
if (!data[key]) data[key] = { key, ts }

Keybase proof

I hereby claim:

  • I am fanatid on github.
  • I am fanatid (https://keybase.io/fanatid) on keybase.
  • I have a public key ASAtNsTFNV7ksgUpfTF1dGnA_tPOpLlNagxyHhyQ_AoSPwo

To claim this, I am signing this object:

@fanatid
fanatid / cluster.js
Last active December 12, 2017 20:21
node.js cluster: pipe
// Based on: https://github.com/nodejs/node-v0.x-archive/issues/5727
const cluster = require('cluster')
const net = require('net')
function runMaster () {
cluster.setupMaster({ stdio: [0, 1, 2, 'ipc', 'pipe'] })
const worker = cluster.fork()
const pipe = worker.process.stdio[4]
pipe.on('data', (buffer) => {
@fanatid
fanatid / bip0037.js
Last active January 10, 2017 03:27
BIP-0037 example on JavaScript (bitcore-lib, bitcore-p2p, webcoin merkleTree)
var bitcore = require('bitcore-lib') // 0.13.14
var p2p = require('bitcore-p2p') // 1.1.0
var MerkleTree = require('webcoin/lib/merkleTree') // 1.0.2
var address = '1JSbd6CXJHzhGgadpio3HPXTZcSWzBHy3L'
var blockHash = '000000000000000006f9b9d985624bb621221cde9682a038a9a21403376c36f6' // 397690
// expect:
// tx: 0f15750e8a662ff7d02123677461477eb3b3222d6ca785b98f64c17d7d458699
// in block: 397697:0000000000000000021b3bd248ee38a47e0a9904d6a4bfbd7fcfe200bb533e97
// tx: ffe2822fd404e829ef4758617b01d2c4b9b26ab9a1a146e23be468aa0d881fa5
@fanatid
fanatid / index.js
Last active August 29, 2015 14:23
get colored balance for addresses
// npm i git://github.com/fanatid/coloredcoinjs-lib#v0.4.0 git://github.com/chromaway/blockchainjs lodash cb-insight bluebird bitcore
var _ = require('lodash')
var cclib = require('coloredcoinjs-lib')
var bitcore = require('bitcore')
var Promise = require('bluebird')
var Blockchain = require('cb-insight')
var blockchain = new Blockchain('https://insight.bitpay.com')
var blockchainjs = require('blockchainjs')
var connector = new blockchainjs.connector.Chromanode({networkName: 'livenet'})
@fanatid
fanatid / .bash_profile
Last active July 6, 2019 08:16
dotfiles
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
@fanatid
fanatid / bitcoinjs-lib.js
Last active March 28, 2019 21:49
bitcoin multisig transaction demo
var bitcoin = require('bitcoinjs-lib') // 1.4.x ?
var privKeys = [
'L2ALJznyt2croGHs8duBK2TZMB3Bc5ZpFZQSmR5QQUMPDDcUWeTw', // n2t8F1D41xy6f3d2B6DtjXRRsn8dgUzQ6C
'L3gM5giJqPAJcWyD8eKv94d4QgqyzqrYeAA9DnuJe23FszsnqD1w', // mjgF67B4pyEHuGTLU5jS333EasUrZBaxMB
'KwdYxYAbxntKvrMQtDHAamPT1pyuYkDRfAwESBqCGRdz9abQo3dW', // mwzPpNMFwLoJPXw2ez8mz6RrdYGaqZDind
'L5LTWMRBt27dHde1mnvV1RzW1mxQuQBxpm2TvNHsMaNvAQKqKov2', // mt7K2ChnJSp96k93HYdC8B9oqUmqLyESpL
'L4qQgxEbKJFJKans2UxFRzXisS7o3oBkyJGirAUgTxS9CfTo9Cd4', // mmvbfVqYrXdy1i4x9UzWc4PtgN7VjMNjeY
]