Skip to content

Instantly share code, notes, and snippets.

View mashihua's full-sized avatar
🏠
Working from home

Shihua Ma mashihua

🏠
Working from home
View GitHub Profile
@mashihua
mashihua / LICENSE.txt
Created May 19, 2011 19:31 — forked from madrobby/LICENSE.txt
Functional array sorting
Copyright (c) 2011 Thomas Fuchs, http://mir.aculo.us
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
@mashihua
mashihua / LICENSE.txt
Created May 19, 2011 19:35 — forked from 140bytes/LICENSE.txt
140byt.es -- Click ↑↑ fork ↑↑ to play!
Copyright (c) 2011 YOUR_NAME_HERE, YOUR_URL_HERE
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
@mashihua
mashihua / README
Created May 24, 2011 03:53
javascript development script
Watch a dir to concat javascript file when it is change.
@mashihua
mashihua / README
Created June 29, 2011 02:24
Cloud9 IED http_digest_auth Patch
Add http_digest_auth for Cloud9 IED.
Step:
1.git clone https://github.com/ajaxorg/cloud9.git
2.git submodule update --init --recursive
3.git apply cloud9.patch
4.bin/cloud9.sh -c config.js
5.open the url http://127.0.0.1:3000/
6.when prompt the authorization,username is admin and password is admin.
@mashihua
mashihua / get-node
Created August 25, 2011 05:59
All built-in function and javascript source in Node.js
#!/usr/bin/env node
//all built-in module and lib/*.js,expcept node.js
['constants','io_watcher','timer','buffer','cares','child_process','evals','fs','net','http_parser','signal_watcher','stdio','os'].forEach(function(v){
console.log('built-in module:\t' + v);
console.dir(require('sys').inspect(process.binding(v)));
});
console.log('all javascript from built-in module natives,expect node.js');
var sources = process.binding('natives');
Object.keys(sources).forEach(function(key){
@mashihua
mashihua / install_node.sh
Created September 23, 2011 14:23
Install node.js on Ubuntu
#!/bin/bash
NODE_VERSION=0.4.12
NODE_FILE=node-v$NODE_VERSION
MY_USER=mashihua
REDIS_VERSION=2.0.3
apt-get update
apt-get install -y build-essential git-core nginx libssl-dev pkg-config
wget http://nodejs.org/dist/$NODE_FILE.tar.gz
@mashihua
mashihua / Capfile
Created October 12, 2011 10:40
Capistrano deploy script for node.js
load 'deploy' if respond_to?(:namespace) # cap2 differentiator
Dir['vendor/gems/*/recipes/*.rb','vendor/plugins/*/recipes/*.rb'].each { |plugin| load(plugin) }
load 'config/deploy' # remove this line to skip loading any of the default tasks
load 'config/node'
@mashihua
mashihua / node_debian_init.sh
Created October 19, 2011 07:34 — forked from peterhost/node_debian_init.sh
Daemon init script for node.js based app/server (DEBIAN/UBUNTU)
#!/bin/sh
# ------------------------------------------------------------------------------
# SOME INFOS : fairly standard (debian) init script.
# Note that node doesn't create a PID file (hence --make-pidfile)
# has to be run in the background (hence --background)
# and NOT as root (hence --chuid)
#
# MORE INFOS : INIT SCRIPT http://www.debian.org/doc/debian-policy/ch-opersys.html#s-sysvinit
# INIT-INFO RULES http://wiki.debian.org/LSBInitScripts
# INSTALL/REMOVE http://www.debian-administration.org/articles/28
@mashihua
mashihua / arg.js
Created October 20, 2011 10:13
get arguments
function arg(type) {
var r,t = Object.prototype.toString;
[].forEach.call(arguments.callee.caller.arguments, function (a) {
if (!r && t.call(arguments[0]).replace(/^[^\s]+\s([^\]]+)]/ig,"$1").toLowerCase() === type.toLowerCase()) r = a;
});
return r;
}
@mashihua
mashihua / hackcmb.js
Created December 2, 2011 22:02
Enable mobile CMB on desktop Safari
SubmitControl.prototype.submit = function() {
var sXmlReq = "";
if (BSGetElementIgnoreError("TransID_New") != null) {
this.addFieldByElementId("TransID_New");
}
for (var i = 0; i < this.m_fields.length; i++) {
var sName = (this.m_fields[i])[0];
var sValue = (this.m_fields[i])[1];
if ((sName != null) && (sValue != null)) {
sValue = sValue.replace("%", "%25");