- Stabby / Lambda
- Block
- Nested Methods
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class A(object): | |
def __getattr__(s,i): | |
raise Exception('wth') | |
def raises(self): | |
"aoeu".nonexistent | |
@property | |
def yep(self): | |
self.raises() | |
A().yep |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export NOTIFY_TIME=10 | |
function timer_start { | |
previous_command=$this_command | |
if [ "$BASH_COMMAND" != "timer_stop" ] | |
then | |
this_command=$BASH_COMMAND | |
fi | |
timer=${timer:-$SECONDS} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function silencing_stderr() { | |
$* 2>/dev/null | |
} | |
function branch_names() { | |
git br | awk '{print $1}' | grep -v '*' | xargs | |
} | |
for branch_name in $(branch_names) | |
do |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.concurrent.ArrayBlockingQueue | |
import java.util.concurrent.ConcurrentHashMap | |
import java.util.concurrent.atomic.AtomicLong | |
queue_size = 10 | |
queue = ArrayBlockingQueue.new queue_size, true | |
counts = {"A"=> AtomicLong.new, "B" => AtomicLong.new} | |
producerA = Thread.new do | |
while true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mirah 0.1.2 release highlights | |
- improvements to the new mirrors implementation (try it with -T) | |
- improvements to the new backend implementation (try it with -N) | |
- added better casting for methods that return primitives (754cc38f) | |
- =~, include? macros added to String (Thanks altamic) | |
- << operator added to StringBuilder | |
- improved line number recording in new backend | |
- fixed a few macro expansion related bugs | |
- Added Apache 2 license to gem metadata |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# add a curry method to symbol for evil/awesome symbol to proc powers. | |
class Symbol | |
def curry(n=nil) | |
->(*args) { | |
->(obj) {obj.send self, *args} | |
}.curry(n) | |
end | |
def call(*n) | |
curry.(*n) |
NewerOlder