Skip to content

Instantly share code, notes, and snippets.

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

Leon Guan pzgz

🏠
Working from home
View GitHub Profile
@pzgz
pzgz / jui_bootstrap_adapter.js
Created November 7, 2011 09:55
Try to adapt bootstrap with jquery ui, mainly resolve conflict on tabs and button functions.
$(function() {
function setState(el, state) {
var d = 'disabled'
, $el = $(el)
, data = $el.data()
state = state + 'Text'
data.resetText || $el.data('resetText', $el.html())
@pzgz
pzgz / fibonacci.rb
Created December 14, 2011 18:11
Fibonacci Bench Testing
def fibonacci(n)
a,b = 0, 1
n.times do
a,b = b,a+b
end
b
end
puts fibonacci(40)
@pzgz
pzgz / syntax_highlighting.py
Created January 2, 2012 19:16 — forked from JeanMertz/syntax_highlighting.py
Ruby on Rails syntax highlight switcher for Sublime Text 2
import sublime, sublime_plugin
import os
class DetectFileTypeCommand(sublime_plugin.EventListener):
""" Detects current file type if the file's extension isn't conclusive """
""" Modified for Ruby on Rails and Sublime Text 2 """
""" Original pastie here: http://pastie.org/private/kz8gtts0cjcvkec0d4quqa """
def on_load(self, view):
filename = view.file_name()
@pzgz
pzgz / Word2Textile.vb
Last active September 14, 2016 20:50
Word2Textile
Sub Word2Textile()
'
' Word2Textile Macro
' Macro created 7/18/11 by Jim Syler, zarquon42@aol.com
' Modified from Word2MediaWiki, <http://www.infpro.com/Word2MediaWiki.aspx>
' Textile format information available at <http://redcloth.org/hobix.com/textile/>
' copied from http://pastebin.com/4GUetmBd, Ref to http://www.obsidianportal.com/campaign/sydarksun/wikis/word-to-textile-conversion
'
Application.ScreenUpdating = False
@pzgz
pzgz / datatables_ajax_url_decode.rb
Created September 21, 2012 04:15
Decode datatables ajax request URL in ruby controller
# Process AJAX request generated by jquery datatables plugin, prepare an object which contains information to be used in
# ActiveRecord operation, result object properties tbd
def decode_datatables_req
cols_count = params['iColumns'].to_i
row_start = params['iDisplayStart'].to_i
rows_per_page = params['iDisplayLength'].to_i
search_text = params['sSearch']
sort_cols_count = params['iSortingCols'].to_i
columns = (0..cols_count-1).map { |i| params["mDataProp_#{i}"] }
@pzgz
pzgz / custom reader css for safari to show codes
Created December 4, 2012 17:58
CSS for CustomReader in Safari for better display on pre and code blocks
.page {
width: 680px;
background-color: #f3f2ee;
color: #000000;
text-rendering: optimizelegibility;
font-family: Georgia !important;
}
.page > * {
zoom: 1;
}
@pzgz
pzgz / disable_flash_p2p_uploading
Created December 10, 2012 13:17
禁用Flash P2P上传, credit to http://pastebin.com/pL749WiL
Mac OS:
sudo bash -c 'echo RTMFPP2PDisable=1 >> /Library/Application\ Support/Macromedia/mms.cfg'
Windows:
echo RTMFPP2PDisable=1 >> %windir%\system32\Macromed\Flash\mms.cfg
echo RTMFPP2PDisable=1 >> %windir%\syswow64\Macromed\Flash\mms.cfg
echo RTMFPP2PDisable=1 >> %windir%\system32\mms.cfg
Linux:
sudo mkdir -p /etc/adobe
@pzgz
pzgz / my_oh-my-zsh_aliases.zsh
Created December 12, 2012 02:27
My oh-my-zsh aliases, located in ~/.oh-my-zsh/lib/aliases.zsh
# My Alias
alias ams='cd ~/Workspace/pzgz/tongji_ams/ams'
alias workspace='cd ~/Workspace/'
alias ws='cd ~/Workspace/'
alias os='cd ~/Workspace/opensources'
alias adx='cd ~/Workspace/adsvana/adx'
alias bid='cd ~/Workspace/adsvana/adx_bidder'
alias is='cd ~/Workspace/pzgz/itravels/'
alias ib='cd ~/Workspace/pzgz/itravels/backbone/'
alias ims='cd ~/Workspace/pzgz/pister/ims/'
@pzgz
pzgz / update.sh
Created December 30, 2012 09:28
GraceMode autoddvpn update script for tomato firmware
#!/bin/sh
#set -x
host='autoddvpn.googlecode.com'
cv_dir='/jffs/var/'
cv_file="${cv_dir}version.client"
vpnup_remote_path='http://autoddvpn.googlecode.com/svn/trunk/grace.d/vpnup.sh'
vpndown_remote_path='http://autoddvpn.googlecode.com/svn/trunk/grace.d/vpndown.sh'
vpnup_local_path='/jffs/openvpn/vpnup.sh'
vpndown_local_path='/jffs/openvpn/vpndown.sh'
@pzgz
pzgz / brew --config
Created June 11, 2014 06:01
Brew Doctor Error about zLib Import
~  brew --config
HOMEBREW_VERSION: 0.9.5
ORIGIN: https://github.com/Homebrew/homebrew.git
HEAD: 25cffcf1e4fa8b2bc8f989d33d8946978a2da9d4
HOMEBREW_PREFIX: /usr/local
HOMEBREW_CELLAR: /usr/local/Cellar
CPU: 8-core 64-bit ivybridge
OS X: 10.9.4-x86_64
Xcode: 5.1.1
CLT: 5.1.0.0.1.1396320587