Skip to content

Instantly share code, notes, and snippets.

View he9lin's full-sized avatar

Lin He he9lin

View GitHub Profile
// $.widget is a factory to create jQuery plugins
// taking some boilerplate code out of the plugin code
function getter(namespace, plugin, method, args) {
function getMethods(type) {
var methods = $[namespace][plugin][type] || [];
return (typeof methods == 'string' ? methods.split(/,?\s+/) : methods);
}
var methods = getMethods('getter'); //[ui][plugin_name][getter], all getter methods
if (args.length == 1 && typeof args[0] == 'string') {
puts Readline:HISTORY.entries.split("exit").last[0..-2].join("\n")
//http://bililite.com/blog/2008/08/05/namespaces-in-jquery/
(function($){
if ({}.__proto__){
// mozilla & webkit expose the prototype chain directly
$.namespace = function(name){
$.fn[name] = function namespace() { // insert this function in the prototype chain
this.__proto__ = arguments.callee;
return this;
};
// jQuery based CSS parser
// documentation: http://youngisrael-stl.org/wordpress/2009/01/16/jquery-css-parser/
// Version: 1.1
// Copyright (c) 2009 Daniel Wachsstock
// MIT license:
// 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
this.headers
this.active.find
this.active.outerHeight()
this.element
this.headers
.attr('role', 'tab')
@he9lin
he9lin / deploy_rails_app_on_ubuntu.md
Created October 1, 2011 09:51
Setup Rails application production environment on Ubuntu

Setup Rails application production environment on Ubuntu

Add deploy user

ssh root@YOURDOMAIN
adduser deploy
visudo # Add deploy ALL=(ALL) ALL

Install necessary libraries

@he9lin
he9lin / gist:2054587
Created March 17, 2012 02:55 — forked from JakubOboza/gist:2008958
faye as subdomain
upstream faye {
server 127.0.0.1:9292;
}
upstream webrick{
server 127.0.0.1:3000;
}
server {
listen 80 default;
@he9lin
he9lin / AsyncTaskTests.java
Created March 25, 2012 14:29
How to test AsyncTask in Android
package jieqoo.android.KASS.test.tasks;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import jieqoo.android.models.RESTListener;
import jieqoo.android.models.RESTResponse;
import jieqoo.android.tasks.FetchRESTResponseTask;
import jieqoo.android.util.Configuration;
import android.test.InstrumentationTestCase;
@he9lin
he9lin / Gemfile
Created May 26, 2012 14:19
Project Gemfile
source 'http://rubygems.org'
gem 'rails', '3.1.1'
group :assets do
gem 'sass-rails', '~> 3.1.4'
gem 'coffee-rails', '~> 3.1.1'
gem 'uglifier', '>= 1.0.3'
gem 'compass', "0.12.alpha"
end
@he9lin
he9lin / chef_solo_bootstrap.sh
Last active December 15, 2015 01:29 — forked from ryanb/chef_solo_bootstrap.sh
Chef solo bootstrap with Berkshelf
```
#!/usr/bin/env bash
apt-get -y update
apt-get -y install build-essential zlib1g-dev libssl-dev libyaml-dev libxslt-dev git-core autoconf bison libssl-dev libreadline6-dev libncurses5-dev
cd /tmp
wget http://cache.ruby-lang.org/pub/ruby/2.1/ruby-2.1.4.tar.gz
tar -xzf ruby-2.1.4.tar.gz
cd ruby-2.1.4/
./configure --prefix=/usr/local --with-readline-dir=/usr/include/readline
make