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 'open-uri' | |
# == Feed me with: | |
# | |
# Filename:: and I'll give you the file! | |
# URL:: and I'll give you the content! | |
# Any string:: and I'll give you a StringIO! | |
# An integer:: and I'll give you the stream for | |
# the given integer file descriptor! | |
# Any IO:: and I'll give you the same IO! |
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
# 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
require 'fileutils' | |
require 'date' | |
require 'yaml' | |
require 'rexml/document' | |
include REXML | |
doc = Document.new File.new(ARGV[0]) | |
FileUtils.mkdir_p "_posts" |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="UTF-8"> | |
<title> Learning about Bacjbone.js </title> | |
</head> | |
<body> | |
<script src="http://documentcloud.github.com/underscore/underscore-min.js"></script> | |
<script src="http://documentcloud.github.com/backbone/backbone-min.js"></script> | |
<script type="text/javascript"> |
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
# | |
# lib/mongoid/counter_cache.rb | |
# ruby | |
# | |
# Created by Zhang Alex on 2011-06-17. | |
# Copyright 2011 __ZhangHanDong__. All rights reserved. | |
# | |
# =================================== | |
# class Forum | |
# references_many :topics |
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 'net/ftp' | |
CONTENT_SERVER_DOMAIN_NAME = "one-of-the-ftp-server.thought-sauce.com.hk" | |
CONTENT_SERVER_FTP_LOGIN = "saucy-ftp-server-login" | |
CONTENT_SERVER_FTP_PASSWORD = "saucy-ftp-server-password" | |
# LOGIN and LIST available files at default home directory | |
Net::FTP.open(CONTENT_SERVER_DOMAIN_NAME, CONTENT_SERVER_FTP_LOGIN, CONTENT_SERVER_FTP_PASSWORD) do |ftp| | |
files = ftp.list |
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
#!/usr/bin/env ruby | |
# This script will automatically export all the Balsamiq mock files to PDF and bundle them up | |
# into a nice PDF. Just drop this script into the folder containing the mock files and | |
# execute it from the command-line | |
# | |
# For the PDF to work, you'd need to install "prawn" and "prawn-fast-png" gem, otherwise the PDF | |
# creation will be very slow. | |
# | |
# Currently this script has been tested with Balsamiq Next.161 build (05/28/2010) |