Skip to content

Instantly share code, notes, and snippets.

$KCODE = 'u'
# Goal: 小写金额转换为大写金额
# Limit: 金额整数位支持到亿位,小数点后支持两位并且不支持四舍五入
class ChineseFee
attr_reader :chn_numbers, :chn_units, :chn_decimals
def initialize
@chn_numbers = %w(零 壹 贰 叁 肆 伍 陆 柒 捌 玖)
@chn_units = %w(元 拾 佰 仟 万 拾万 佰万 仟万 亿)
# These commands will help you setup the Rails test environment without problems
#
# MAKE SURE YOU HAVE VIRTUAL BOX INSTALLED http://www.virtualbox.org/wiki/Downloads
#
# Copy paste all of following commands in your normal terminal and the following things will happen:
# - rails_test_box dir is created
# - rails master branch is checkout in the dir rails
# - A Gemfile is created and all the gems to run the virtualbox are installed using bundler
# - The rails vagrant box is downloaded and added to your vagrant boxes
# - A Vagrantfile is created for vagrant
# These commands will help you setup the Rails test environment without problems
#
# MAKE SURE YOU HAVE VIRTUAL BOX INSTALLED http://www.virtualbox.org/wiki/Downloads
#
# Copy paste all of following commands in your normal terminal and the following things will happen:
# - rails_test_box dir is created
# - rails master branch is checkout in the dir rails
# - A Gemfile is created and all the gems to run the virtualbox are installed using bundler
# - The rails vagrant box is downloaded and added to your vagrant boxes
# - A Vagrantfile is created for vagrant
# Video: http://rubyhoedown2008.confreaks.com/08-chris-wanstrath-keynote.html
Hi everyone, I'm Chris Wanstrath.
When Jeremy asked me to come talk, I said yes. Hell yes. Immediately. But
then I took a few moments and thought, Wait, why? Why me? What am I supposed
to say that's interesting? Something about Ruby, perhaps. Maybe the
future of it. The future of something, at least. That sounds
keynote-y.
#此DEMO的功能:查询手机类的淘客商品
require 'digest/md5'
require 'net/http'
require 'open-uri'
require 'iconv'
#获得当前时间
t = Time.new();
#组装参数
@ikbear
ikbear / lisp.rb
Created September 2, 2010 09:27 — forked from dahlia/lisp.rb
# 30 minutes Lisp in Ruby
# Hong MinHee <http://dahlia.kr/>
#
# This Lisp implementation does not provide a s-expression reader.
# Instead, it uses Ruby syntax like following code:
#
# [:def, :factorial,
# [:lambda, [:n],
# [:if, [:"=", :n, 1],
# 1,
@ikbear
ikbear / vc6-bug.cpp
Created December 14, 2010 15:04
VC 6.0 Bug
#include <iostream>
using namespace std;
void fun(int i)
{
static int n = i ;
int *p = &n ;
cout << n << endl ;
++n ;
--p ;
*p = 0 ;
@ikbear
ikbear / gist:769115
Created January 7, 2011 04:40 — forked from pch/gist:766349
#!/bin/bash
BACKUP_DIR='/home/rsync/mysql_backup'
MHOST='localhost'
MUSER='root'
MPASS='yourpass'
NOW=$(date +"%Y-%m-%d_%H")
@ikbear
ikbear / mysql.sh
Created January 8, 2011 13:54
简单的备份mysql数据库的脚本,完全自用,需要的可以参考一下,但绝不能照搬
#!/bin/sh
suffix=$(date +%y%m%d)
password="pass"
user="user"
mkdir db
cd db
mysqldump -u$user -p$password blog > blog.$suffix.sql
mysqldump -u$user -p$password en > en.$suffix.sql
@ikbear
ikbear / server.sh
Created January 8, 2011 13:57
在服务器上添加一个网站,服务器为nginx,本脚本功能为添加网站的配置文件
#!/bin/bash
# Usage:
# ./server.sh domain.com(without www)
# ./server.sh helishi.net
if [ "$*" = "" ]
then
exit;
fi