Skip to content

Instantly share code, notes, and snippets.

@cenyG
cenyG / migration.sql
Created August 24, 2018 14:16 — forked from sevlyar/migration.sql
Add postgresql enum's element in transaction
-- rename the old enum
ALTER TYPE country_code RENAME TO country_code__;
-- create the new enum with the old name
CREATE TYPE country_code AS ENUM ('DE', 'AT', 'NL', 'CH');
-- ALTER all you enum columns
ALTER TABLE user_address
ALTER COLUMN country DROP DEFAULT;
ALTER TABLE user_address
@cenyG
cenyG / toWif.js
Last active August 14, 2018 13:28 — forked from t4sk/wif.md
How to convert private key to WIF
function toWIF(privkey, network) {
const netPriv = new Buffer([network.privatekey]).toString('hex');
let res = `${netPriv}${privkey}`
let chk = crypto.createHash('sha256').update(res, 'hex').digest()
chk = crypto.createHash('sha256').update(chk).digest()
const cheksum = chk.slice(0, 4).toString('hex')
res = `${netPriv}${privkey}${cheksum}`
const bs58 = require('base-x')('123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz')