Skip to content

Instantly share code, notes, and snippets.

@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 / 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

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 "[email protected]"
npm set init.author.url "http://yourblog.com"

npm adduser

!!! 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]
@Unitecho
Unitecho / gist:5074920
Created March 3, 2013 06:21
google tts
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'
ll
var __ = require("../maki/lib/underscore.js");
var events = require("events");
var Stream = require('./events_caller.js').MyStream;
var stream = new Stream();
console.log(stream instanceof events.EventEmitter); // true
console.log(Stream.super_ === events.EventEmitter); // true
stream.on("data", function(data) {
@Unitecho
Unitecho / gist:5393289
Created April 16, 2013 04:13
Intercept console.log output and write to file
var util = require('util');
var fs = require('fs');
var log = fs.createWriteStream('stdout.log');
console.log = console.info = function(t) {
var out;
if (t && ~t.indexOf('%')) {
out = util.format.apply(util, arguments);
process.stdout.write(out + '\n');
return;

Contract Killer 3

Revised date: 07/11/2012

Between us [company name] and you [customer name]

Summary:

We’ll always do our best to fulfil your needs and meet your expectations, but it’s important to have things written down so that we both know what’s what, who should do what and when, and what will happen if something goes wrong. In this contract you won’t find any complicated legal terms or long passages of unreadable text. We’ve no desire to trick you into signing something that you might later regret. What we do want is what’s best for both parties, now and in the future.

@Unitecho
Unitecho / gist:5524591
Created May 6, 2013 11:25
Angular animation
- <div ng-directive ng-animate="{enter: 'animate-enter'}"></div>
- * .animate-enter-setup {
* -webkit-transition: 1s linear all; /&#42; Safari/Chrome &#42;/
* -moz-transition: 1s linear all; /&#42; Firefox &#42;/
* -ms-transition: 1s linear all; /&#42; IE10 &#42;/
* -o-transition: 1s linear all; /&#42; Opera &#42;/
* transition: 1s linear all; /&#42; Future Browsers &#42;/
*
* /&#42; The animation preparation code &#42;/
* opacity: 0;
@Unitecho
Unitecho / gist:5524598
Created May 6, 2013 11:26
Angular - Promise $q
function asyncGreet(name) {
var deferred = $q.defer();
setTimeout(function() {
// since this fn executes async in a future turn of the event loop, we need to wrap
// our code into an $apply call so that the model changes are properly observed.
scope.$apply(function() {
if (okToGreet(name)) {
deferred.resolve('Hello, ' + name + '!');
} else {