Skip to content

Instantly share code, notes, and snippets.

View gist:3148416
++ pwd
+ PWD=/var/lib/go-agent/pipelines/profiles/tmp/rpmbuild/BUILD/profiles
+ env -i GEM_HOME=/var/lib/go-agent/pipelines/profiles/tmp/rpmbuild/BUILD/profiles/vendor/bundle/ruby/1.9.1 GEM_PATH=/var/lib/go-agent/pipelines/profiles/tmp/rpmbuild/BUILD/profiles/vendor/bundle/ruby/1.9.1 gem install bundler --no-rdoc --no-ri
ERROR: Could not find a valid gem 'bundler' (>= 0) in any repository
ERROR: Possible alternatives: bundler
error: Bad exit status from /var/tmp/rpm-tmp.23649 (%build)
Bad exit status from /var/tmp/rpm-tmp.23649 (%build)
View headless-jasmine
tw@hernan-cortes:~$ [master*] time rake jasmine:headless
....................................
PASS: 36 tests, 0 failures, 0.175 secs.
real 0m4.303s
user 0m2.660s
sys 0m0.900s
View gist:1169573
require 'rubygems'
require 'rspec'
module EventLogging
def self.included(base)
base.extend ClassMethods
end
module ClassMethods
@cv
cv / graceful_degradation_helper.rb
Created Jun 29, 2011
a graceful degradation helper for dangerous operations in the template
View graceful_degradation_helper.rb
module GracefulDegradationHelper
# doctest:
#
# >> gracefully { tag(:hello) }
# => "<hello />"
#
# >> gracefully { raise "oops" }
# => ""
#
View gist:855293
namespace :foo do
task :a do
exec "echo A"
end
task :b => [:'foo:a'] do
exec "echo B"
end
View gist:723768

Pimp

The following code shows the Pimp language output for some specific input, showing some of the benefits from using such a nice language.

Defining something

 an Account:owner, amount

is positive?

View gist:60963
iik> java:util:ArrayList new
*** - java.lang.IllegalArgumentException: object is not an instance of declaring class (Condition Error JavaException)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:585)
ioke.lang.JavaMethodJavaMethod.activate(JavaMethodJavaMethod.java:45)
ioke.lang.JavaMethodJavaMethod.activate(JavaMethodJavaMethod.java:38)
ioke.lang.IokeObject.activate(IokeObject.java:932)
View gist:58391
Refactoring = Origin mimic do(
ifToUnless = method("Returns a message with all the if statements converted to unless statements", message,
unless(message kind == "Message", return)
message each(i,
Refactoring ifToUnless(i next)
i arguments each(j,
Refactoring ifToUnless(j)
)
)
View gist:56936
use("ispec")
describe("Java",
it("should create new methods on an object",
Java compileMethod(Text, :disemvowel, #[{
return runtime.newText(Text.getText(on).replaceAll("a|e|i|o|u|A|E|I|O|U", ""));
}])
"hello, world!" disemvowel should == "hll, wrld!"