Skip to content

Instantly share code, notes, and snippets.

🏠
Working from home

Lishi He ikbear

🏠
Working from home
Block or report user

Report or block ikbear

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View chinesedecimal.rb
$KCODE = 'u'
# Goal: 小写金额转换为大写金额
# Limit: 金额整数位支持到亿位,小数点后支持两位并且不支持四舍五入
class ChineseFee
attr_reader :chn_numbers, :chn_units, :chn_decimals
def initialize
@chn_numbers = %w(零 壹 贰 叁 肆 伍 陆 柒 捌 玖)
@chn_units = %w(元 拾 佰 仟 万 拾万 佰万 仟万 亿)
View rails_test_box_prepackaged.sh
# 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
View rails_test_box_prepackaged.sh
# 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
View gist:480391
# 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.
View taobao_api.rb
#此DEMO的功能:查询手机类的淘客商品
require 'digest/md5'
require 'net/http'
require 'open-uri'
require 'iconv'
#获得当前时间
t = Time.new();
#组装参数
View 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,
View vc6-bug.cpp
#include <iostream>
using namespace std;
void fun(int i)
{
static int n = i ;
int *p = &n ;
cout << n << endl ;
++n ;
--p ;
*p = 0 ;
View gist:769115
#!/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 Jan 8, 2011
简单的备份mysql数据库的脚本,完全自用,需要的可以参考一下,但绝不能照搬
View mysql.sh
#!/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 Jan 8, 2011
在服务器上添加一个网站,服务器为nginx,本脚本功能为添加网站的配置文件
View server.sh
#!/bin/bash
# Usage:
# ./server.sh domain.com(without www)
# ./server.sh helishi.net
if [ "$*" = "" ]
then
exit;
fi
You can’t perform that action at this time.