Skip to content

Instantly share code, notes, and snippets.

Xiuyu Li nickleefly

Block or report user

Report or block nickleefly

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@nickleefly
nickleefly / nextTick.js
Created Aug 1, 2012 — forked from mmalecki/nextTick.js
process.nextTick vs setTimeout(fn, 0)
View nextTick.js
for (var i = 0; i < 1024 * 1024; i++) {
process.nextTick(function () { Math.sqrt(i) } )
}
@nickleefly
nickleefly / readme-outline.md
Created Oct 9, 2012 — forked from indexzero/readme-outline.md
A quick outline of a README.md
View readme-outline.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
View 1-view-events.js
MyView = Backbone.View.extend({
events: {
"click #someButton": "doThat",
"change #someInput": "changeIt"
},
doThat: function(){ ... },
changeIt: function(){ ... }
});
View default.js
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 Oct 25, 2012 — forked from domenic/promises.md
You're Missing the Point of Promises
View promises.md

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 Oct 29, 2012 — forked from bpaquet/gist:3922818
Zlib leak node v0.8.12
View gist:3970960
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 Oct 31, 2012 — forked from csanz/flyingrobots.js
programming flying robots with node.js is easy
View flyingrobots.js
var arDrone = require('ar-drone');
var client = arDrone.createClient();
client.takeoff();
client
.after(5000, function() {
this.clockwise(0.5);
})
.after(3000, function() {
View 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)
View gemspec-usage.md

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 Dec 5, 2012
get tar ball, install it
View get-and-install.sh
#
# Get and install <repo>.
#
get() {
local prev=`pwd`
local repo=$1
rm -fr /tmp/get \
&& mkdir /tmp/get \
&& cd /tmp/get \
You can’t perform that action at this time.