Skip to content

Instantly share code, notes, and snippets.

View coderek's full-sized avatar
👽

Derek Zeng coderek

👽
View GitHub Profile
const axios = require('axios')
const start = new Date
function fetchDependencies(url) {
console.log('Fetching ' + url)
return axios.get(url).then(({data})=> {
return data.dependencies || []
}, () => {
return []
}).catch(() => {
from subprocess import run, DEVNULL
import re
cp = run(['ls', 'graphql'], stdout=PIPE, encoding='utf-8')
for filename in re.split(r'\s+', cp.stdout):
if filename:
cp = run(
'ack -w -r {filename} **/**'.format(filename=filename),
stdout=DEVNULL,
shell=True)
1;Max;dummy@dummy.com;69123456789;1;17;39;12;2;14;5;13;31;23;34;46;57;20;45;16;;
2;Tobi;dummy@dummy.com;68123456789;1;8;3;20;10;1;11;30;47;23;6;15;;;;;;
3;Desi;dummy@dummy.com;6123456789;1;12;2;13;14;39;31;55;58;10;28;15;;;;;;
4;Alex;dummy@dummy.com;-0;1;39;9;12;25;33;41;54;;;;;;;;;;
5;Nati;-0;491123456789;1;14;29;37;30;10;11;19;13;17;8;;;;;;;
6;Ceci;dummy@dummy.com;41123456789;1;22;34;24;33;45;39;50;55;;;;;;;;;
7;Kim;dummy@dummy.com;491123456789;1;32;37;30;29;11;;;;;;;;;;;;
8;Frank;dummy@dummy.com;4917123456789;1;2;14;5;13;45;28;22;34;24;12;51;42;;;;;
9;Diego;dummy@dummy.com;6123456789;1;22;34;24;25;33;23;45;28;39;6;4;47;41;;;;
10;Winni;dummy@dummy.com;6123456789;1;17;39;12;2;14;13;54;45;10;46;24;47;15;;;;
@coderek
coderek / docker-cleanup-resources.md
Created January 30, 2018 17:44 — forked from bastman/docker-cleanup-resources.md
docker cleanup guide: containers, images, volumes, networks

Docker - How to cleanup (unused) resources

Once in a while, you may need to cleanup resources (containers, volumes, images, networks) ...

delete volumes

// see: https://github.com/chadoe/docker-cleanup-volumes

$ docker volume rm $(docker volume ls -qf dangling=true)

$ docker volume ls -qf dangling=true | xargs -r docker volume rm

function MyPromise(task) {
this._state = 'init';
this._resolve_handler = null;
this._reject_handler = null;
this._resolved_value = null;
this._rejected_value = null;
this._resolve = this._resolve.bind(this);
this._reject = this._reject.bind(this);
task(this._resolve, this._reject);
return this;
function segment(list) {
const nodes = [];
for (let i=0;i<list.length;i++) {
nodes.push({max: [list[i], i], range: [i, i+1]});
}
let l = list.length;
while (l > 0) {
for (let i=0;i<l-1;i+=2) {
let maxIdx = nodes[i]['max'];
@coderek
coderek / kmp_search.py
Last active October 17, 2017 03:18
finding repeated string using kmp
def kmp(text, word):
wl = len(word)
jump = [0 for _ in range(wl)]
j = 0
i = 1
while i < wl:
if word[i] == word[j]:
jump[i] = j + 1
i+=1
@coderek
coderek / win.vimrc
Last active October 6, 2017 20:06
vimrc for windows
set nocompatible " be iMproved, required
set rtp+=$HOME/.vim/bundle/Vundle.vim
filetype off " required
" set the runtime path to include Vundle and initialize
call vundle#begin('$HOME/.vim/bundle/')
" alternatively, pass a path where Vundle should install plugins
"call vundle#begin('~/some/path/here')
" let Vundle manage Vundle, required
@coderek
coderek / threading.py
Last active July 25, 2017 02:46
threading and synchronization
import time
from random import random
from threading import Thread, Lock
"""
Python's GIL ensures that non IO ops will execute sequentially
So no need to sync the followings
s = store + 1
store = s