Skip to content

Instantly share code, notes, and snippets.

View hosh's full-sized avatar

Ho-Sheng Hsiao hosh

  • Remine
  • Phoenix, AZ
View GitHub Profile
I don't need this right now but I will need them for this current project over the summer.
Here's what I'm thinking:
- Build it on top of RESTClient
- On the surface, it should be compatible with ActiveResource
- Maybe take advantage of .to_model interface with ActiveORM in Rails3
- Use Addressable as Jesse suggests, to construct the URL
- Defaults to Yajl, switchable to JSON gem
- Defaults to Nokogiri + libxml2
- Pluggable backend: Net::HTTP or EventMachine's HTTP
require 'machinist/active_record'
require 'sham'
require 'faker'
# The one below is from an older version. In my newer version that works with rspec2,
# blueprints.rb is located in spec/support and the line below matches that. The advantage
# is that the generated spec_helper automatically loads anything under spec/support
require File.expand_path('blueprints.rb', File.dirname(__FILE__) + '/../spec/')
puts '', "Accounts ..."
@hosh
hosh / person.rb
Created April 20, 2010 14:49
Sample Remarkable Macros
# In app/models/person.rb
class Person < ActiveRecord::Base
belongs_to :organization
validates_presence_of :name
validates_presence of :email
validates_uniqueness_of :email
end
module Animal
def self.included(base)
base.extend(ClassMethods)
end
module ClassMethods
def say
"animal"
end
end
# Mock, this isn't real
$ rake db:schema:version
-> saves to db/schema/schema-20100403232.rb
# Now you don't have the problem with the timestamp embedded
# into the db/schema.rb every time you do a db:schema:dump
#!/bin/sh
# Configuration
#CLOUD_ETH="eth0"
CLOUD_ETH="eth1" # Standard for Rackspace Cloud
CHEFSERVER="10.177.133.40"
# Do not edit below
ActionController::Routing::Routes.draw do |map|
map.root :controller => :home, :action => :index
map.resources :servicios
map.resources :nosotros
#map.servicios '/servicios/consultorias', :controller => 'servicios', :action => 'consultoria'
map.connect "/servicios/:action", :controller => "servicios"
end
class Forgery
class Merchant
PRODUCTS = %w(coffee drink gas donut sandwich icecream cigarette)
PROMOTION_TYPES = [
lambda {
["Buy X P get Y Q free",
[:X, rand(3)+1],
[:Y, rand(4)+1],
[:P, PRODUCTS.rand],
#!/usr/bin/env ruby
def hello_loop(names)
names.each do |name|
puts "Hello #{name}"
end
end
hello_loop(%w(
Gafitescu
# app/concerns/let.rb
# Ripped from Rspec 2.0 beta.12
# I've found it so useful in Rspec, I made it into a module. Controller code with shared
# code seem to have a lot of use for this. For example, in inherited_resources, you would
# typically override model, parent, etc. to configure it. You would typically memomize it
# as well. With this, you can use a more compact let() syntax.
# (Note: This code will only work in Rails 3)
module Let