Skip to content

Instantly share code, notes, and snippets.

View vidul-nikolaev-petrov's full-sized avatar

Видул Петров vidul-nikolaev-petrov

View GitHub Profile
@vidul-nikolaev-petrov
vidul-nikolaev-petrov / ascci_hex_string.js
Created December 19, 2016 16:13
Tiny helpers: ASCII HEX STRING
function string2ascii(string, sep) {
return string.split('')
.map(e => e.charCodeAt(0)).join(sep ? sep : '');
}
function string2hex(string, sep) {
return string.split('')
.map(e => e.charCodeAt(0).toString(16)).join(sep ? sep : '');
}
@vidul-nikolaev-petrov
vidul-nikolaev-petrov / new_year_tree.js
Last active December 25, 2016 11:42
New Year tree
console.log(' '.repeat(10), "☆");
for (let i = 1, s = ''; i < 10; i++) {
console.log(' '.repeat(10 - i), `${s += i}=${+s * 8 + i}`);
}
console.log(' '.repeat(9), '_=_');
/**
Based on the eight calculations:
@vidul-nikolaev-petrov
vidul-nikolaev-petrov / extendObject.js
Last active February 12, 2017 16:01
ES5 extend object
function extendObject(parent, child) {
var copyFunction = function (f) {
var t = function () {
return f.apply(this, arguments);
};
Object.defineProperty(t, 'name', {
value: f.name,
});
return t;
},
# apps
alias e='exit'
alias v='vim'
alias g='git'
alias gr='grep'
alias c='cut'
alias h='head'
alias t='tail'
alias tf='tail -f'
alias le='less'
@vidul-nikolaev-petrov
vidul-nikolaev-petrov / .bashrc
Last active April 21, 2017 02:56
Save bash history per tty
# command (one-off step)
mkdir -m700 ~/.history
# in .bashrc
HISTFILE=~/.history/history.`tty | cut -d/ -f4`
#!/usr/bin/env node
var blockexplorer = require('blockchain.info/blockexplorer')
// randomly chosen
var addresses = [
'1CEDQ9Vfq8pYVi3Anp926Zjac9Xiz394Y1',
'1CGXTwzjTHbUJXLAvWB4r7L2QLctEpWjti',
'1DUb2YYbQA1jjaNYzVXLZ7ZioEhLXtbUru',
'1Hz96kJKF2HLPGY15JWLB5m9qGNxvt8tHJ',