Skip to content

Instantly share code, notes, and snippets.

View jpemberthy's full-sized avatar

Juan Pemberthy jpemberthy

View GitHub Profile
>> ShortURL.shorten( 'http://www.istwitterdown.com' )
=> "http://rubyurl.com/P9w"
>> ShortURL.shorten( 'http://www.istwitterdoasdfsdfwn.com' )
=> "http://rubyurl.com/XB8P"
>> ShortURL.shorten( 'http://www.istwitterdown.com' )
=> "http://rubyurl.com/P9w"
test user
INSERT into people (first_name, last_name, login, access_level, type, timezone, salt, crypted_password, activated_at ) values ('juan', 'pemberthy', "jpemberthy", "admin", "User", "Pacific Time (US & Canada)", "cfc5a1bf387c1d2b3356859e21b9c390879928cf", "6815e1f121fe06ec575eb9577c90d6f4bb0eca1b", "2009-07-02 14:11:11" )
test rel
r = Relationship.new(:relationship_type_id => 28, :contact_id => 717641310, :client_id => 94, :primary => false, :message_visible => true)
another rel
<% author_name = message.author ? message.author.name : User.find(message.author_id, :with_deleted => true).name %>
<td class="by">
<%=h author_name %><%= " wrote" unless controller.controller_name == 'messages' %>
>> @selection.text
=> "jaroslav writes \"The University of Wisconsin is attempting to update a payroll system they have had in place since 1975, but spent $28.4 million in a 2004 attempt with no results, and now is experiencing new overruns in cost and time after \"not hav[ing] the full picture of how complex this project would be\". The current estimate of the redesign is $12 million and years of further work on top of the money already spent.\""
>> doc.search('//' + search_path).first.text
=> "jaroslav writes \"The\nUniversity of Wisconsin is attempting to update a payroll system they\nhave had in place since 1975, but spent $28.4 million in a 2004 attempt\nwith no results, and now is experiencing new overruns in cost and time\nafter \"not hav[ing] the full picture of how complex this project would\nbe\". The current estimate of the redesign is $12 million and years of further work on top of the money already spent.\""
init.rb
def has_one_with_deleted(association_id, options = {})
with_deleted = options.delete :with_deleted
returning has_one_without_deleted(association_id, options) do
if with_deleted
reflection = reflect_on_association(association_id)
association_accessor_methods(reflection, Caboose::Acts::HasOneThroughWithDeletedAssociation)
association_constructor_method(:build, reflection, Caboose::Acts::HasOneThroughWithDeletedAssociation)
association_constructor_method(:create, reflection, Caboose::Acts::HasOneThroughWithDeletedAssociation)
Element.update("content", "\u003Ch4\u003ECreate New Document\u003C/h4\u003E\r\n\u003Cform action=\"/railfrog_admin/create_chunk\" method=\"post\" onsubmit=\"new Ajax.Request('/railfrog_admin/create_chunk', {asynchronous:true, evalScripts:true, parameters:Form.serialize(this)}); return false;\"\u003E\u003Cdiv style=\"margin:0;padding:0\"\u003E\u003Cinput name=\"authenticity_token\" type=\"hidden\" value=\"4a696668506e589c48c29ab99def55d274c768d0\" /\u003E\u003C/div\u003E\r\n \u003Cinput id=\"parent_id\" name=\"parent_id\" type=\"hidden\" value=\"3\" /\u003E\r\n \u003Cinput id=\"markup\" name=\"markup\" type=\"hidden\" value=\"html\" /\u003E\r\n \n\n\n\n\u003Cp\u003E\u003Clabel for=\"site_mapping_path_segment\"\u003EDocument Name\u003C/label\u003E\u003Cbr/\u003E\n\u003Cinput id=\"site_mapping_path_segment\" name=\"site_mapping[path_segment]\" size=\"30\" type=\"text\" value=\"\" /\u003E\u003Cbr/\u003E\n\u0026nbsp; \u0026nbsp; the document name will be the last part of the URL for this document\u003C/p\u003E\
[user]
name = Scott Chacon
email = [email protected]
[alias]
serve = !git daemon --reuseaddr --verbose --base-path=. --export-all ./.git
unstage = reset HEAD
lol = log --pretty=oneline --abbrev-commit --graph --decorate
branches = !git-branches
st = status
[gui]
def datetime_calendar(initial_date, opts = {}, html_opts = {}) #:nodoc:
options = {:prefix => 'date'}
options.merge!(opts)
date_format = Wice::Defaults::DATETIME_FORMAT
date_string = initial_date.nil? ? '' : initial_date.strftime(Wice::Defaults::DATETIME_FORMAT)
date_picker, datepicker_placeholder_id, trigger_id, dom_id, date_span_id = select_date_datetime_common(options, date_string, html_opts)
html = "<span id=\"#{datepicker_placeholder_id}\">#{date_picker}</span>"
html << %(<script type="text/javascript">\n)
config = Rails::Configuration.new
database = config.database_configuration[RAILS_ENV]["database"]
username = config.database_configuration[RAILS_ENV]["username"]
password = config.database_configuration[RAILS_ENV]["password"]
namespace :db do
#rake db:dump
desc "dumps the database to a sql file"
task :dump => :environment do
<r:children:each limit="3" order="desc">
<div class="blog_post">
<h4><r:link /></h4>
<r:content />
<r:if_content part="extended"><r:link anchor="extended">Continue Reading&#8230;</r:link></r:if_content>
<p>Posted by <r:author /> on <r:date format="%d/%m/%Y" /></p>
<div class="blog_separator"><hr /></div>
</div>
</r:children:each>