Skip to content

Instantly share code, notes, and snippets.

# Evil Exponential Backoff
#
# fog has this wait_for method that calls #to_f on its interval each iteration
# to determine how to sleep. https://github.com/fog/fog/blob/master/lib/fog/core/wait_for.rb
#
# This object will generate the 2**n series. Each time you call to_f, it'll give you another one.
#
iter = (0..(1/0.0)).each
def iter.to_f
// Generated from test_shatner.mirah
package org.shatner;
public class SomeAppWithAnUnmacroedView extends org.shatner.ShatnerBase {
public SomeAppWithAnUnmacroedView() {
org.shatner.SomeAppWithAnUnmacroedView.__xform_tmp_5 $binding = new org.shatner.SomeAppWithAnUnmacroedView.__xform_tmp_5();
java.lang.String temp$1 = null;
{
temp$1 = "/";
}
org.shatner.SomeAppWithAnUnmacroedView.__xform_tmp_6 temp$2 = new org.shatner.SomeAppWithAnUnmacroedView.__xform_tmp_6($binding);
def foo r:Runnable
#...
end
foo do # Block 1.
foo do # Block 2.
puts 1
end
end
/Users/nick/hacking/mirah_model/test/model_test.mirah:31: Bad unquote value
property 'date', Date
^^^^^^^^^^^^^^^^^^^^^^^
rake aborted!
Bad unquote value
macro def add_puts_to_init str_node
puts_tree = quote do
puts `str_node`
end
init_method = caller.containing_class.method :initialize
unless init_method
caller.containing_class.body << quote do
def initialize
end
@baroquebobcat
baroquebobcat / gist:1670973
Created January 24, 2012 16:28
installing macruby 0.9 installs 0.10
$ rvm install --trace macruby-0.9
--trace macruby-0.9
rvm 1.10.2 by Wayne E. Seguin <wayneeseguin@gmail.com>, Michal Papis <mpapis@gmail.com> [https://rvm.beginrescueend.com/]
+ /scripts/cli : __rvm_parse_args() 738 > [[ -n '' ]]
+ /scripts/cli : __rvm_parse_args() 739 > export 'PS4=+ ${BASH_SOURCE##${rvm_path:-}} : ${FUNCNAME[0]:+${FUNCNAME[0]}()} ${LINENO} > '
+ /scripts/cli : __rvm_parse_args() 739 > PS4='+ ${BASH_SOURCE##${rvm_path:-}} : ${FUNCNAME[0]:+${FUNCNAME[0]}()} ${LINENO} > '
+ /scripts/cli : __rvm_parse_args() 770 > [[ -z install ]]
+ /scripts/cli : __rvm_parse_args() 772 > [[ 0 -eq 1 ]]
@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
@baroquebobcat
baroquebobcat / db_col
Created January 10, 2012 03:29
get hashes working w/ association find_or_create in rails 2.3.x > 2.3.8
--- !map:HashWithIndifferentAccess
body: other test comment body
type: test
# Snippet to wrap tests with ActiveRecord db transactions outside Rails.
#
# references:
# https://github.com/rails/rails/blob/master/railties/lib/rails/test_help.rb#L27
# https://github.com/rails/rails/blob/master/activerecord/lib/active_record/fixtures.rb#L704
#
# TestFixtures checks whether configurations is blank
# to determine whether to use transactions/fixtures or not.
# which is why we need to set it to something.
ActiveRecord::Base.configurations= {test: {
require 'rubygems'
require 'em-http-request'
# Monkey-patched Gzip Decoder to handle
# Gzip streams.
#
# This takes advantage of the fact that
# Zlib::GzipReader takes an IO object &
# reads from it as it decompresses.
#