Skip to content

Instantly share code, notes, and snippets.

View nickleefly's full-sized avatar

Xiuyu Li nickleefly

  • Shanghai
View GitHub Profile
@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 \
@nickleefly
nickleefly / preg_replace.php
Created December 31, 2012 06:15
url to clickable link
<!--
a few lines of code to make a url into a clickable link
using lazy star (.*?) and $0
-->
<?php
$string = 'http://www.haha.com www.haha.com hahahaha https://www.haha.com';
$string = $string." ";
$stringall = preg_replace('/((https:\/\/)|(http:\/\/)|(www\.))(.*?)(?=\s)/i','<a href="$0" target="_blank">$0</a>',$string);
@nickleefly
nickleefly / insert.js
Last active December 10, 2015 19:48
insert async
var insertElement = function(data, callback) {
var timeout = Math.ceil(Math.random() * 1000);
setTimeout(function() {
callback(null, data);
}, timeout);
};
var insertAll = function(coll, callback) {
var queue = coll.slice(0),
elem;
@nickleefly
nickleefly / sublime-windows.md
Last active December 10, 2015 23:08
sublime text shortcut windows

#Editing ##Keypress Command

  • Ctrl + X Delete line
  • Ctrl + ↩ Insert line after
  • Ctrl + ⇧ + ↩ Insert line before
  • Ctrl + ⇧ + ↑ Move line/selection up
  • Ctrl + ⇧ + ↓ Move line/selection down
  • Ctrl + L Select line - Repeat to select next lines
  • Ctrl + D Select word - Repeat select others occurrences
@nickleefly
nickleefly / sublime.mac
Last active December 10, 2015 23:09
mac sublime shortcut
h1. Sublime Text 2 - Useful Shortcuts (Mac OS X)
h2. General
| *⌘T* | go to file |
| *⌘⌃P* | go to project |
| *⌘R* | go to methods |
| *⌃G* | go to line |
| *⌘KB* | toggle side bar |
| *⌘⇧P* | command prompt |