Skip to content

Instantly share code, notes, and snippets.

View zliang-min's full-sized avatar

Gimi Liang zliang-min

View GitHub Profile
def sleep_sort(a)
result = []
a.map { |e| Thread.new { sleep e; result << e } }.each { |t| t.join }
result
end
puts sleep_sort([7, 5, 8, 6, 4, 9, 2, 3, 1])
/*
* 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)
Some brief instructions on how to use Sprocket 2 in Rails to get CoffeeScript
powered JS and SASS powered CSS with YUI compression all via the magic of rack.
Ignore the number prefixes on each file. This is just to ensure proper order in the Gist.
@zliang-min
zliang-min / sinatra.md
Created March 23, 2011 06:15
Things about sinatra.

Sinatra类的继承

(这里把sinatra中间件和sinatra应用统称为sinatra类)当B继承A时:

  • B在运行filter的阶段,会先运行自己的filters,然后运行A的filters

  • 同理,B在运行routes时,也会运行A的routes(前提是,B没有找到匹配的route)

@zliang-min
zliang-min / play_with_neo4j_rest.rb
Created March 21, 2011 02:31
neo4j rest ruby interface
#!/usr/bin/env ruby
# encoding: utf-8
require 'uri'
require 'rubygems' if RUBY_VERSION < '1.9'
require 'typhoeus'
require 'yajl'
module Neo4j
class REST
@zliang-min
zliang-min / jquery.validation.md
Created March 21, 2011 02:28
Summary of jquery.validation & jquery.validationEngine

jquery.validation

$('form').validate();

options:
  debug: true|false

  // 1. 事件处理
  //   * form提交
  submitHandler: function(form) // 千万不要在这里执行:$(form).submit(),否则死循环

// * 验证失败