Skip to content

Instantly share code, notes, and snippets.

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

Block or report user

Report or block vidul-nikolaev-petrov

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View simulate_btc_balance.js
#!/usr/bin/env node
var blockexplorer = require('blockchain.info/blockexplorer')
// randomly chosen
var addresses = [
'1CEDQ9Vfq8pYVi3Anp926Zjac9Xiz394Y1',
'1CGXTwzjTHbUJXLAvWB4r7L2QLctEpWjti',
'1DUb2YYbQA1jjaNYzVXLZ7ZioEhLXtbUru',
'1Hz96kJKF2HLPGY15JWLB5m9qGNxvt8tHJ',
@vidul-nikolaev-petrov
vidul-nikolaev-petrov / .bashrc
Last active Apr 21, 2017
Save bash history per tty
View .bashrc
# command (one-off step)
mkdir -m700 ~/.history
# in .bashrc
HISTFILE=~/.history/history.`tty | cut -d/ -f4`
View .bash_aliases.sh
# 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'
View extendObject.js
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;
},
View new_year_tree.js
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 / ascci_hex_string.js
Created Dec 19, 2016
Tiny helpers: ASCII HEX STRING
View ascci_hex_string.js
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 / printable_ascii_characters.c
Last active Dec 13, 2016
Printable ascii characters (tiny helper)
View printable_ascii_characters.c
#include <stdio.h>
/*
The conversion from `int` to `char` in this sequence is not to guaranteed to work on all systems.
See more in the comments of the accepted answer: http://stackoverflow.com/questions/21196926
*/
int main() {
int i;
int e = 0;
char numbers[11];
char alpha_capital[27];
@vidul-nikolaev-petrov
vidul-nikolaev-petrov / JS-pt-string-index.slice.substring.js
Last active Nov 29, 2016
String performance test on Node -- index, slice, substring
View JS-pt-string-index.slice.substring.js
var string = 'string',
stringIndex = function () {
string[0];
},
stringSlice = function () {
string.slice(0, 1);
},
stringSubstring = function () {
string.substring(0, 1);
};
View checkBalancedBrackets.js
function checkBalance(s) {
if (s.length % 2 !== 0) return false;
if (s.length === 0) return true;
var pairs = ['[]', '()', '{}'],
r0 = s.split(pairs[0]),
r1 = s.split(pairs[1]),
r2 = s.split(pairs[2]);
@vidul-nikolaev-petrov
vidul-nikolaev-petrov / webpage-crypto.html
Last active Feb 17, 2016
Self-contained crypto webpage (AES-256)
View webpage-crypto.html
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<script>
/*
CryptoJS v3.1.2
code.google.com/p/crypto-js
(c) 2009-2013 by Jeff Mott. All rights reserved.
code.google.com/p/crypto-js/wiki/License
You can’t perform that action at this time.