Skip to content

Instantly share code, notes, and snippets.

View saighost's full-sized avatar

saighost saighost

View GitHub Profile
var Objectifier = (function() {
// Utility method to get and set objects that may or may not exist
var objectifier = function(splits, create, context) {
var result = context || window;
for(var i = 0, s; result && (s = splits[i]); i++) {
result = (s in result ? result[s] : (create ? result[s] = {} : undefined));
}
return result;
};
@saighost
saighost / smsclient.js
Created October 25, 2012 01:11
短信SDK
//client
(function () {
var smsclient = {};
module.exports = smsclient;
var cfg = require("./config").config;
var soap = require('soap');
@saighost
saighost / weibo_wap.js
Created August 14, 2012 14:47 — forked from dongyuwei/weibo_wap.js
自动登陆新浪微博移动版( http://m.weibo.cn ) 发微博
var http = require('http');
var qs = require('querystring');
function parse_response(res, callback) {
var list = [];
res.on('data', function(chunk) {
list.push(chunk);
});
res.on('end', function() {
callback(Buffer.concat(list).toString());
@saighost
saighost / gist:3303773
Created August 9, 2012 12:21 — forked from fxsjy/gist:3291755
Memcached in JavaScript based on Node.JS
//author: Sun, Junyi (weibo.com/treapdb)
//usage: node --nouse-idle-notification --expose-gc --max-old-space-size=8192 memcached.js
var config ={
port: 11211,
max_memory: 100 // default 100M bytes
}
var net = require('net');
var LRU = function (max) { // this LRU implementaion is based on https://github.com/chriso/lru
@saighost
saighost / RemoveMultipleSpaces.cs
Created March 28, 2012 17:31 — forked from Ninputer/RemoveMultipleSpaces.cs
模拟微面试之去空格
//请实现下面的函数,输入参数baseStr是一个(可以更改的)字符串,请将其中所有连续出现的多个空格都替换成一个空格,单一空格需保留。
//请直接使用baseStr的空间,如需开辟新的存储空间,不能超过o(N)(注意是小o,N是字符串的长度)。返回值是替换后的字符串的长度。
//样例代码为C#,但可以使用任何语言。如需使用任何库函数,必须同时给出库函数的实现。
class Program
{
public static int RemoveMultipleSpaces(char[] baseStr)
{
if(baseStr==null){
return 0;
}
if (typeof (AC) === "undefined") {
AC = {}
}
AC.ImageReplacer = Class.create({
_defaultOptions: {
listenToSwapView: true,
filenameRegex: /(.*)(\.[a-z]{3}($|#.*|\?.*))/i,
filenameInsert: "_☃x",
ignoreCheck: /(^http:\/\/movies\.apple\.com\/|\/105\/|\/global\/elements\/quicktime\/|_(([2-9]|[1-9][0-9]+)x|nohires)(\.[a-z]{3})($|#.*|\?.*))/i,
attribute: "data-hires",