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
CmdUtils.CreateCommand({ | |
name: "dict", | |
icon: "http://dict.cn/favicon.ico", | |
homepage: "http://dict.cn/", | |
author: { name: "Kai Chen", email: "[email protected]"}, | |
license: "GPL", | |
description: "Search word in dict.cn", | |
help: "dict word_wanted_to_search", | |
takes: {"input": noun_arb_text}, | |
preview: function( pblock, input ) { |
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
namespace :db do | |
namespace :test do | |
desc "Create the test DB and do migrations automatonlly" | |
task :prepare do | |
Merb.start_environment(:environment => 'test', :adapter => 'runner') | |
config = Merb::Orms::DataMapper.config | |
puts "Creating database '#{config[:database]}'" | |
case config[:adapter] | |
when 'postgres' | |
`createdb -U #{config[:username]} #{config[:database]}` |
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/ruby -w | |
# File: ryaourt | |
# | |
# A utility script let you can install rubygems as archlinux's aur package manager yaourt. | |
# | |
# Usge: | |
# | |
# $ ryaourt gem_you_want_to_query | |
# |
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 | |
require 'rubygems' | |
require 'nokogiri' | |
if ARGV.empty? || ARGV.size != 3 | |
#display the usage | |
return | |
end | |
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
# base.rb | |
# rails2p3 app template | |
# from Kai Chen | |
# Delete unnecessary files | |
run "rm README" | |
run "rm public/index.html" | |
run "rm public/favicon.ico" | |
run "rm public/robots.txt" | |
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: http://www.javaeye.com/topic/456482?page=1 | |
#include <stdio.h> | |
#include <string.h> | |
#include <sys/types.h> | |
#include <dirent.h> | |
#include <sys/stat.h> | |
#include <time.h> | |
#include <stdlib.h> |
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
# Crack bug | |
# Crack use YAML paser to parse json data, and YAML parser cloud not parse colon symbol well. | |
# brianmario's fork would be better, http://github.com/brianmario/crack | |
# Fail | |
should "should be able to parse a JSON includes colon" do | |
data = %q![{"foo":{"bar":"2009-08-30 : 22:49"}}]! | |
lambda { | |
Crack::JSON.parse(data) | |
}.should_not raise_error(Crack::ParseError) |
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 | |
require 'ftools' | |
def get_sub_dirs_in_dir(dir) | |
`find #{dir} -type d`.split("\n") - [dir] | |
end | |
def get_sub_dirs_in_current_dir | |
get_sub_dirs_in_dir Dir.pwd | |
end |
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
#compdef gem gem1.9 | |
gem_general_flags=("(-h --help)"{-h,--help}"[Get help on this command]" | |
"(-V --verbose)"{-V,--verbose}"[Set the verbose level of output]" | |
"(-q --quiet)"{-q,--quiet}"[Silence commands]" | |
"--config-file[Use this config file instead of default]:file:_files" | |
"--backtrace[Show stack backtrace on errors]" | |
"--debug[Turn on Ruby debugging]" | |
$nul_arg | |
) |
OlderNewer