Skip to content

Instantly share code, notes, and snippets.

View nodew's full-sized avatar
:octocat:
Focusing

Qiao Wang nodew

:octocat:
Focusing
View GitHub Profile
@nodew
nodew / UCanUupCount
Created July 21, 2016 14:01
count 'UCanUup' in the file 'http://106.75.28.160/UCloud.txt'
var http = require('http');
http.get('http://106.75.28.160/UCloud.txt', function(res) {
var body = '';
res.on('data', function(d) {
body += d;
});
res.on('end', function() {
var count = body.match(/UCanUup/g).length
console.log(count);
});
@nodew
nodew / UCanUupCount-ShellVersion
Last active July 21, 2016 14:28
count 'UCanUup' in the file 'http://106.75.28.160/UCloud.txt' with shell in one line
wget -q -O- http://106.75.28.160/UCloud.txt | grep -o 'UCanUup' | wc -l
@nodew
nodew / .eslintrc.js
Created August 11, 2016 16:03 — forked from nkbt/.eslintrc.js
Strict ESLint config for React, ES6 (based on Airbnb Code style)
{
"env": {
"browser": true,
"node": true,
"es6": true
},
"plugins": ["react"],
"ecmaFeatures": {
function store() {}
function closure(obj) {
store.print = function() {
console.log(obj)
}
return function() {
store.print()
}
}
@nodew
nodew / simplify-express-middleware-model.js
Last active March 29, 2017 13:15
to understand the middlewares of express better
var proto = {};
function express() {
var app = function(ctx, cb) {
app.handle(ctx, cb);
}
app.__proto__ = proto;
app.stack = [];
return app;
}
@nodew
nodew / simplify-redux.js
Created March 29, 2017 13:15
a simple redux, just has `createStore` and `combineReducer` method
/*
* demo reducer
* function demoReducer(state, action) {
* do something
* return state;
* }
*
* demo action
* {
* type: [type symbol]
@nodew
nodew / find-increasing-subsequence.lisp
Created April 15, 2017 16:47
to find increasing subsequence, for example, [1 0 1 2 3 0 4 5] => [0 1 2 3]
(defun find-subsequence-a (lst)
(let ((result '(1)))
(do ((l lst (cdr l)))
((null (cdr l)) result)
(let ((current (car l))
(next (cadr l)))
(if (> next current)
(setq result (cons (1+ (car result)) result))
(setq result (cons 1 result)))))))
@nodew
nodew / compose.lisp
Created April 17, 2017 16:24
compose functions
(defun compose (&rest funcs)
"compose functions, (compose f g) => (f (g args))"
;; at least one function is required
(if (null funcs)
nil
(destructuring-bind (fn . rest) (reverse funcs)
#'(lambda (&rest arguments)
(reduce #'(lambda (v f)
(funcall f v))
rest
@nodew
nodew / walk_folder.sh
Last active April 19, 2017 08:51
recursively find out all file under a folder
path=$1
ignoreFolder=$2
walk() {
ss=${1#*${2}}
if [[ $ss == "" ]]; then
return
fi
if [[ -d $1 ]]; then
sub=`ls $1`
#!/bin/bash
files=`find ./src -type f -regex "./.*.[^coffee]"`
for file in $files
do
path=`dirname $file`
newpath=`echo ${path//src/build}`
filename=`basename $file`
if [ ! -d $newpath ]; then