Skip to content

Instantly share code, notes, and snippets.

@manveru
manveru / raku
Created April 5, 2009 06:37
Raku is a tiny rake-task manager
#!/usr/bin/env ruby
require 'optparse'
require 'ostruct'
require 'pathname'
require 'fileutils'
require 'digest/sha1'
ACTIONS = []
TARGETS = []
From 69c54b3b56d6ca1e51cfe33a15a4a5b730cc82ec Mon Sep 17 00:00:00 2001
From: Michael Fellinger <m.fellinger@gmail.com>
Date: Thu, 16 Apr 2009 13:57:17 +0900
Subject: [PATCH] Improved Rack::Reloader
---
lib/rack/reloader.rb | 134 +++++++++++++++++++++++++++++++++-----------------
1 files changed, 88 insertions(+), 46 deletions(-)
diff --git a/lib/rack/reloader.rb b/lib/rack/reloader.rb
require 'ramaze'
module Thoth
def self.setup
puts 'ramaze is not up yet, but gonna be soon'
end
end
Ramaze.options.setup << Thoth
class AttribBase
def initialize
eval($initLine)
end
end
module ConstExtend
def const_missing(name)
const = const_set(name, Class.new(AttribBase))
const.extend(ConstExtend)
require 'bacon'
Bacon.summary_on_exit
describe 'keychain splitter' do
def split(keychain)
return nil, keychain if keychain.first == '0'
argument, rest = [], []
digits = true
layout do |path, wish|
if path !~ /feed|show/
mobile_rendering? ? :mobile : :main
end
end
def self.mobile_rendering?
(request.host =~ /m\.learnivore/) ? true : false
end
require 'benchmark'
def with_zip(n, a1, a2)
n.times do
a1.zip(a2).each{|a,b| [a,b]}
end
end
def with_index(n, a1, a2)
n.times do
require 'benchmark'
h = {
:asymbol => :foo,
:astring => 'foo',
'bsymbol' => :bar,
'bsymbol' => 'bar'
}
iterations = 2_000_000
jruby-1.4.0: jruby 1.4.0 (ruby 1.8.7 patchlevel 174) (2009-11-02 69fbfa3) (Java HotSpot(TM) 64-Bit Server VM 1.6.0_17) [amd64-java]
Rehearsal -------------------------------------------------------
on the fly: 1.591000 0.000000 1.591000 ( 1.511000)
compiled: 0.861000 0.000000 0.861000 ( 0.861000)
on the fly right: 0.814000 0.000000 0.814000 ( 0.815000)
compiled right: 0.712000 0.000000 0.712000 ( 0.712000)
---------------------------------------------- total: 3.978000sec
user system total real
require 'nokogiri'
require 'csv'
template = Nokogiri::XML(DATA.read)
builder = Nokogiri::XML::Builder.with(template.at('group')) do |group|
CSV.foreach('export', headers: true) do |row|
group.entry do |entry|
entry.title row['title']
entry.username row['username']
entry.password row['password']