Skip to content

Instantly share code, notes, and snippets.

View corntrace's full-sized avatar

Kevin corntrace

  • Shanghai, China
View GitHub Profile
@corntrace
corntrace / gist:256985
Created December 15, 2009 14:39 — forked from holin/gist:256825
ascii print, useful guesture
puts <<ASCII
/´¯/)
,/¯ /
/ /
/´¯/' '/´¯¯`·¸
/'/ / / /¨¯\\
('( ´ ´ ¯~/' ')
\\ ' /
'' \\ _ ·´
\\ (
@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"
class Someone
class << self
def say
$stdin.each_line do |line|
$stdout << "someone says '#{line}' @ #{Time.now}"
end
end
end
end

== 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

@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,
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
# 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'
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);
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!"
@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!"