Skip to content

Instantly share code, notes, and snippets.

@woodie
woodie / logging.properties
Created January 5, 2010 04:21
Set log level on App Engine for JRuby
# Specify the handlers to create in the root logger
# (all loggers are children of the root logger)
# The following creates two handlers
handlers = java.util.logging.ConsoleHandler, java.util.logging.FileHandler
# Set the default logging level for the root logger
.level = ALL
# Set the default logging level for new ConsoleHandler instances
java.util.logging.ConsoleHandler.level = INFO
package br.com.caelum.teste;
import java.util.Set;
import javax.validation.ConstraintViolation;
import javax.validation.Validation;
import javax.validation.Validator;
import javax.validation.ValidatorFactory;
import org.hibernate.validator.constraints.ScriptAssert;
@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

@toluju
toluju / delicious2google.rb
Created December 17, 2010 01:02
Delicious is shutting down, so here's a script to load the exported delicious bookmarks into Google Bookmarks.
require 'net/http'
require 'uri'
require 'cgi'
text = "<html><head><title>Delicious2Google</title></head><body>" +
"<h1>Upload</h1>" +
"<form action='https://www.google.com/bookmarks/mark?op=upload&zx=#{rand(65535)}' method='POST'>" +
"<input type='submit'/><input type='hidden' id='data'></form>" +
"<textarea id='xml' style='display:none'>\n<bookmarks>"
class Fixnum
def seconds
self
end
def minutes
self * 60
end
def hours
# When anything, including nil, is a valid param and you need
# a clear way to know if a param was set or not, use `None`.
None = Object.new
def foo(a, b=None)
result = [a]
if b != None
result << b
end
@matthewmccullough
matthewmccullough / gitignorechanges.sh
Created January 24, 2011 04:08
This script sets up aliases for ignoring changes to a version controlled file
# Using Git? Want to ignore changes to a noisy (e.g. tool-updated file), yet have to have it exist to satisfy said tool?
# Check it in once to source code control, then ignore all future changes. This option only applies to your local clone.
# Use this by typing 'git ignorechanges MYFILE'
git config --global alias.ignorechanges = update-index --assume-unchanged
# Use this by typing 'git noticechanges MYFILE'
git config --global alias.noticechanges = update-index --no-assume-unchanged
@headius
headius / output
Created May 19, 2011 21:58
Rubinius's actor API under JRuby
~/projects/jruby ➔ jruby rbx_actor_example.rb
Processing: 0
Processing: 4
Processing: 7
Processing: 5
Processing: 8
Processing: 3
Processing: 2
Processing: 6
Processing: 1
@dbrady
dbrady / csv_tests.rb
Created May 26, 2011 06:05
Unit Tests for CSV demonstrating that Enumerable is supported only at the whim of the underlying StringIO seek position
#!/usr/bin/env ruby
unless RUBY_VERSION.start_with? "1.9"
puts "This test file is for Ruby 1.9.x"
exit -1
end
require 'csv'
require 'test/unit'
#!/usr/bin/env ruby
# encoding: utf-8
require "rubygems"
require "amqp"
EventMachine.run do
AMQP.connect(:host => '127.0.0.1') do |connection|
puts "Connected to AMQP broker. Running #{AMQP::VERSION} version of the gem..."