Skip to content

Instantly share code, notes, and snippets.

View nickleefly's full-sized avatar

Xiuyu Li nickleefly

  • Shanghai
View GitHub Profile
@nickleefly
nickleefly / nextTick.js
Created August 1, 2012 05:10 — forked from mmalecki/nextTick.js
process.nextTick vs setTimeout(fn, 0)
for (var i = 0; i < 1024 * 1024; i++) {
process.nextTick(function () { Math.sqrt(i) } )
}
@nickleefly
nickleefly / readme-outline.md
Created October 9, 2012 16:22 — forked from indexzero/readme-outline.md
A quick outline of a README.md

README.md Outline

  • Header and a Brief description (should match package.json)
  • Example (if applicable)
  • Motivation (if applicable)
  • API Documentation: This will likely vary considerably from library to library.
  • Installation
  • Tests
  • Contributors
  • License
@nickleefly
nickleefly / 1-view-events.js
Created October 13, 2012 14:58 — forked from mxriverlynn/1-view-events.js
zombies! run!
MyView = Backbone.View.extend({
events: {
"click #someButton": "doThat",
"change #someInput": "changeIt"
},
doThat: function(){ ... },
changeIt: function(){ ... }
});
function runSpecs() {
// configure the spec runner
var specRunner = new Hilo.SpecRunner({
src: "Hilo",
specs: "specs",
helpers: "specs/Helpers"
});
// Handle any errors in the execution that
// were not part of a failing test
@nickleefly
nickleefly / promises.md
Created October 25, 2012 04:45 — forked from domenic/promises.md
You're Missing the Point of Promises

You're Missing the Point of Promises

Promises are a software abstraction that makes working with asynchronous operations much more pleasant. In the most basic definition, your code will move from continuation-passing style:

getTweetsFor("domenic", function (err, results) {
    // the rest of your code goes here.
});
@nickleefly
nickleefly / gist:3970960
Created October 29, 2012 01:58 — forked from bpaquet/gist:3922818
Zlib leak node v0.8.12
var zlib = require('zlib');
var completed = 0;
function printProcMem() {
if (completed % 100 == 0) {
var mem = process.memoryUsage();
console.log('%d %d %d %d',
completed, mem.rss / 1000000, mem.heapTotal / 1000000, mem.heapUsed / 1000000);
}
@nickleefly
nickleefly / flyingrobots.js
Created October 31, 2012 01:16 — forked from csanz/flyingrobots.js
programming flying robots with node.js is easy
var arDrone = require('ar-drone');
var client = arDrone.createClient();
client.takeoff();
client
.after(5000, function() {
this.clockwise(0.5);
})
.after(3000, function() {
@nickleefly
nickleefly / http.js
Created November 12, 2012 03:20 — forked from isaacs/http.js
var domain = require('domain');
var d = domain.create()
var fs = require('fs')
server = require('http').createServer(
function(req, res) {
var d2 = domain.create();
d2.add(req)
d2.add(res)
@nickleefly
nickleefly / gemspec-usage.md
Created November 29, 2012 13:20 — forked from holman/gemspec-usage.md
test/spec/mini

Just install this in your apps like so:

gem 'test-spec-mini', :git => 'git://gist.github.com/1806986.git', :require => 'mini'

@nickleefly
nickleefly / get-and-install.sh
Created December 5, 2012 01:53
get tar ball, install it
#
# Get and install <repo>.
#
get() {
local prev=`pwd`
local repo=$1
rm -fr /tmp/get \
&& mkdir /tmp/get \
&& cd /tmp/get \