This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ "hasvisible" : false, | |
"next_cursor" : 0, | |
"previous_cursor" : 0, | |
"statuses" : [ { "comments_count" : 0, | |
"created_at" : "Sat Feb 25 20:38:04 +0800 2012", | |
"favorited" : false, | |
"geo" : null, | |
"id" : 3417057616355950, | |
"idstr" : "3417057616355950", | |
"in_reply_to_screen_name" : "", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
STR_REGEXP = /[a-zA-Z0-9:]/ | |
str = "iceskysl...balalal" | |
if str =~ UNICODE_STR_DLD_REGEXP | |
puts "==bad str: #{str}" | |
else | |
puts "ok......pass" | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Taken from passenger_memory_stats script | |
# Returns the private dirty RSS for the given process, in KB. | |
def determine_private_dirty_rss(pid) | |
total = 0 | |
File.read("/proc/#{pid}/smaps").split("\n").each do |line| | |
line =~ /^(Private)_Dirty: +(\d+)/ | |
if $2 | |
total += $2.to_i | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
production: | |
listen: 0.0.0.0:9312 | |
address: 0.0.0.0 # 对应的安装了searchd(sphinx)的mysql服务器ip | |
port: 9312 # 对应的安装了searchd(sphinx)的mysql服务器端口 | |
bin_path: '/usr/local/bin' | |
searchd_file_path: '/data/sphinx/production' | |
query_log_file: '/data/sphinx/log/searchd.query.log' | |
searchd_log_file: '/data/sphinx/log/searchd.log' | |
exceptions: '/data/sphinx/log//exception.log' | |
enable_star: true # 支持通配符匹配 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "rubygems" | |
require "date" | |
start_d = Date.parse( '2010-01-01' ) | |
end_d = Date.today - 1 | |
start_d.step(end_d , step=1){|d| | |
puts d | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
location ~* ^.+\.(jpg|jpeg|gif|png|bmp|ico|css|js|swf|lrc)$ { | |
access_log off; | |
expires 30d; | |
} | |
location ~* ^.+\.(mp3|wma|rar|zip|flv)$ { | |
expires 30d; | |
} | |
location ~* ^.+\.(htm|html|xml)$ { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Converts an IP string to integer | |
def ip2int(ip) | |
return 0 unless ip =~ /d{1,3}.d{1,3}.d{1,3}.d{1,3}/ | |
v = ip.split('.').collect { |i| i.to_i } | |
return (v[0] << 24) | (v[1] << 16) | (v[2] << 8 ) | (v[3]); | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
svn remove log/* | |
svn commit -m"removing log files" | |
svn propset svn:ignore "*.log" log/ | |
svn update log/ | |
svn commit -m 'Ignoring all files in /log/ ending in .log' | |
svn move config/database.yml config/database.example | |
svn commit -m 'Moving database.yml to database.example to provide a template for anyone who checks out the code' | |
svn propset svn:ignore "database.yml" config/ | |
svn update config/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%w("en", "en_US", "_US", "en__POSIX", "en_US_POSIX", "zh-rCN" , "zh-r").each do |locale| | |
puts locale | |
if(locale =~ /^([^-_]+)[-_]?r?([^-_]+)?[-_]?([^-_]+?)$/) | |
puts "$1=#{$1},$2=#{$2},$3=#{$3}" | |
end | |
end | |
output | |
"en", | |
$1="en",$2=,$3=, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<eoe status="true"> | |
<jokes> | |
<page>1</page> //当前请求的页数 | |
<per_page>20</per_page> //当前请求页中的条数 | |
<totle_page>1</totle_page> //总页数 | |
<total_entries>2</total_entries> //总数 | |
<list> //笑话列表 | |
<joke> //笑话 | |
<id>2</id> //编号 | |
<title>这个字段是笑话的标题</title> //笑话标题 |