This file contains 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 | |
# Usage: | |
# ruby plugin_to_gem.rb my_plugin_directory | |
require 'fileutils' | |
@plugin_dir = ARGV[0] | |
@plugin_name = ARGV[0] | |
def rakefile_content | |
description = 'TODO' |
This file contains 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 | |
# Written by Kieran P | |
# http://github.com/KieranP | |
# http://twitter.com/k776 | |
# http://k776.tumblr.com | |
# | |
# Feel free to fork and modify. | |
# If you do, send me a message on | |
# Github details changes and I'll |
This file contains 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
from google.appengine.api import urlfetch | |
from google.appengine.api import xmpp | |
from google.appengine.ext import db | |
from google.appengine.ext import webapp | |
from google.appengine.ext.webapp.util import run_wsgi_app | |
from google.appengine.ext.webapp import xmpp_handlers | |
import base64 | |
import feedparser | |
import logging |
This file contains 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
############## commands ################# | |
run "touch tmp/.gitignore log/.gitignore vendor/.gitignore" | |
run %{find . -type d -empty | grep -v "vendor" | grep -v ".git" | grep -v "tmp" | xargs -I xxx touch xxx/.gitignore} | |
run "rm .gitignore" | |
file '.gitignore', <<-ENDEND | |
.DS_Store | |
log/*.log | |
tmp/**/* | |
config/database.yml |
This file contains 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
$KCODE = 'u' | |
# Goal: 小写金额转换为大写金额 | |
# Limit: 金额整数位支持到亿位,小数点后支持两位并且不支持四舍五入 | |
class ChineseFee | |
attr_reader :chn_numbers, :chn_units, :chn_decimals | |
def initialize | |
@chn_numbers = %w(零 壹 贰 叁 肆 伍 陆 柒 捌 玖) | |
@chn_units = %w(元 拾 佰 仟 万 拾万 佰万 仟万 亿) |
This file contains 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 "test/unit" | |
require "stringio" | |
module Test::Unit | |
# Used to fix a minor minitest/unit incompatibility in flexmock | |
# AssertionFailedError = Class.new(StandardError) | |
class TestCase | |
This file contains 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
# inspiration | |
# http://github.com/jnstq/rails-nginx-passenger-ubuntu | |
# sudo this sudo that bollocks | |
sudo -i | |
# system-related stuff | |
apt-get install htop strace sysstat | |
dpkg-reconfigure sysstat | |
apt-get install ntp |
This file contains 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
This example shows how to setup an environment running Rails 3 beta 3 under 1.9.2-head with a 'rails3' gem set. | |
∴ rvm update --head | |
# ((Open a new shell)) or do 'rvm reload' | |
# If you do not already have the ruby interpreter installed, install it: | |
∴ rvm install 1.9.2-head | |
# Switch to 1.9.2-head and gemset rails3, create if it doesn't exist. | |
∴ rvm --create use 1.9.2-head@rails3 |
This file contains 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
user app; | |
worker_processes 2; | |
error_log /home/app/logs/nginx.error.log info; | |
events { | |
worker_connections 1024; | |
} | |
This file contains 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 SvgController < ApplicationController | |
require 'active_support/secure_random' | |
def create | |
# create an SVG image | |
# based on Highcharts index.php | |
batik_path = Rails.root.to_s() + '/vendor/batik/batik-rasterizer.jar' | |
svg = params[:svg] | |
filename = params[:filename].blank? ? "chart" : params[:filename] |
OlderNewer