Skip to content

Instantly share code, notes, and snippets.

@migane
migane / gist:3660478
Created September 6, 2012 21:24
Sorting file lines with rackup and curl
# Alpha.txt is supposed to be a text file with multiple lines
# my_sort_file.rb
class MySortFile
def call(env)
req = Rack::Request.new(env)
initial_file = req.params['file']
Rack::Response.new.finish do |res|
res['Content-Type'] = 'text/plain'
@migane
migane / gist:3729548
Created September 15, 2012 20:09
Date locale/us in jruby
# jruby01.rb
require 'java'
java_import('java.util.Date') { |pkg, name| 'JDate' }
# To get the locales
java_import('java.util.Locale') { |pkg, name| 'JLocale'}
java_import('java.text.DateFormat')
# Get the date in local format
@migane
migane / gist:3776032
Created September 24, 2012 13:46
Login window with MigLayout in JRuby
# Using MigLayout as frankly Javax Swing without a decent GUI
# tool is really a nightmare
# One has to download the MigLayout jar from its site
# then put it inside the jruby/lib folder
require 'java'
# For rvm users => allow to just run jruby frontend.rb
# provided that a .rvmrc has been created in the directory where
# frontend.rb is located.