Skip to content

Instantly share code, notes, and snippets.

View xianhuazhou's full-sized avatar

xianhua zhou xianhuazhou

View GitHub Profile
@xianhuazhou
xianhuazhou / find_fields_from_form.rb
Created January 15, 2010 03:54
find all available fields/values from a from by Hpricot
# encoding: utf-8
require 'rubygems'
require 'hpricot'
def find_fields_from_form(form)
fields = {}
return fields unless form.is_a? Hpricot::Elem
set_parameter = Proc.new {|name, value|
case name
when /^(.+)\[\]$/
#
# convert xml data to hash with hpricot
#
# by xianhua.zhou@gmail.com
require 'rubygems'
require 'hpricot'
require 'ap'
class ConvertXml
def initialize(filename)
<?php
$str = '这是中国和中国的句子,把中国替换成其它的,把中国的替换成另一个';
$str = str_replace('中国的', '<a href="a.php"><中国的</a>', $str);
$str = preg_replace('/(中国)([^的])/', '<a href="b.php">$1</a>$2', $str) . "\n";
echo $str;
$ sudo apt-get install hfsplus hfsutils
$ sudo mount -t hfsplus /dev/hda /media/cdrom
. /sw/bin/init.sh
export CFLAGS=-I/sw/include
export LDFLAGS=-L/sw/lib
export CXXFLAGS=$CFLAGS
export CPPFLAGS=$CXXFLAGS
export ACLOCAL_FLAGS="-I /sw/share/aclocal"
export PKG_CONFIG_PATH="/sw/lib/pkgconfig"
export PATH=/sw/var/lib/fink/path-prefix-10.6:$PATH
export MACOSX_DEPLOYMENT_TARGET=10.6
@xianhuazhou
xianhuazhou / gist:662184
Created November 4, 2010 06:32
xstartup
#!/bin/sh
unset SESSION_MANAGER
sh /etc/X11/xinit/xinitrc
def bubble_sort(array)
size = array.size - 1
0.upto(size) do |i|
i.upto(size) do |j|
array[i], array[j] = array[j], array[i] if array[i] > array[j]
end
end
array
end
@xianhuazhou
xianhuazhou / gist:893960
Created March 30, 2011 06:39
selection styles
p.normal::selection {
background:#cc0000;
color:#fff;
}
p.moz::-moz-selection {
background:#cc0000;
color:#fff;
}
Fatal error: Call to undefined function safeBitCheck() in /var/www/hfchina.com/mzag2_hfchina/caches/GUI/Smarty/Compiled/%%C8^C8C^C8CE918D%%detail.fairs.tpl.php on line 117
from: http://www.hmf-china.com/index.php?scriptlet=CMS/Start&tpl=fairs&id=783&cID=15