Skip to content

Instantly share code, notes, and snippets.

View pat's full-sized avatar
🇵🇸
free Palestine 🇵🇸

Pat Allan pat

🇵🇸
free Palestine 🇵🇸
View GitHub Profile
# Facets syntax first draft
# Defining
define_index do
indexes state, :facet => true # use existing field
has year, :facet => true # use existing attribute
has status_id, :facet => status.name # use existing attribute as key, given field as text
facet status.name
facet status.name, :id => status.id
end
# Current Facets Support:
#
# Single-model searches only
#
class Person < ActiveRecord::Base
define_index do
indexes state, :facet => true
has year, :facet => true
facet city
Overview of Saul Griffith talk at The Long Now Foundation, written by Stewart
Brand:
Engineer Griffith said he was going to make the connection between personal
actions and global climate change. To do that he's been analyzing his own life
in extreme detail to figure out exactly how much energy he uses and what
changes might reduce the load. In 2007, when he started, he was consuming
about 18,000 watts, like most Americans.
The energy budget of the average person in the world is about 2,200 watts.
# Goal is => Client.first.items... Can do with finder_sql, but want an activerecord way!
class Client < ActiveRecord::Base
has_many :contacts
has_many :tasks, :through => :contacts
# has_many :items, :through => :tasks # THIS DOESNT WORK
def items
@items ||= self.tasks.collect { |task| task.items }.flatten
end
- filtered_filenames(@items).each do |name|
%p do some stuff
require 'mysql'
require 'riddle'
require 'trollop'
opts = Trollop::options do
opt :sql_host, "SQL host", :type => :string
opt :sql_user, "SQL username", :type => :string
opt :sql_pass, "SQL password", :type => :string
opt :sql_db, "SQL database", :type => :string
opt :sql_socket,"SQL socket", :type => :string
/Library/Ruby/Gems/1.8/gems/radiant-0.7.1/vendor/rails/railties/lib/initializer.rb:358:in `load_view_paths': private method `load' called for #<String:0x349e118> (NoMethodError)
from /Library/Ruby/Gems/1.8/gems/radiant-0.7.1/vendor/rails/railties/lib/initializer.rb:182:in `process'
from /Library/Ruby/Gems/1.8/gems/radiant-0.7.1/vendor/rails/railties/lib/initializer.rb:112:in `send'
from /Library/Ruby/Gems/1.8/gems/radiant-0.7.1/vendor/rails/railties/lib/initializer.rb:112:in `run'
from /Library/Ruby/Gems/1.8/gems/radiant-0.7.1/lib/radiant/initializer.rb:100:in `run'
from /Users/pat/Code/ccc/internet/config/environment.rb:12
from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require'
from /Library/Ruby/Gems/1.8/gems/radiant-0.7.1/vendor/rails/activesupport/lib/active_support/dependencies.rb:153:in `require'
... 23 levels...
curl -L http://github.com/freelancing-god/fakeweb/tarball/matcher -o matcher.tar.gz
tar -xvf matcher.tar.gz
mv freelancing-god-fakeweb* fakeweb
cd fakeweb
rake gem
sudo gem install pkg/fakeweb-1.3.1.gem
@pat
pat / super.rb
Created April 25, 2009 05:54 — forked from benschwarz/super.rb
class A
def initialize
dispatch if respond_to?(:dispatch)
end
end
class B < A
def dispatch
puts "called dispatch"
end
def drill(*args)
args.inject(nil) do |obj, pointer|
obj = obj.nil? ? pointer : obj[pointer]
end
end
@items = build_multilevel_hash
drill(@items, :right, :down, :to, :here)