Skip to content

Instantly share code, notes, and snippets.

@woodie
woodie / .SETUP
Created November 23, 2010 08:23
gem install dubious
$ sudo jruby -S gem install dubious
Successfully installed bitescript-0.0.7
Successfully installed mirah-0.0.4-java
Successfully installed thor-0.13.8
Successfully installed activesupport-3.0.3
Successfully installed i18n-0.4.2
Successfully installed appengine-sdk-1.3.8
Successfully installed dubious-0.0.1-java
7 gems installed
@telent
telent / gist:704274
Created November 17, 2010 22:46
Some random notes on Mirah, mostly culled from the mailing list

Stuff in Ruby that is/isn't supported, or is different

=begin / =end

Rib Rdb writes: "The new parser doesn't support this". Use single line comments instead

The object model

The ruby object model is not the same as the java object model. The

@hakunin
hakunin / show_exception.mirah
Created November 3, 2010 08:48
Exception pretty printing similar to Rack::ShowException
class ShowException
def initialize
@html = '<html>
<style>
body {
font-family:arial;
margin:0;
padding:0;
}
#! /usr/bin/env ruby
# usage: gemdir gemname
#
# eg: cd `gemdir yajl`
#
require 'rubygems'
arg = ARGV.first
require 'fiber'
module Eigenclass
def eigenclass
class << self; self end
end
module_function :eigenclass
public :eigenclass
end

#Dr StrangeCode or "How I Learned to Stop Worrying and Love the Rails 3.0 Upgrade"* I recently upgraded one of my Rails applications from 2.3.5 to 3.0.0 (and from ruby 1.8.7 to 1.9.2). I took a series of notes of all the problems and issues I ran into. ##Ruby 1.8.7 to 1.9.2 upgrade

  • FasterCSV is part of 1.9.2, but not 1.8.7. If you want to maintain compatibility with both, then keep using FasterCSV.
  • ftools no longer exists in ruby 1.9.2. Was using it in a require. I just used fileutils instead.
  • I had a bunch of old-style case/when statements that no longer work in 1.9.
    hours = case r[6..6]
        when "M": [0,11]
 when "A": [12, 18]
@woodie
woodie / Gemfile .rb
Created September 18, 2010 21:42
Rails 3.0 on GAE
# Gemfile for Rails 3.0
source 'http://rubygems.org'
gem 'rails', '3.0.0'
gem 'activerecord-nulldb-adapter' # for now
gem 'jruby-openssl' # for cookie sessions
gem 'appengine-rack' # jruby-jars & jruby-rack
@woodie
woodie / gist:569719
Created September 8, 2010 06:13
dubious app
$ jgem install dubious-0.0.0-java.gem
$ dubious init hubouhe
create hubouhe
create hubouhe/Rakefile
create hubouhe/app/controllers/application_controller.mirah
create hubouhe/public/404.html
create hubouhe/public/422.html
create hubouhe/public/500.html
create hubouhe/public/favicon.ico
@dahlia
dahlia / lisp.rb
Created September 2, 2010 07:52
30 minutes Lisp in Ruby
# 30 minutes Lisp in Ruby
# Hong Minhee <http://dahlia.kr/>
#
# This Lisp implementation does not provide a s-expression reader.
# Instead, it uses Ruby syntax like following code:
#
# [:def, :factorial,
# [:lambda, [:n],
# [:if, [:"=", :n, 1],
# 1,
# In here, we monkey-patch Net::SSH. Beware, there be dragons.
# Net::SSH can add hosts to the known_hosts file, but can't remove
module Net; module SSH
class KnownHosts
# Looks in all user known host files (see KnownHosts.hostfiles) and tries to
# remove an entry for the given host and key to the first file it is able to.
def self.remove(host, options={})
hostfiles(options, :user).each do |file|
begin