Skip to content

Instantly share code, notes, and snippets.

View corntrace's full-sized avatar

Kevin corntrace

  • Shanghai, China
View GitHub Profile
@corntrace
corntrace / README
Created July 9, 2011 14:44 — forked from andersonsp/README
Rails 3 custom form builder implementing a simple color picker based on JQuery and CaryonBox plugin
INSTALLATION
the rails application must have support for JQuery
get JQuery.Crayonbox.js at http://gelform.com/crayonbox-jquery-plugin/
add the plugin JQuery.Crayonbox.js to /public/javascript folder
add the crayonbox css to /public/stylesheets folder
add color_picker_form_builder.rb to the /lib folder
add to the view or layout file:
@corntrace
corntrace / ruby-1.9-tips.rb
Created May 15, 2011 04:12 — forked from lporras/ruby-1.9-tips.rb
Ruby 1.9 Tips
def tip(msg); puts; puts msg; puts "-"*100; end
#
# 30 Ruby 1.9 Tips, Tricks & Features:
# http://www.igvita.com/2011/02/03/new-ruby-19-features-tips-tricks/
#
tip "Upgrading to Ruby 1.9 is simple: rvm install 1.9.2 && rvm --default 1.9.2"
tip "Ruby 1.9 supports named captures in regular expressions!"
def tip(msg); puts; puts msg; puts "-"*100; end
#
# 30 Ruby 1.9 Tips, Tricks & Features:
# http://www.igvita.com/2011/02/03/new-ruby-19-features-tips-tricks/
#
tip "Upgrading to Ruby 1.9 is simple: rvm install 1.9.2 && rvm --default 1.9.2"
tip "Ruby 1.9 supports named captures in regular expressions!"
var mozmill = {}; Components.utils.import('resource://mozmill/modules/mozmill.js', mozmill);
var elementslib = {}; Components.utils.import('resource://mozmill/modules/elementslib.js', elementslib);
var testFoo = function(){
var controller = mozmill.getMail3PaneController();
var e =
new elementslib.XPath(controller.window.frames[0].document, "/*[name()='page' and namespace-uri()='http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul']/*[name()='grid' and namespace-uri()='http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul'][1]/*[name()='rows' and namespace-uri()='http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul'][1]/*[name()='row' and namespace-uri()='http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul'][16]/*[name()='hbox' and namespace-uri()='http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul'][1]/*[name()='label' and namespace-uri()='http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul'][1]");
controller.click(e);
# Cleaning up and extending the Gemfile
remove_file 'Gemfile'
create_file 'Gemfile', <<-GEMFILE
source 'http://rubygems.org'
gem 'rails', '3.0.0'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'sqlite3-ruby', :require => 'sqlite3'
module Embedding
def embeds_many(association_id, options = {})
has_many association_id, options.merge(:dependent => :destroy)
accepts_nested_attributes_for association_id, :allow_destroy => true
end
def embeds_one(association_id, options = {})
has_one association_id, options.merge(:dependent => :destroy)
accepts_nested_attributes_for association_id, :allow_destroy => true
end
@corntrace
corntrace / lisp.rb
Created September 2, 2010 10:41 — forked from dahlia/lisp.rb
0 minutes Lisp in Ruby
# 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,

== Scala 2.7.5

scalac shapes.scala shapes-actor.scala
scala shapes-actor-script.scala // it works

== Scala 2.8.0

scalac shapes.scala shapes-actor.scala
scala shapes-actor-script.scala // NOT works

scala -cp . shapes-actor-script.scala // NOT works

class Someone
class << self
def say
$stdin.each_line do |line|
$stdout << "someone says '#{line}' @ #{Time.now}"
end
end
end
end
@corntrace
corntrace / dewip.sh
Created December 23, 2009 06:43 — forked from timriley/dewip.sh
cucumber tags filters
alias dewip="sed -E -i '' -e '/^[[:blank:]]*@wip$/d;s/,[[:blank:]]*@wip//g;s/@wip,[[:blank:]]*//g' features/**/*.feature"