Skip to content

Instantly share code, notes, and snippets.

@jinzhu
jinzhu / 0001-support-pass-variables-from-routes-to-handler.patch
Created February 26, 2012 15:42
[PATCH form Gorilla] support pass variables from routes to handler
From a948c13b7073af9a0af4e3615cf4a245056a42f2 Mon Sep 17 00:00:00 2001
From: Jinzhu <wosmvp@gmail.com>
Date: Sun, 26 Feb 2012 23:34:58 +0800
Subject: [PATCH] support pass variables from routes to handler
---
route.go | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/route.go b/route.go
@jinzhu
jinzhu / resort.go
Created September 29, 2015 07:55
reset sorting positions
package main
import (
"reflect"
"github.com/qor/qor-example/app/models"
"github.com/jinzhu/gorm"
"github.com/qor/qor-example/db"
)
@jinzhu
jinzhu / gist:1381658
Created November 21, 2011 04:49
Ruby Mail for ISO-2022-JP / SHIFT_JIS
require 'rubygems'
gem 'mail', '=2.2.19'
require 'mail'
require 'nkf'
module Mail
module Encodings
class SevenBit
def self.decode(str)
#Tasks have been added to fully maintain nginx, unicorn, redis, memcached, start resque workers and run any command on any server in the farm.
#<pre>
#cap nginx:restart # Restart Nginx.
#cap nginx:start # Start Nginx.
#cap nginx:status # Status of Nginx.
#cap nginx:stop # Stop Nginx.
#cap nginx:tail_error # Tail the Nginx error logs.
#cap unicorn:reload # reload your unicorn servers.
#cap unicorn:restart # restart your unicorn servers.
#cap unicorn:start # start your unicorn servers.
@jinzhu
jinzhu / gist:956813
Created May 5, 2011 09:53
gzip script (used for nginx)
#!/bin/sh
cp $1 $1.tmp
## Remove the old gz if there is one
rm -rf $1.gz
## Compress the tmp HTML copy. Use the highest level 9
## compression and do not store dates or file names
## in the gzip header. BTW, if the compressed gz is
## larger then the original file a gzip will NOT be made.
while true
do
sleep 0.5
if [ -f /dev/sdj ]; then
echo `date` > SdjMountedAt
sudo mount /dev/sdj /mnt/DATA
sudo /etc/init.d/httpd start
sudo /etc/init.d/mysqld start
cd /mnt/DATA/mysql-server-tritonn; sudo ./bin/mysqld_safe &
sudo su postgres -c '/usr/local/pgsql/bin/pg_ctl -D /mnt/DATA/pgsql -l /mnt/DATA/pgsql/log start'
keyBindings = (function(){
var keyId = {
"U+0008" : "BackSpace",
"U+0009" : "Tab",
"U+0018" : "Cancel",
"U+001B" : "Esc",
"U+0020" : "Space",
"U+0021" : "!",
"U+0022" : "\"",
"U+0023" : "#",
require 'geoip'
module Rack
# Rack::GeoIPCountry uses the geoip gem and the GeoIP database to lookup the country of a request by its IP address
# The database can be downloaded from:
# http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz
#
# Usage:
# use Rack::GeoIPCountry, :db => "path/to/GeoIP.dat"
#
# See also http://github.com/simonjefford/rack_firebug_logger
# for this middleware + tests + a rails plugin
class FirebugLogger
def initialize(app, options = {})
@app = app
@options = options
end
def call(env)
dup._call(env)
@jinzhu
jinzhu / _README.md
Created November 23, 2009 03:05 — forked from kneath/_README.md

GitHub Javascript Strategy

Unless otherwise necessary (such as mobile development), the GitHub javascript codebase is based off jQuery. You can safely assume it will be included on every page.

File naming

  • All jquery plugins should be prefixed with jquery, such as jquery.facebox
  • All github-specific jquery plugins should be prefixed with jquery.github. Like jquery.github.repo_list.js
  • All page-specific files (that only run on ONE page) should be prefixed with page. page.billing.js