Skip to content

Instantly share code, notes, and snippets.

@guileen
guileen / issue16.diff
Created December 7, 2011 07:30
closure lint ignore error
Index: errorrules.py
===================================================================
--- errorrules.py (revision 7)
+++ errorrules.py (working copy)
@@ -25,6 +25,7 @@
FLAGS = flags.FLAGS
flags.DEFINE_boolean('jsdoc', True,
'Whether to report errors for missing JsDoc.')
+flags.DEFINE_list('ignore_errors', [], 'List of error codes to ignore.')
@guileen
guileen / demo-memleak.js
Created February 29, 2012 09:09
This code will memory leak, if you restart redis server when the node process is running
/**
* This code will memory leak, if you restart redis server when the node process is running
*
* @author Gui Lin
*/
var redis = require('redis').createClient();
setInterval(function(){
redis.multi()
@guileen
guileen / async.js
Created March 11, 2012 15:59
parallel javascript
// This is an lite version of `async`, see https://github.com/caolan/async
//
// es5shim.js is required for old version browsers
//
// Author: Gui Lin
// Email: [email protected]
var async = {};
@guileen
guileen / url.js
Created March 12, 2012 16:46
simple url parser
// URL parse utility
//
// Author: Gui Lin
//
// guileen AT gmail DOT com
//
// this function is use to strip url not validation
function urlparser (url) {
var r = /^(\w+):\/\/([^\/\?#]+)(\/[^\?#]*)?(\?[^#]*)?(#.*)?$/i.exec(url);
return r && {
@guileen
guileen / StackScript.sh
Created April 5, 2012 19:23 — forked from visnup/StackScript.sh
node.js knockout 2011 StackScript
#!/bin/bash
cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
# <UDF name="ssh_key" Label="Paste in your public SSH key" default="" example="" optional="false" />
# root ssh keys
mkdir /root/.ssh
echo $SSH_KEY >> /root/.ssh/authorized_keys
chmod 0700 /root/.ssh
@guileen
guileen / install_redis.sh
Created April 9, 2012 07:16
install redis
# install redis
git clone git://github.com/antirez/redis.git ~/redis
cd ~/redis
git checkout unstable
make
make install
echo run `pwd`/utils/install_server to install service
echo TODO make presharding
@guileen
guileen / init_user.sh
Created April 9, 2012 07:44
init user settings
#!/bin/bash
read -p "Please input username:" USERNAME
if [ ! -f "/bin/zsh" ]; then
apt-get install zsh
fi
useradd -U -s /bin/zsh -m $USERNAME
passwd $USERNAME
@guileen
guileen / init-user-noshell.sh
Created April 12, 2012 09:13
create user for ssh no shell
# ensure you have nologin
#
# less /etc/shells
# which nologin
# /usr/sbin/nologin
# echo `which nologin` >> /etc/shells
useradd -m -s /usr/sbin/nologin public
# login without password
@guileen
guileen / install-imagemagick.sh
Created April 13, 2012 07:31
install ImagMagick on ubuntu
# https://help.ubuntu.com/community/ImageMagick
sudo apt-get install imagemagick --fix-missing
# ignore below, just for information
# http://cn-popeye.iteye.com/blog/1236691
# install zlib
# page http://sourceforge.net/projects/libpng/files/zlib/1.2.5/zlib-1.2.5.tar.gz/download?use_mirror=superb-dca2
@guileen
guileen / app.js
Created April 23, 2012 07:54
node benchmark
var http = require('http')
http.createServer(function(req, res) {
res.end('hello world');
}).listen('/tmp/test.sock');