Skip to content

Instantly share code, notes, and snippets.

!!! 5
//if lt IE 7
<html class="no-js lt-ie9 lt-ie8 lt-ie7">
//if IE 7
<html class="no-js lt-ie9 lt-ie8">
//if IE 8
<html class="no-js lt-ie9">
//[if gt IE 8]><!
html(class='no-js')
//<![endif]

Getting Started with NPM (as a developer)

If you haven't already set your NPM author info, now you should:

npm set init.author.name "Your Name"
npm set init.author.email "you@example.com"
npm set init.author.url "http://yourblog.com"

npm adduser

@Unitecho
Unitecho / test.sh
Created February 25, 2013 18:37
Record mic and send it to google speech for recognition
rec -c 2 -r 16000 -s -t wav - | flac - -f --best --sample-rate 16000 -o out.flac
#arecord -f cd -t wav -d 5 -r 16000 | flac - -f --best --sample-rate 16000 -o out.flac
wget --post-file='out.flac' --header='Content-Type: audio/x-flac; rate=16000;' \
-O 'recognized.json' \
'https://www.google.com/speech-api/v1/recognize?lang=fr-FR'
cat recognized.json
@Unitecho
Unitecho / display_routes.js
Created February 8, 2013 03:53
Express : Display routes
for (var key in app.routes) {
if (app.routes.hasOwnProperty(key)) {
var r = app.routes[key];
r.forEach(function(ro) {
console.log(' \033[90m%s \033[36m%s\033[0m', ro.method.toUpperCase(), ro.path);
});
}
}
@Unitecho
Unitecho / gist:4721032
Created February 6, 2013 07:51
HTTP : detecting rate limits in headers
["x-ratelimit-limit", "x-ratelimit-remaining", "x-oauth-scopes", "link"]
@Unitecho
Unitecho / index.js
Created February 6, 2013 07:46
JS : Add methods to Object with .call(
(function() {
this.updateKey = function(msg, block, callback) {
var self = this;
[.....]
});
};
}).call(User.prototype);
@Unitecho
Unitecho / gist:4713994
Created February 5, 2013 11:52
jQuery : Detect CSS3 end transition
$("#someSelector").bind("transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd", function(){ ... });
@Unitecho
Unitecho / console.js
Created February 1, 2013 10:13
Node : Console log direct CB binding
db.on('error', console.error.bind(console, 'connection error:'))
var net = require('net')
var sock = net.connect(1337)
process.stdin.pipe(sock)
sock.pipe(process.stdout)
sock.on('connect', function () {
process.stdin.resume();
process.stdin.setRawMode(true)
@Unitecho
Unitecho / bench.js
Created January 30, 2013 07:35
Node : Benchmarking code
console.time('100-elements');
for (var i = 0; i < 100; i++) {
;
}
console.timeEnd('100-elements');