Skip to content

Instantly share code, notes, and snippets.

View zliang-min's full-sized avatar

Gimi Liang zliang-min

View GitHub Profile
@zliang-min
zliang-min / php-cgi.rc.sh
Created March 21, 2011 02:25
php-cgi rc script for archlinux
#!/bin/bash
# vim: syntax=sh
. /etc/rc.conf
. /etc/rc.d/functions
daemon_name=php-cgi
BIND=/tmp/php-cgi.socket
USER=gimi
diff --git a/gc.c b/gc.c
--- a/gc.c
+++ b/gc.c
@@ -77,6 +77,41 @@ void *alloca ();
#ifndef GC_MALLOC_LIMIT
#define GC_MALLOC_LIMIT 8000000
#endif
+#define HEAP_MIN_SLOTS 10000
+#define FREE_MIN 4096
+
@zliang-min
zliang-min / crossdomain.xml
Created March 9, 2011 06:51
A flash crossdomain.xml sample.
<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy SYSTEM "http://www.adobe.com/xml/dtds/cross-domain-policy.dtd">
<cross-domain-policy>
<allow-access-from domain="your.domain.com" />
</cross-domain-policy>
@zliang-min
zliang-min / jquery plugins.md
Created March 1, 2011 02:58
一些常用的plugin

jquery.maskedinput jquery.metadata

VALIDATION: jquery.validate metadataRules classRules attributeRules staticRules

jquery.blockUI[http://jquery.malsup.com/block/]

@zliang-min
zliang-min / replica sets.md
Created March 1, 2011 02:14
A summary of MongoDB Replica Sets

MongoDB

Replica Sets

  • Supports more than two servers in the cluster
  • Better failover and recovery between nodes
  • Data center aware (rack aware too, eventually)
  • Can have passive set members (slaves) that are never primary

配置

启动命令

@zliang-min
zliang-min / highlight-cat.rb
Created February 24, 2011 17:13
The syntax highlighting cat.
#!/usr/bin/env ruby
require 'syntax/convertors/html'
require 'rainbow'
filename = ARGV[0]
puts ARGV[0]
line_num=0
tokenizer = Syntax.load "ruby"
@zliang-min
zliang-min / rails_cache.md
Created February 18, 2011 08:37
Rails cache summary.

Rails 2

  • Specify RAILS_CACHE directly in environment.rb, like: RAILS_CACHE = ActiveSupport::Cache.lookup_store :memory_store.

  • Use config.cache_store=, like: config.cache_store = :memory_store. In fact, it calls ActiveSupport::Cache.lookup_store.

  • Another example of cache_store usage: config.cache_store = [:mem_cache_store, 'memhost:11211', {:namespace => 'gimi', :autofix_keys => true}]

  • By default, ActionController::Base.cache_store will be set to RAILS_CACHE, but it can be changed by using ActionController::Base.cache_store=.

  • About session store: ActionController::Base.session= will set ActionController::Base.session_options. ActionController::Base.session_store= decides which store will be used.

@zliang-min
zliang-min / google_map.html
Created February 16, 2011 08:30
A simple google map api example.
<!doctype html>
<html lang='zh'>
<head>
<meta charset="UTF-8">
<!-- For mobile devices. -->
<title>Google map</title>
<style type="text/css">
#map_canvas { width:299px;height:234px; }
</style>
<script type="text/javascript" src="http://ditu.google.cn/maps/api/js?sensor=false"></script>
@zliang-min
zliang-min / ruby-1.9-tips.rb
Created February 6, 2011 03:52 — forked from igrigorik/ruby-1.9-tips.rb
ruby-1.9-tips
def tip(msg); puts; puts msg; puts "-"*100; end
#
# 30 Ruby 1.9 Tips, Tricks & Features:
# http://www.igvita.com/2011/02/03/new-ruby-19-features-tips-tricks/
#
tip "Upgrading to Ruby 1.9 is simple: rvm install 1.9.2 && rvm --default 1.9.2"
tip "Ruby 1.9 supports named captures in regular expressions!"
@zliang-min
zliang-min / memory_bloat.rb
Created January 25, 2011 08:21 — forked from quake/memory_bloat.rb
一个检查内存泄漏的rack中间件
module Rack
class MemoryBloat
def initialize(app, logger)
@app = app
@logger = logger
end
def call(env)
memory_usage_before = memory_usage
result = @app.call(env)