Skip to content

Instantly share code, notes, and snippets.

View ged's full-sized avatar
President of the ByteBuffer fanclub

Michael Granger ged

President of the ByteBuffer fanclub
View GitHub Profile
@ged
ged / copyfrom.rb
Created September 28, 2010 15:45
Example of how to use COPY FROM from Ruby with the 'pg' library. The last two edits are demonstrating the error case and the successful case.
#!/usr/bin/env ruby
require 'pg'
require 'stringio'
$stderr.puts "Opening database connection ..."
conn = PGconn.connect( :dbname => 'test' )
conn.exec( <<END_SQL )
DROP TABLE IF EXISTS logs;
@ged
ged / app.html
Last active July 8, 2016 01:11 — forked from jdanyow/app.html
I'm Not Repeat.foring Correctly?
<template>
<h1>I expect:</h1>
<div>
<strong>this</strong>: that<br>
<strong>those</strong>: these<br>
</div>
<h1>But I get:</h1>
<div repeat.for="[a,b] of stuff">
<strong>${a}</strong>: ${b}<br>

Keybase proof

I hereby claim:

  • I am ged on github.
  • I am ged (https://keybase.io/ged) on keybase.
  • I have a public key ASCwVmGyGLRuwjCKt6kSJ0Zy89VDirUXsa8kR8v84mDYggo

To claim this, I am signing this object:

diff --git a/lib/inversion/template.rb b/lib/inversion/template.rb
--- a/lib/inversion/template.rb
+++ b/lib/inversion/template.rb
@@ -121,6 +121,7 @@ class Inversion::Template
:ignore_unknown_tags => true,
:template_paths => [],
:stat_delay => 0,
+ :strict_attributes => false,
# Rendering options
@ged
ged / show.html.erb
Created January 19, 2012 23:07 — forked from pbruna/show.html.erb
Treequel adding to many extensions
class OrganizationalUnitsController < ApplicationController
def show
@organizational_unit = @directory.search( params[:id], :base )
end
end
require 'treequel/model'
require 'treequel/model/objectclass'
@ged
ged / sheen.rb
Created October 25, 2011 21:42 — forked from tarcieri/sheen.rb
Example class using Celluloid::Actor
class Sheen
include Celluloid::Actor
def initialize(name)
@name = name
end
def current_status
"#{@name} is winning!"
end
@ged
ged / modinheritance.rb
Created April 14, 2011 17:23
Module is_a?
#!/usr/bin/env ruby
class A
def initialize
puts "Initializing an A"
super
end
end
module B
@ged
ged / parasite.rb
Created November 13, 2010 23:33
More cool/stupid Method#to_proc tricks
#!/usr/bin/env ruby -wKU
### A parasitic class
class Parasite
### Make all future instances of the Parasite actually call
### methods of the +victim+ instead.
def self.infest( victim )
victim.methods.each do |m|
meth = victim.method( m )
#!/usr/bin/env ruby
class A
def a; end
def b; end
end
class B < A
def a; end
end