Skip to content

Instantly share code, notes, and snippets.

#!/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)
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
#
# 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
<!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">
@IceskYsl
IceskYsl / wp-xml-import.rb
Created April 26, 2012 02:39 — forked from zanshin/wp-xml-import.rb
WordPress to Markdown ruby script. Parses existing WP categories into discreet list of categories. Also identifies link-style postings and sets a YAML attribute to identify those entries. Finally forces all content to be UTF-8.
require 'fileutils'
require 'date'
require 'yaml'
require 'rexml/document'
include REXML
doc = Document.new File.new(ARGV[0])
FileUtils.mkdir_p "_posts"
# 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
@IceskYsl
IceskYsl / sphinx.yml
Created September 20, 2011 10:07 — forked from dchentech/sphinx.yml
sphinx in chinese setup
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 # 支持通配符匹配
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!