Skip to content

Instantly share code, notes, and snippets.

View ihower's full-sized avatar
🎯
Focusing

Wen-Tien Chang ihower

🎯
Focusing
View GitHub Profile
production: &defaults
min_word_len: 1
charset_table: U+FF10..U+FF19->0..9, 0..9, U+FF41..U+FF5A->a..z, U+FF21..U+FF3A->a..z,A..Z->a..z, a..z, U+0149, U+017F, U+0138, U+00DF, U+00FF, U+00C0..U+00D6->U+00E0..U+00F6, U+00E0..U+00F6, U+00D8..U+00DE->U+00F8..U+00FE, U+00F8..U+00FE, U+0100->U+0101, U+0101, U+0102->U+0103, U+0103, U+0104->U+0105, U+0105, U+0106->U+0107, U+0107, U+0108->U+0109, U+0109, U+010A->U+010B, U+010B, U+010C->U+010D, U+010D, U+010E->U+010F, U+010F, U+0110->U+0111, U+0111, U+0112->U+0113, U+0113, U+0114->U+0115, U+0115, U+0116->U+0117, U+0117, U+0118->U+0119, U+0119, U+011A->U+011B, U+011B, U+011C->U+011D, U+011D, U+011E->U+011F, U+011F, U+0130->U+0131, U+0131, U+0132->U+0133, U+0133, U+0134->U+0135, U+0135, U+0136->U+0137, U+0137, U+0139->U+013A, U+013A, U+013B->U+013C, U+013C, U+013D->U+013E, U+013E, U+013F->U+0140, U+0140, U+0141->U+0142, U+0142, U+0143->U+0144, U+0144, U+0145->U+0146, U+0146, U+0147->U+0148, U+0148, U+014A->U+014B, U+014B, U+014C->U+014D, U+014D, U+014E->U+014F, U+014F
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Registrano | Lobby</title>
</head>
<body id="lobby-page">
<style type="text/css">
[user]
name = Wen-Tien Chang
email = [email protected]
[alias]
co = checkout
ci = commit
sh = !git-sh
[color]
diff = auto
status = auto
@ihower
ihower / gist:115577
Created May 21, 2009 17:18
convert big5 hex codepoint to utf-8 string
require 'iconv'
$KCODE = 'u'
hex_string ="4A6BA441" # A441 is big5 "乙"
big5_string = hex_string.scan(/../).map{ |c| c.hex }.pack("c*")
iconv = Iconv.new("utf-8//ignore", "big5")
utf8_string = iconv.iconv(big5_string) # convert to utf-8
puts utf8_string # output JK乙
SetEnv force-proxy-request-1.0 1
SetEnv proxy-nokeepalive 1
# Rewrite index to check for static
RewriteRule ^/$ /index.html [QSA]
# Rewrite to check for Rails cached page
RewriteRule ^([^.]+)$ $1.html [QSA]
# Redirect all non-static requests to cluster
@ihower
ihower / gist:78473
Created March 13, 2009 07:47
Counting Black Friday
# http://www.geocities.com/calshing/dayofweek.htm
def get_week( year , month , day)
c = year.to_s[0, year.to_s.length-2 ].to_i
y = year.to_s[year.to_s.length-2,2]
a = (14-month)/12
y = y.to_i - a
m = month + 12*a - 2
y_div_4 = ( y == 0 )? 0 : (y/4)
MD5 test
# ruby
require 'digest/md5'
puts Digest::MD5.hexdigest( File.read('foobar.png') )
# php5
echo md5( file_get_contents('foobar.png') );
class ApplicationController < ActionController::Base
before_filter :log_session
def log_session
logger.info("Session debug: #{ (session.cgi.cookies['_registrano_session']).to_yaml }")
logger.info("Cookie get: #{session.instance_variable_get("@data").to_yaml}")
end
# HTML (from http://960.gs/ code example)
<div class="container_12">
<div class="grid_7 prefix_1">
<div class="grid_2 alpha">
<p>...</p>
</div>
<div class="grid_3">
<p>...</p>
</div>
# Helper
def grid_row( cols )
out = ""
cols.each do |col|
out << "<div class=\"grid_#{col[0]}\">#{col[1]}</div>"
end
return out
end