Skip to content

Instantly share code, notes, and snippets.

View LeoNogueira's full-sized avatar

Leonardo Nogueira LeoNogueira

View GitHub Profile
@LeoNogueira
LeoNogueira / gist:07e6cc7f12d90cbc1eda
Created July 11, 2014 16:47
Using bundle binstubs with Rails
bundle config --delete bin # Turn off Bundler's stub generator
rake rails:update:bin # Use the new Rails 4 executables
git add bin # Add bin/ to source control
@LeoNogueira
LeoNogueira / gist:7684018
Created November 27, 2013 22:04
Function to list all object properties
function listAllProperties(o){
var objectToInspect;
var result = [];
for(objectToInspect = o; objectToInspect !== null; objectToInspect = Object.getPrototypeOf(objectToInspect)){
console.log(Object.getOwnPropertyNames(objectToInspect));
}
}

Polymorphism

Sometimes relationships need to be flexible, and that's where we look to polymorphism. Say we want to implement:

  • A Person
  • A Company
  • A PhoneNumber that can connect to a Person or a Company

At the Database Level

## based on the example at:
## http://gist.github.com/17371
##
## put me in lib/un_haml.rb (in the haml-based project)
##
## call me on the command line thus:
## $ script/runner UnHaml app/views/layouts/application.html.haml
## $ script/runner UnHaml */*/*/*.haml
##
class UnHaml < Haml::Engine
# testing the webservice with soapUI works fine using :
# <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/">
# <soapenv:Header/>
# <soapenv:Body>
# <tem:GetAllUsers/>
# </soapenv:Body>
# </soapenv:Envelope>
require 'rubygems'
require 'savon'
@LeoNogueira
LeoNogueira / gist:801997
Created January 29, 2011 17:07
DNSServers
OpenDNS 1 - 208.67.222.222
OpenDNS 1 - 208.67.220.220
Google Public DNS1 - 8.8.8.8
Google Public DNS2 - 8.8.4.4