Skip to content

Instantly share code, notes, and snippets.

View dynamical.rb
class Dynamical
define_method :works_fine do |&block|
5.times { |n| block.call(n) }
end
def self.defn name
define_method name do |&block|
5.times { |n| yield n }
end
end
View gist:8227106
$ rake gem
rm -rf build/bootstrap
mkdir -p build/bootstrap
Compiling 10 source files to /Users/nick/hacking/mirah_hacking/mirah/build/bootstrap
/Users/nick/hacking/mirah_hacking/mirah/src/org/mirah/IsolatedResourceLoader.java
/Users/nick/hacking/mirah_hacking/mirah/src/org/mirah/MirahClassLoader.java
/Users/nick/hacking/mirah_hacking/mirah/src/org/mirah/jvm/compiler/Cleaned.java
/Users/nick/hacking/mirah_hacking/mirah/src/org/mirah/jvm/types/Flags.java
/Users/nick/hacking/mirah_hacking/mirah/src/org/mirah/jvm/types/MemberAccess.java
/Users/nick/hacking/mirah_hacking/mirah/src/org/mirah/jvm/types/MemberKind.java
View compare_branches.bash
function silencing_stderr() {
$* 2>/dev/null
}
function branch_names() {
git br | awk '{print $1}' | grep -v '*' | xargs
}
function most_recent_commit() {
git log . | grep "Date: " | cut -c 9- | head -1
View compare_branches.bash
function silencing_stderr() {
$* 2>/dev/null
}
function branch_names() {
git br | awk '{print $1}' | grep -v '*' | xargs
}
for branch_name in $(branch_names)
do
@baroquebobcat
baroquebobcat / polluted.rb
Created Nov 8, 2012 — forked from ahoward/polluted.rb
ruby libs have *got* to stop doing this...
View polluted.rb
libs = ARGV.size == 0 ? all_gems : ARGV
list =
libs.
forkify(16){|lib| puts "#{ lib }..."; [lib, polluted_by(lib)]}.
sort_by{|pair| pair.last}
list.each do |lib, polluted|
puts "polluted_by('#{ lib }') #=> #{ polluted }"
View quiz-1.md
So you think you wanna be a web developer...

Fork this, update your copy with answers.

They don't need to be precise - pseudo-code is fine in most cases.

Some questions don't have correct answers.

@baroquebobcat
baroquebobcat / Hash.from_xml_using_Nokogiri.rb
Created Jan 12, 2012 — forked from dimus/Hash.from_xml using Nokogiri
Adding Hash.from_xml method using Nokogiri
View Hash.from_xml_using_Nokogiri.rb
# USAGE: Hash.from_xml:(YOUR_XML_STRING)
#
# - fixes handling of <text> elements
# - prepends namespaces on keys where used including both elements & attributes
# - uses strings instead of symbols to prevent consumption of the symbol table
require 'nokogiri'
# modified from http://stackoverflow.com/questions/1230741/convert-a-nokogiri-document-to-a-ruby-hash/1231297#1231297
class Nokogiri::XML::Node
def namespaced_name
View output.txt
~/hacking/fresh_mirah]$ bundle exec mirahc -V test.mirah
Parsing...
test.mirah
Inferring types...
* [Mirah::Typer] New type defined: 'Test' < ''
* [Mirah::Typer] Learned local type under #<Mirah::AST::StaticScope:0x39e2ee3f> : test = Type(boolean)
* [AST] [RequiredArgument] RequiredArgument(test) resolved!
...
View map.mirah
6: Cannot find instance method set(int, int) on java.util.List
Mirah::InternalCompilerError: Cannot find instance method set(int, int) on java.util.List
infer at ~/hacking/fresh_mirah/lib/mirah/typer/simple.rb:280
infer at ~/hacking/fresh_mirah/lib/mirah/ast/structure.rb:34
each at org/jruby/RubyArray.java:1603
infer at ~/hacking/fresh_mirah/lib/mirah/ast/structure.rb:33
infer at ~/hacking/fresh_mirah/lib/mirah/typer/simple.rb:275
infer at ~/hacking/fresh_mirah/lib/mirah/ast/flow.rb:125
collect at org/jruby/RubyArray.java:2336
View kingdom-assignmentbin.rb
require 'rubygems'
require 'kingdom-assignment'
if CSV.const_defined? :Reader
# require 'fastercsv'
INSTALLED_CSV = FasterCSV
else
INSTALLED_CSV = CSV
end
You can’t perform that action at this time.