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
# RSS采集并自动发帖到某网站 | |
require 'mechanize' | |
require 'simple-rss' | |
puts "loading exists guid list..." | |
# 读取已存在的guids | |
old_guids = [] | |
guid_file = File.open('guids.dat',"a+") | |
guid_file.each_line { |line| old_guids << line.gsub("\n",'') } |
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
# 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
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
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
# 去除区域里面的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
module StringExtensions | |
def remove_html_tags() | |
self.gsub(/<.+?>/, "") | |
end | |
# clear unsafe char with url slug | |
def safe_slug(spliter = '-') | |
@slug = self | |
if @slug.blank? | |
Guid.new |
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
# Nginx Linux 下面创建为系统服务脚本 | |
#!/bin/sh -e | |
### BEGIN INIT INFO | |
# Provides: nginx | |
# Required-Start: $all | |
# Required-Stop: $all | |
# Default-Start: 2 3 4 5 | |
# Default-Stop: 0 1 6 | |
# Short-Description: starts the nginx web server |
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
# Deploy Rails on Ubuntu with shell | |
#!/bin/sh | |
echo "=== YTRIPTHIRD UBUNTU INSTALL ===" | |
cd /tmp | |
# Ruby | |
echo "=== Install Ruby library..." | |
sudo apt-get install g++ ruby1.8 rubygems rake irb ruby1.8-dev build-essential libopenssl-ruby libssl-dev imagemagick rdtool | |
echo "=== Ruby library install done." |
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
class String | |
def remove_html_tags() | |
self.gsub(/<.+?>/, "") | |
end | |
# clear unsafe char with url slug | |
def safe_slug(spliter = '-') | |
@slug = self | |
if @slug.blank? | |
Guid.new |
OlderNewer