Skip to content

Instantly share code, notes, and snippets.

View wenbing's full-sized avatar

wenbing wenbing

View GitHub Profile
@wenbing
wenbing / 12306.user.js
Created January 5, 2012 13:39 — forked from quietlynn/12306.user.js
12306 Auto Query => A javascript snippet to help you book ticket
/*
12306 Auto Query => A javascript snippet to help you book tickets online.
Copyright (C) 2011 Jingqin Lynn
Includes jQuery
Copyright 2011, John Resig
Dual licensed under the MIT or GPL Version 2 licenses.
http://jquery.org/license
Includes Sizzle.js
@wenbing
wenbing / .tmux.conf
Created January 10, 2012 15:13 — forked from rdegges/.tmux.conf
My tmux configuration file.
set -g prefix C-a
unbind %
bind \ split-window -h
bind - split-window -v
bind-key k select-pane -U
bind-key j select-pane -D
bind-key h select-pane -L
bind-key l select-pane -R
@wenbing
wenbing / template.js
Created February 8, 2012 09:25
编写通用字符串替换函数replace, 例如 var a = 'hi, my name is {name}, I am {age} years old, my email is {email}.'; var b = {name:'max', age: 12, email: 'max@gmail.com'}; 执行 replace(a, b) 返回'hi, my name is max, I am 12 years old, my email is max@gmail.com.'
function template(str, obj) {
if(str.indexOf('{') === -1) {
return str;
}
var result = [];
var i, l = str.length;
var start = 0, end = 0, inner = false;
var curr, name, value, search;
for(i = 0; i < l; i++) {
curr = str[i];
@wenbing
wenbing / gist:2556294
Created April 30, 2012 07:37
walk in js
var walk = function(list, callback) {
var getCB = function(next) {
return function(o) {
callback(o, next)
};
},
handle = function() {
var item, cb, res = {};
if(list.length <= 0) {
return;
@wenbing
wenbing / gist:2934521
Created June 15, 2012 03:31
tail by php
function tail_read($filename, $lines = 10, $offset = 4096, $onLine = null) {
if(is_callable($lines)) {
$onLine = $lines;
$lines = 10;
$offset = 4096;
}
if(is_callable($offset)) {
$onLine = $offset;
$offset = 4096;
}
@wenbing
wenbing / gist:5523004
Created May 6, 2013 02:07
jitsu deploy error
error: Error running command deploy
error: Nodejitsu Error (400): Bad Request
warn: Error returned from Nodejitsu
error: Error: No active subscriptions available.
error: at Object.module.exports.billing.findAvailable (/root/nodejitsu/lib/nodejitsu/billing/billing.js:287:23)
error: at fn (/root/nodejitsu/lib/nodejitsu/billing/billing.js:187:24)
error: at Resource._request (/root/nodejitsu/node_modules/resourceful/lib/resourceful/resource.js:184:13)
error: at loop (/root/nodejitsu/node_modules/resourceful/lib/resourceful/resource.js:90:9)
error: at /root/nodejitsu/node_modules/resourceful/lib/resourceful/resource.js:78:20
error: at exports.resource.app.resources.User.app.define.after.method (/root/nodejitsu/node_modules/flatiron-http-users/lib/http-users/user/core.js:82:9)
<#function bodyClass>
<#local
uri = page.request.getRequestURI(),
uri = uri?replace("/", "", "f"),
parts = uri?split("/"),
classes = "page"
/>
<#if uri == "/">
<#local classes = classes + " page-index" />
</#if>
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
// ...
});
grunt.loadNpmTasks('grunt-contrib-uglify');
};
var Y = require('yui').YUI({useSync: true, filter: 'debug' });
Y.use('event-custom', 'oop');
function A(parent) {
if(parent) {
this.parent = parent;
this.addTarget(parent);
}
}
var express = require('express');
var app = express();
app.set('env', 'production');
app.get('/', function(req, res) {
throw new Error('dsjldsl');
});