Skip to content

Instantly share code, notes, and snippets.

module ApplicationHelper
def person_hcard_for(record, company=nil, options={ :logo => true })
return '' if record.nil?
html = ''
company ||= record.kind_of?(User) ? record.firm : record.parent_contact;
html << %Q(<div class="vcard person #{options[:class] || ''}">)
html << %Q( <h4 class="fn">#{h record.name}</h4>)
html << %Q( <div><a href="mailto:#{record.email}" class="email">#{h record.email}</a></div>)
html << %Q( <address class="adr">)
html << %Q( <div class="street-address">#{h company.address1}</div>) unless company.address1.blank?
@ihoka
ihoka / evented.rb
Created April 18, 2010 09:52 — forked from tenderlove/evented.rb
Event based Twitter stream client
require 'socket'
require 'psych'
###
# Event based Twitter stream client. Yields tweets as they happen from the
# "sample" stream. Requires Ruby 1.9.2.
#
# Example:
#
# sc = StreamClient.new($username, $password)
<LocationMatch "^/((?!stylesheets|images|invitations).)+$">
Require valid-user
Authtype basic
Authname "Something"
Authuserfile /some/path
</LocationMatch>
@ihoka
ihoka / after
Created February 16, 2010 15:29
Top 10 slowest examples:
0.1609040 User validations email should have many payments require unique values for email case insensitive
0.1101940 User validations email should not allow "test", "example.com", and "@example.com" as values for email
0.0933020 Content#ordered_thumbnails returns the thumbnails if no thumbnail is set
0.0931930 VideosController responding to #GET index should have many payments assign user
0.0927460 Content#encoding_notify thumbnail and preview encoding notification sets the thumbnail images
0.0925780 UsersController responding to #GET edit should have many payments render template "edit" and with layout "application"
0.0921550 Content #set_default_thumbnail sets content's thumbnail to the first thumbnail
0.0893400 Content#encoding_notify thumbnail and preview encoding notification sets the preview filename
0.0878390 Content#enqueue_transcoding updates the media id with the one received from the job queue
Top 10 slowest examples:
0.6008160 UsersController responding to #GET edit should have many payments assign user
0.5968420 UsersController responding to #GET show when logged in should have many payments assign user
0.5947920 UsersController responding to #PUT update with valid attributes should have many payments set the flash message success to "Successfully updated your account."
0.5909800 UsersController responding to #POST flag should have many payments redirect to "/1068/profile"
0.5896030 VideosController responding to #GET index should have many payments assign for_sale
0.5888560 UsersController responding to #GET show should have many payments render template "show" and with layout "others"
0.5873400 UsersController responding to #POST create with invalid attributes should have many payments assign user
0.5866060 ContentsController PUT update sets the flash message and redirects to the current user's home on success
0.5854330 ContentsController PUT update finds the specified content and assigns it fo
has_many :manager_org_links,
:class_name => "OrgLink",
:foreign_key => "subordinate_id",
:dependent => :delete_all,
:extend => SearchAndPaginateOrgLinks
has_many :peer_org_links,
:class_name => "OrgLink",
:dependent => :delete_all,
:extend => SearchAndPaginateOrgLinks
@ihoka
ihoka / gist:263155
Created December 24, 2009 11:33 — forked from ezmobius/gist:262085
require 'rubygems'
require 'redis'
require 'json'
require 'eventmachine'
class RedisLoop
class << self
attr_accessor :queues
def start(opts={}, &blk)
EM.run {
require 'rubygems'
require 'active_record'
# Open Safari's sqlite3 cache database
arb = ActiveRecord::Base
arb.establish_connection(
:adapter => "sqlite3",
:database => File.join(ENV['HOME'], 'Library', 'Caches', 'com.apple.Safari', 'Cache.db'))
# How to match files (LIKE string)
dyld: Library not loaded: /usr/lib/libsqlite3.dylib
Referenced from: /System/Library/Frameworks/Security.framework/Versions/A/Security
Reason: Incompatible library version: Security requires version 9.0.0 or later, but libsqlite3.dylib provides version 1.0.0
~/Projects/talent_rockr[master]% spec spec/controllers/measures_controller_spec.rb --format specdoc
Loaded /Volumes/SLHomes/piki/Projects/talent_rockr/db/populate/001_multi_value_elements.rb
Loaded /Volumes/SLHomes/piki/Projects/talent_rockr/db/populate/002_mve_country_type.rb
Loaded /Volumes/SLHomes/piki/Projects/talent_rockr/db/populate/003_mve_label_type.rb
Loaded /Volumes/SLHomes/piki/Projects/talent_rockr/db/populate/004_mve_objective_category_type.rb
Loaded /Volumes/SLHomes/piki/Projects/talent_rockr/db/populate/005_mve_measure_unit_type.rb
MeasuresController access control
- does not allow anonymous users
- does not allow regular employees