Skip to content

Instantly share code, notes, and snippets.

View jeremyevans's full-sized avatar

Jeremy Evans jeremyevans

View GitHub Profile
@jeremyevans
jeremyevans / gist:7837679
Created December 7, 2013 05:42
Toto to Jekyll converter used to convert the sequel blog
# Run from jekyll dir
Dir['/path/to/toto/articles/*.txt'].sort.each do |path|
file = File.basename(path)
new_file = "_posts/#{file.sub(/\.txt\z/, '.md')}"
text = File.read(path)
headers, md = text.split("\n\n", 2)
raise "No title" unless headers =~ /^title: (.+)$/
title = $1
File.write(new_file, "---\n layout: post\n title: #{title}\n---\n\n#{md}")
end
ruby 2.0.0p247 (2013-06-27 revision 41674) [i386-openbsd]
.................F....F........................................................................................................E..F...................................................................................................................................................F..F.F...........................................................................................................................F.....................F...........................................................E...................E................E............................................................................................................................................................................................................................................................................................F.................................FF...F.........FF...E......E...E.........................................FF..............................................
1)
Dir.home raises an ArgumentError if the named user doesn't exist FAILED
Expected ArgumentError
but got Errno::ENOENT (No such file or directory - retrieving user home directory - getpwnam_r(3))
{ } in Object#__script__ at spec/ruby/core/dir/home_spec.rb:23
BasicObject(Object)#instance_eval at kernel/common/eval.rb:43
{ } in Enumerable(Array)#all? at kernel/common/enumerable.rb:304
Array#each at kernel/bootstrap/array.rb:66
Enumerable(Array)#all? at kernel/common/enumerable.rb:304
Integer(Fixnum)#times at kernel/common/integer.rb:198
daedalus: Nothing to do for vm/vm
Invoke spec (first_time)
** Invoke build (first_time)
** Invoke build:build (first_time)
** Invoke build:llvm (first_time)
** Execute build:llvm
** Invoke vm/vm (first_time)
** Invoke vm/gen/config_variables.h (first_time, not_needed)
** Invoke library/rubinius/configuration.rb (first_time, not_needed)
** Invoke config.rb (first_time, not_needed)
@jeremyevans
jeremyevans / sequel_model_without_a_table.rb
Created October 10, 2012 21:17 — forked from jescalante/sequel_model_without_a_table.rb
Trying to use a sequel model without a table
# in sequel/plugins/foo.rb
module Sequel::Plugin::Foo
def self.apply(model)
model.plugin :timestamps, :create => :created_on, :update => :updated_on
model.plugin :validation_helpers
model.many_to_one :user
end
module InstanceMethods
# Note that it's probably a bad idea to override initialize unless you
Calculating -------------------------------------
AR new 1110 i/100ms
AR new args 479 i/100ms
AR create 57 i/100ms
AR find 131 i/100ms
-------------------------------------------------
AR new 13570.5 (±5.4%) i/s - 67710 in 5.003359s
AR new args 5271.7 (±6.5%) i/s - 26345 in 5.018283s
AR create 576.4 (±6.2%) i/s - 2907 in 5.062781s
AR find 1357.2 (±4.2%) i/s - 6812 in 5.027665s
one: {:name=>"Acme Enterprises, Inc.", :commplanname=>"All Transactions", :policynum=>"21IL909GL341234", :class=>"WORK", :billingtype=>"D", :term=>"A", :territory=>nil, :location=>1, :effective=>2008-10-05 00:00:00 -0500, :expires=>2009-10-04 00:00:00 -0500, :cancelled=>false, :decverified=>nil, :totprem=>#<BigDecimal:1d2da07,'0.1492E4',4(12)>, :policyfee=>#<BigDecimal:1e80cc2,'0.0',1(4)>, :adminfee=>#<BigDecimal:19db869,'0.0',1(4)>, :tax=>#<BigDecimal:1b5f860,'0.0',1(4)>, :otherfee=>#<BigDecimal:1c5822c,'0.0',1(4)>}
two: Acme Enterprises, Inc.
@jeremyevans
jeremyevans / record.rb
Created March 31, 2012 19:20 — forked from leucos/record.rb
An attempt with Sequel's composition plugin
# In-memory test database
# The schema has been simplified for the discussion (yes, it should have some domain_id somewhere !)
#
# Values in the content field for a SOA, are, in order :
# ns email serial refresh retry expiry minimum
DB = Sequel.sqlite
DB.run "CREATE TABLE records (name VARCHAR(255) PRIMARY KEY NOT NULL, type VARCHAR(5), content VARCHAR(255))"
DB.run "INSERT INTO records VALUES ('example.com', 'SOA', 'ns.example.com root.example.com 2012333335 28800 86400 3600000 86400')"
# Just an assert function for basic testing
@jeremyevans
jeremyevans / non_persistent_test.rb
Created March 1, 2012 16:39 — forked from nelsnelson/non_persistent_test.rb
Testing non-persistent fields on persisted identity-mapped entity instances in JRuby and Sequel through jdbc-postgres
#! /usr/bin/env jruby
require 'rubygems'
require 'sequel'
DB = Sequel.sqlite
DB.create_table? :test do
primary_key :id
foreign_key :parent_id, :test, :on_delete => :set_null
module Sequel
module Plugins
module OracleSequence
def self.configure(model, seq=nil)
model.sequence = seq || model.dataset.opts[:sequence]
model.dataset = model.dataset.sequence(nil) if model.dataset.opts[:sequence]
end
module ClassMethods
attr_accessor :sequence
end