Skip to content

Instantly share code, notes, and snippets.

View stormslowly's full-sized avatar
🎯
Focusing

pshu stormslowly

🎯
Focusing
  • Hangzhou, Zhejiang, China
View GitHub Profile
@stormslowly
stormslowly / timestamp.sh
Last active August 29, 2015 14:20
add prefix time stamp for console output
someCMD | awk 'BEGIN{cmd="date +%H:%M:%S.%N"} {cmd|getline D; close(cmd); print D,$0}'
"this way slow down the cmd execute try below
someCMD | awk '{print strftime("%H:%M:%S"),$0}'
@stormslowly
stormslowly / expressV3apiextracter.js
Last active August 29, 2015 14:16
get express v3 api sublime completions array
'use strict';
var toCompelition = function(signature) {
/* app.get(name) */
var apiReg = /([a-zA-Z.]+)\(([\w\s\[\]\.\|,]*)\)/g;
var varReg = /([a-zA-Z.]+)/g;
var com = null;
var matchs = apiReg.exec(signature);
if (matchs) {
@stormslowly
stormslowly / README.md
Last active August 29, 2015 14:12
get a random commandlinefu from commandlinefu.com

STEP 0

install HTML-XML-utils and w3m

STEP 1

in your .bashrc add below alias

alias cf="curl -Ls http://www.commandlinefu.com/commands/random  |hxprune -c sample-output | hxprune -c meta|hxprune -c votes |hxprune -c options |hxprune -c window-bar  | hxnormalize  -x | hxselect -s '\n' '.terminal-display'  | w3m -dump   -T text/html"
@stormslowly
stormslowly / 微信UA.md
Created September 5, 2014 08:08
微信UA识别

iPhone 通过微信内置浏览器访问网页时得到 User Agent 是:

Mozilla/5.0 (iPhone; CPU iPhone OS 6_1_3 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Mobile/10B329 MicroMessenger/5.0.1

Android 通过微信内置浏览器访问网页时得到 User Agent 是:

Mozilla/5.0 (Linux; U; Android 2.3.6; zh-cn; GT-S5660 Build/GINGERBREAD) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1 MicroMessenger/4.5.255
@stormslowly
stormslowly / MakeGraphDependencies.java
Created July 4, 2014 03:07
MakeGraphDependencies
/**
* steal from: https://raw.githubusercontent.com/lindenb/jsandbox/master/src/sandbox/MakeGraphDependencies.java
* thanks a lot
*/
package sandbox;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
@stormslowly
stormslowly / prepare.md
Last active August 29, 2015 14:03
node 准备工作

周五node分享会,大家有空提前准备一些东西

(1) 先到下面的链接 找对应文件的node安装文件安装。

http://nodejs.org/dist/v0.10.22/

在命令行

$ node -v
"use strict";
// `f` is assumed to sporadically fail with `TemporaryNetworkError` instances.
// If one of those happens, we want to retry until it doesn't.
// If `f` fails with something else, then we should re-throw: we don't know how to handle that, and it's a
// sign something went wrong. Since `f` is a good promise-returning function, it only ever fulfills or rejects;
// it has no synchronous behavior (e.g. throwing).
function dontGiveUp(f) {
return f().then(
undefined, // pass through success
function keepTrying(otherArgs, promise) {
promise = promise||new Promise();
// try doing the important thing
if(success) {
promise.resolve(result);
} else {
setTimeout(function() {
keepTrying(otherArgs, promise);
@stormslowly
stormslowly / bootstrap-navbar.html
Created June 16, 2014 12:19
bootstrap navbar template
<nav class="navbar navbar-default" role="navigation">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">Brand</a>
module.exports = {
get: function (req, res) {
res.sendfile(req.path.substr(1));
},
_config: {
rest: false,
shortcuts: false
}
};