Skip to content

Instantly share code, notes, and snippets.

View zliang-min's full-sized avatar

Gimi Liang zliang-min

View GitHub Profile
if
[ -f "$rvm_path/scripts/rvm" ]
then
__env="$( "$rvm_path/bin/rvm" . do env --path )"
if
[ -n "$__env" ] &&
[ -s "$__env" ]
then
source "$__env"
fi
@zliang-min
zliang-min / parse-json.rb
Created December 21, 2011 17:23 — forked from mislav/stupid-json.rb
Stupid simple JSON parser
require 'strscan'
require 'forwardable'
# Stupid JSON parser. Only handles well-formed JSON.
# Otherwise, it may go into an endless loop.
class Parser
WSP = /\s+/
OBJ = /[{\[]/
NUM = /-?\d+(\.\d+)?([eE][+-]?\d+)?/
BOL = /(?:true|false)\b/
@zliang-min
zliang-min / README.markdown
Created November 7, 2011 09:57 — forked from weakish/README.markdown
#Solarized themes (dark and light) for #roxterm.

Roxterm solarized theme

Description

Solarized themes (dark and light) for roxterm.

@zliang-min
zliang-min / fiber_race.rb
Created November 3, 2011 02:56 — forked from raggi/fiber_race.rb
An example race condition using fibers
# Author:: Mohammad A. Ali (mailto:[email protected])
# Copyright:: Copyright (c) 2008 eSpace, Inc.
# License:: Distributes under the same terms as Ruby
require 'fiber'
class Fiber
#Attribute Reference--Returns the value of a fiber-local variable, using
#either a symbol or a string name. If the specified variable does not exist,
require 'dl'
require 'fiddle'
module FFI
module Library
def ffi_lib *libs
libs.each { |lib| DL.dlopen lib }
end
def attach_function name, arg_types, return_type
/*
* Property prefix hacks
*/
/* IE6 only - any combination of these characters */
_ - £ ¬ ¦
/* IE6/7 only - any combination of these characters */
@zliang-min
zliang-min / annotated.js
Created May 18, 2011 06:47 — forked from madrobby/annotated.js
Unit testing
function(
a, // a object holding test functions
b, // a logging function, taking multiple arguments
c, // placeholder
d, // placeholder
e, // placeholder
f // placeholder
){
c = d = e = 0; // initialize asserts, failures and exception counts to 0
for ( // iterate
@zliang-min
zliang-min / LICENSE.txt
Created May 16, 2011 10:03 — forked from jed/LICENSE.txt
calculate # of ms/seconds/minutes/hours/days in the past
Copyright (c) 2011 Jed Schmidt, http://jed.is
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
@zliang-min
zliang-min / rails_3_1_beta_1_changes.md
Created May 6, 2011 02:23 — forked from ryanb/rails_3_1_rc4_changes.md
The Changelogs for Rails 3.1 Beta 1

Railties 3.1 Beta 1

  • The -j option of the application generator accepts an arbitrary string. If passed "foo", the gem "foo-rails" is added to the Gemfile, and the application JavaScript manifest requires "foo" and "foo_ujs". As of this writing "prototype-rails" and "jquery-rails" exist and provide those files via the asset pipeline. Default is "jquery". [fxn]

  • jQuery is no longer vendored, it is provided from now on by the jquery-rails gem. [fxn]

  • Prototype and Scriptaculous are no longer vendored, they are provided from now on by the prototype-rails gem. [fxn]

  • The scaffold controller will now produce SCSS file if Sass is available [Prem Sichanugrist]

module Test
module Unit
TestCase = RSpec::Core::ExampleGroup
end
end
class Test::Unit::TestCase
def self.inherited(host)
host.set_it_up host.name.gsub(/(Spec|Test)/,'')
def host.method_added(name)