Skip to content

Instantly share code, notes, and snippets.

@baroquebobcat
baroquebobcat / Hash.from_xml_using_Nokogiri.rb
Created January 12, 2012 22:56 — forked from dimus/Hash.from_xml using Nokogiri
Adding Hash.from_xml method using Nokogiri
# 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
function silencing_stderr() {
$* 2>/dev/null
}
function branch_names() {
git br | awk '{print $1}' | grep -v '*' | xargs
}
for branch_name in $(branch_names)
do
$ 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
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
@baroquebobcat
baroquebobcat / polluted.rb
Created November 8, 2012 17:38 — forked from ahoward/polluted.rb
ruby libs have *got* to stop doing this...
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 }"
@baroquebobcat
baroquebobcat / quiz-1.md
Created September 27, 2012 23:44 — forked from ahoward/quiz-1.md
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 / output.txt
Created October 30, 2011 19:43 — forked from igrigorik/output.txt
test.mirah
~/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!
...
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
require 'rubygems'
require 'kingdom-assignment'
if CSV.const_defined? :Reader
# require 'fastercsv'
INSTALLED_CSV = FasterCSV
else
INSTALLED_CSV = CSV
end
/*
with selected true as a param.
Element.select.
option("1", "one").
option("2", "two", true).
option("3", "three").to_s
produces: