Skip to content

Instantly share code, notes, and snippets.

View waynerobinson's full-sized avatar

Wayne Robinson waynerobinson

View GitHub Profile
module MyMixin
def test_constant
puts MY_CONSTANT
end
end
class Foo
MY_CONSTANT = "BLAH"
include MyMixin
end
module MyMixin
def self.included(base)
puts base.to_s
end
end
module TopLevel
class MyClass
include MyMixin
end
require "jruby"
require "dcell"
DCell.start id: "node1-client", addr: "tcp://127.0.0.1:4001", directory: {id: "node1", addr: "tcp://127.0.0.1:4000"}
loop {
duck = DCell::Global[:duck]
if duck
begin
puts duck.future.quack.value(1.5)
module MTData
class Base < ActiveRecord::Base
# MT_DATA_DATABASE should have a connection string to one of the
# specific databases.
establish_connection MT_DATA_DATABASE
end
class Street < Base
self.table_name = "street"
end
class Autocompleter
def self.parse_street_input(input)
matches = /
(
(?:[Uu](?:nit)?\s*)? #U or Unit, any casing, maybe with following spaces, non-captured
[\d\/\s\\\-,]+ #Unit number (Digits, spaces, dashes, both slashes)
\d?) #Street Number
?\s? #Spacing and Optionality for Numbering
([\w\-\s']+) #Street Name - Match any combination of words and spaces (And apostrophe)
@waynerobinson
waynerobinson / cachable_address.rb
Created September 25, 2012 02:10
Cached Address Proxy
require "dalli"
require "yaml"
module MTDataStone
class CachableAddresses < Addresses
DALLI_HOST = "localhost:11211"
DALLI_OPTIONS = {}
EXPIRY_PERIOD = 60.days
@waynerobinson
waynerobinson / index.html
Created August 15, 2012 09:16
MacBook Pro Icon in CSS3 Only
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<!-- IF PEN IS PRIVATE -->
<!-- <meta name="robots" content="noindex"> -->
<!-- END -->
@waynerobinson
waynerobinson / limitandoffset.sql
Created July 20, 2012 05:16
Oracle - SELECT ordered with LIMIT and OFFSET
-- SELECT with LIMIT and OFFSET in MySQL
SELECT id, name FROM table ORDER BY name LIMIT 100 OFFSET 50;
-- SELECT with LIMIT and OFFSET in Oracle
SELECT a.id, a.name
FROM (SELECT b.id, b.name,
@waynerobinson
waynerobinson / juggernaut.rb
Created June 26, 2012 03:00 — forked from maccman/juggernaut.rb
Juggernaut - simple design
# Usage: redis-cli publish message hello
require 'sinatra'
require 'redis'
conns = []
get '/' do
erb :index
end
@waynerobinson
waynerobinson / request.xml
Created April 17, 2012 01:22
New Manual Journal URL Field Not Working
<ManualJournal>
<Date>2011-12-31</Date>
<Status>DRAFT</Status>
<LineAmountTypes>Exclusive</LineAmountTypes>
<UpdatedDateUTC>2008-09-12T05:04:00</UpdatedDateUTC>
<ManualJournalID>f00a355b-7374-445c-886b-0437bea4095c</ManualJournalID>
<Narration>Computer expenses incorrectly coded</Narration>
<JournalLines>
<JournalLine>
<Description>Laptop to wrong expense account</Description>