Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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 / 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 / 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 / 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 / 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 / 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 / Trigger.js
Created September 11, 2011 10:48
A new flow control example, for cross reference
var Trigger = function() {
this.__callbacks = [];
this.__done = [];
};
Trigger.prototype = {
set: function(name) {
var self = this;
return function(err, result) {
if (err)
@guileen
guileen / gist:973054
Created May 15, 2011 11:10
nodejs parallel control flow by bitwise operation
var _a=0x01, _b=0x02, _c=0x04, _d=0x08, _e=0x10, _f=0x20, _done=0;
var triggers = [
function(){
// a,b 完成后,执行 d,execute d() when a and b done.
if(_done & (_a | _b)){
triggers.splice(triggers.indexOf(this), 1);
d(function(){
_done |= _d;