Skip to content

Instantly share code, notes, and snippets.

@atoulme
atoulme / oauth2_example_create.rb
Created August 27, 2012 22:28
OAuth2 example to access Intalio|Create
#!/usr/bin/env ruby
require 'rubygems'
require "wrest"
require "multi_json"
require 'pp'
target_host="http://localhost:8080"
login_user="enter_username"
login_user_password="enter_password"
@atoulme
atoulme / class_methods_and_private.txt
Created December 9, 2011 07:30
class_methods_and_private.txt
ruby-1.9.3-preview1 :001 > class Foo
ruby-1.9.3-preview1 :002?> private
ruby-1.9.3-preview1 :003?> def self.up
ruby-1.9.3-preview1 :004?> "w00t"
ruby-1.9.3-preview1 :005?> end
ruby-1.9.3-preview1 :006?> end
=> nil
ruby-1.9.3-preview1 :007 > class Bar
ruby-1.9.3-preview1 :008?> class << self
ruby-1.9.3-preview1 :009?> private
@atoulme
atoulme / output_buildr_rvm.txt
Created November 16, 2011 20:26
rvmrc_buildr
error: Gemset 'buildr' does not exist, rvm gemset create 'buildr' first.
info: Using jruby 1.6.5 with gemset buildr
Installing bundler...
Fetching: bundler-1.0.21.gem (100%)
Successfully installed bundler-1.0.21
1 gem installed
Installing ri documentation for bundler-1.0.21...
Installing RDoc documentation for bundler-1.0.21...
@atoulme
atoulme / nato_phonetic_alphabet_js.html
Created November 11, 2011 22:44
Use the nato phonetic alphabet to spell words
<!DOCTYPE html>
<html>
<head>
<title>Get your computer to spell for you</title>
<script type="text/javascript">
function spellText(text) {
for (var i = 0; i <= text.length; i++) {
var c = text.substring(i, i + 1).toLowerCase();
var duration = null;
@atoulme
atoulme / osgi_and_jruby.txt
Created September 7, 2011 16:42
osgi_and_jruby.txt
OSGi is supported by JRuby 1.6.0 onwards.
1. OSGiScriptingContainer
Check out that class. Any OSGi app must use this container. In particular, you can add bundles to the jruby classpath easily with this container.
2. LocalScopeContext
By default it is set to SINGLETHREAD. That's the only one that works right now, others will spawn CNFE randomly when used.
@atoulme
atoulme / should.rb
Created June 28, 2011 00:52
should
describe "No should was harmed" do
it "should not care whatever I do with == for booleans" do
true == false
end
it "should not care for numbers" do
1 == 0
end
it "should not even do type validation" do
@atoulme
atoulme / download_and_unzip_a_maven_jar_with_buildr.rb
Created June 3, 2011 22:28
how to download a maven bundle, and unzip it with Buildr
eclipseSDK = Buildr::artifact("org.eclipse:eclipse-SDK:zip:3.6M3-win32")
eclipseSDK.invoke
Buildr::unzip(File.dirname(eclipseSDK.to_s) => eclipseSDK.to_s).extract
@atoulme
atoulme / extract_greenhopper_graph_from_jira.rb
Created April 23, 2011 01:17
Extract Greenhopper graph from Jira using Ruby
require 'rubygems'
require 'net/http'
require 'hpricot'
SERVER = "jira.example.com"
GRAPH_URL = "/secure/ChartBoard.jspa?type=CCB&selectedProjectId=xxxxx&selectedBoardId=xxxxxx&colPage=1"
Net::HTTP.start(SERVER) {|http|
req = Net::HTTP::Get.new(GRAPH_URL)
resp = http.request(req)
html = Hpricot(resp.body)
@atoulme
atoulme / escape_unicode.rb
Created April 11, 2011 19:47
A script to escape a String into unicode characters for double bytes strings
#!/usr/bin/env ruby
puts "Enter content and press Ctrl+D when ready"
old_stty = `stty -g`
# Set up the terminal in non-canonical mode input processing
# This causes the terminal to process one character at a time
system "stty -icanon min 1 time 0 -isig"
answer = ""
while true
char = STDIN.getc
break if char == ?\C-d # break on Ctrl-d
@atoulme
atoulme / scrap_jira_issues.rb
Created April 11, 2011 18:14
A simple script to scrap a set of jira issues from Jira. You should always use the "printable" url of the filter you pass.
require 'uri'
require 'net/http'
require 'rubygems'
require 'hpricot'
def extract_updates(url)
html = Net::HTTP.get(URI.parse(url))
doc = Hpricot(html)
table = doc.search("//*[@id='issuetable']")
table.search("//*[@class='nav duedate']").remove