Skip to content

Instantly share code, notes, and snippets.

#
# ruby implementation of
# https://github.com/domnikl/DesignPatternsPHP/tree/master/Structural/Adapter
# for reno developers meetup 2014-07-28
# https://github.com/renodevelopers/meetups/issues/26
#
module DesignPatterns
module Structural
{
"schema": {
"description": "Schema for Inspections. Represents top-level inspection data.",
"attributes": {
"id": "Surrogate key",
"date": "Date of inspection",
"links": {
"inspection": "Link to inspection data"
}
}
@duonoid
duonoid / extract_facilities.rb
Last active December 24, 2015 06:39 — forked from elskwid/washoe_eats.rb
I played with it a little, attempting to understand their site...
#
# usage: ruby -Imechanize extract_facilities.rb
require "mechanize"
class FacilityScraper
def self.call
new.call
end
$ whois johnga.lt
% Hello, this is the DOMREG whois service.
%
% By submitting a query you agree not to use the information made
% available to:
% - allow, enable or otherwise support the transmission of unsolicited,
% commercial advertising or other solicitations whether via email or
% otherwise;
% - target advertising in any possible way;
% - to cause nuisance in any possible way to the registrants by sending
// example usage:
// <script type="text/javascript" src="redirector.js"></script>
//
// <script type="text/javascript">
// (function (global) {
// redir = global.Redirector;
//
// redir.width = 1400; // optional
// redir.base_url = "http://example.com";
// redir.redirect();
@duonoid
duonoid / gist:1953593
Created March 1, 2012 22:09
hello examples for Josh
$ cat bitizen.rb
module BitTypes
def bit_types
%w[ Food Service Recreation Retail Creative ]
end
end
class Job
include BitTypes
@duonoid
duonoid / gist:807008
Created February 2, 2011 00:20
after gem update 2011-02-01 (most likely: rubygems-update-1.4.2 -> 1.5.0)
$ ./script/server
=> Booting Mongrel
=> Rails 2.3.5 application starting on http://0.0.0.0:3000
/usr/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/rails/gem_dependency.rb:119:in `requirement': undefined local variable or method `version_requirements' for #<Rails::GemDependency:0xf6e64a78> (NameError)
from /usr/local/lib/site_ruby/1.8/rubygems.rb:254:in `activate'
from /usr/local/lib/site_ruby/1.8/rubygems.rb:1204:in `gem'
from /usr/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/rails/gem_dependency.rb:73:in `add_load_paths'
from /usr/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/initializer.rb:301:in `add_gem_load_paths'
from /usr/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/initializer.rb:301:in `each'
from /usr/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/initializer.rb:301:in `add_gem_load_paths'
@duonoid
duonoid / gist:467672
Created July 8, 2010 05:31
while running rails in local development
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapters/postgresql_adapter.rb:1029: [BUG] rb_gc_mark(): unknown data type 0x34(0xa9405d8) non object
ruby 1.8.7 (2010-01-10 patchlevel 249) [i486-linux]
Aborted
/etc/nginx# cat canonical_hostname
if ($host != $server_name) {
rewrite ^(.*)$ $scheme://$server_name$1 permanent;
}
# config/initializers/datamapper.rb
#
# configuring DataMapper w/ Rails (including setting up logging)
require 'dm-core'
# http://datamapper.rubyforge.org/dm-core/DataMapper/Logger.html
# have to setup logger *before* #setup
DataMapper.logger = RAILS_DEFAULT_LOGGER
# http://datamapper.rubyforge.org/dm-core/DataMapper.html
hash = YAML.load(File.new(File.expand_path("config/database.yml", Rails.root)))