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
# 去除区域里面的HTML内容的换行和空白标记 | |
def spaceless(&block) | |
data = with_output_buffer(&block) | |
data = data.gsub(/>\s+</,"><") | |
data | |
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
# coding: UTF-8 | |
# | |
# Yupoo 照片备份工具 | |
# 此工具不需要API,直接就能备份你的照片信息,下载后以图片 + 一个文本文件的方式存放 | |
# 备份包括内容: | |
# 原图,标题,说明,Tag,当然有 Exif 信息 | |
# | |
# Jason Lee <[email protected]> | |
# http://huacnlee.com | |
# 2011-01-28 |
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 "thor/shell" | |
say("Modifying a new Rails app ...", :yellow) | |
#---------------------------------------------------------------------------- | |
# Configure | |
#---------------------------------------------------------------------------- | |
=begin | |
unless options[:database] == 'sqlite3' | |
username = ask("What's your database username[root]") | |
username = 'root' if username.blank? |
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
Coreseek (Sphinx) for MySQL 数据源 安装教程 | |
1. 下载源代码 | |
$ wget http://www.coreseek.cn/uploads/csft/3.2/coreseek-3.2.13.tar.gz | |
$ tar xzf coreseek-3.2.13.tar.gz | |
$ cd coreseek-3.2.13 | |
2. 中文测试环境检查: |
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
def safe_login(str) | |
str.gsub(/[^a-z0-9\-_]/,'') | |
end | |
# Test | |
ruby-1.9.2-p0 > safe_login("asdlg1-24_1(*&(sdgsdg") | |
=> "asdlg1-24_1sdgsdg" |
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
# coding: UTF-8 | |
# | |
# 以下为 Rake 任务,功能是将普通文件系统里面的东西转移到 MongoDB GridFS 里面 | |
# 此代码片段来自于 Homeland 项目: https://github.com/huacnlee/homeland/tree/mysql | |
# 场景: | |
# 老架构 Linux File Store, Paperclip, hash 目录:"https://github.com/huacnlee/homeland/blob/ca0bdd8ab26da7b780e2dae7eba12b79f41e6d65/config/initializers/paperclip_hashpath.rb" | |
# 新架构 Mongodb GridFS, Garrierwave, 继续沿用 Paperclip 目录兼容: https://github.com/huacnlee/homeland/tree/7100ce4c506cc2c4387f25e50c533e5bbcac6cc2/app/uploaders | |
# 整个过程不会修改任何原始数据库和上传文件 | |
# | |
require 'mongo' |
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
sudo apt-get install libjpeg8-dev libmysqlclient-dev | |
curl -O http://www.php.net/get/php-5.3.5.tar.gz/from/a/mirror | |
curl -O http://mirror.bjtu.edu.cn/apache//httpd/httpd-2.2.17.tar.gz | |
tar zxf httpd-2.2.17.tar.gz | |
cd httpd-2.2.17 | |
./configure --prefix=/etc/apache2 --enable-so --enable-cgi --enable-info --enable-rewrite \ | |
--enable-speling --enable-usertrack --enable-deflate --enable-ssl --enable-mime-magic \ | |
--enable-dav --enable-vhost-alias --enable-proxy --enable-expires --enable-headers | |
make && sudo make install | |
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
// jQuery need | |
setTimeout(showBTW, 1000); | |
function showBTW(){ | |
$("body").append('<div class="bottom_pop_window">\ | |
<div class="title">热门推荐<a href="#" onclick="return closeBTW();" class="close">关闭</a></div> \ | |
<iframe src="/btw" frameborder="no"></iframe></div>'); | |
$(".bottom_pop_window").css("bottom",-140).animate({ bottom : 10 }); | |
} | |
function closeBTW(){ |
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
function FindProxyForURL(url, host) { | |
var socksResult = "SOCKS 127.0.0.1:7070"; | |
if (shExpMatch(url, "*://*.scribd.com/*")) { return socksResult; } | |
if (shExpMatch(url, "*://scribd.com/*")) { return socksResult; } | |
if (shExpMatch(url, "*://goo.gl/*")) { return socksResult; } | |
if (shExpMatch(url, "*://feedproxy.google.com/*")) { return socksResult; } | |
if (shExpMatch(url, "*://*.googlecode.com/*")) { return socksResult; } | |
if (shExpMatch(url, "*://googlecode.com/*")) { return socksResult; } | |
if (shExpMatch(url, "*://*.youtube.com/*")) { return socksResult; } | |
if (shExpMatch(url, "*://youtube.com/*")) { return socksResult; } |
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
redis-search 0.3 Benchmark | |
Core 2 Duo CPU 2.66G, 4G Memory | |
20W 数据 | |
# coding: utf-8 | |
require "benchmark" | |
["的","美丽","云","云儿","花","云儿的"].each do |key| |