This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#alter-ego.rubyforge.org | |
require 'ostruct' | |
require File.expand_path('spec_helper', File.dirname(__FILE__)) | |
# let's define a traffic light class with three states: proceed, caution, and | |
# stop. We'll leave the DSL for later, and use old-school class definitions to | |
# start out. | |
class TrafficLightWithClassicStates | |
include AlterEgo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--EXISTING SQL FOR SPHINX | |
SELECT SQL_NO_CACHE | |
`places`.`id` * 2 + 1 AS `id` , | |
`places`.`name` AS `name`, | |
`places`.`address` AS `address`, | |
`places`.`city` AS `city`, | |
`places`.`description` AS `description`, | |
GROUP_CONCAT(DISTINCT IFNULL(`reviews`.`body`, '0') SEPARATOR ' ') AS `body`, | |
GROUP_CONCAT(DISTINCT IFNULL(`reviews`.`title`, '0') SEPARATOR ' ') AS `title`, | |
GROUP_CONCAT(DISTINCT IFNULL(`tags`.`name`, '0') SEPARATOR ' ') AS `tags`, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ruby-1.8.7-p302 > e = Ebates.first | |
ruby-1.8.7-p302 > first = e.current_protos.select{|i| i.rname =~ /shoe/i}[0] | |
"ShoeMall" "http://www.ebates.com/stores/shoemall.com.htm", cb: "8.0% " | |
ruby-1.8.7-p302 > dup = e.current_protos.select{|i| i.rname =~ /shoe/i}[11] | |
"ShoeMall" "http://www.ebates.com/stores/shoemall.com.htm", cb: "8.0% " | |
ruby-1.8.7-p302 > first.process |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
##The original processing done by this protoperk. (From rbs_hrz.sql) | |
ruby-1.8.7-p302 > puts ProtoPerk.find(324076).stdout | |
ICE.com - After Christmas Sale - Save an additional 20% at Ice.com (2011-01-17) {187391} | |
finding 0 locations for ICE.com - After Christmas Sale - Save an additional 20% at Ice.com (2011-01-17) {187391} (324076) | |
Processing tbds: christmas sale | |
locs benefit applies_to type reward_fixed dollars_off min_overall reward_var free_shipping per_n_dollars store_id reward_multi free_gift unrestricted min_dollars program_id reduced_shipping percent_off | |
updated: Coupon(249980,289207,315750) | |
Status: updated | |
# Note the: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
db |
We needed a better example for http://stackoverflow.com/questions/6267059/make-all-actionviewer-helper-methods-available-in-a-module/6271730#6271730
Other Resources on using helpers outside of ActionView:
http://drawohara.com/post/24582894/rails-un-suckass-ing-actionview-helpers-in-the-name
The other approach to this task is to use helpers for just the view oriented portions, and Presenters which are tied to them heavily. http://gilesbowkett.blogspot.com/2007/10/my-version-of-rails-presenters.html http://blog.new-bamboo.co.uk/2007/8/31/presenters-conductors-on-rails
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Mapping RRV to Tests: | |
1. Patch releases (3.2.1) should only include bug fixes and internal implementation changes. | |
test/bugs/ can change | |
test/internal/ can change | |
2. Minor releases (3.2.0) can include bug fixes, internal changes, and new features, but no breaking changes. | |
test/feature_stories/ can be added to |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# System-wide crontab file and cron job directory. Change these for your system. | |
CRONTAB='/etc/crontab' | |
CRONDIR='/etc/cron.d' | |
# Single tab character. Annoyingly necessary. | |
tab=$(echo -en "\t") | |
# Given a stream of crontab lines, exclude non-cron job lines, replace |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>> x = (1..10000000).to_a; x.length | |
=> 10000000 | |
>> | |
?> by_reverse = Proc.new{|p,o| Proc.new{|a,b| b.send(p,o) <=> a.send(p,o)}} | |
=> #<Proc:0x000000013b68a330@(irb):50> | |
>> Benchmark.bm do |y| | |
?> y.report("sort_by neg") { x.sort_by{|i| - (i + 1)} } | |
>> y.report("sort no_send") { x.sort{|a,b| (b + 1) <=> (a + 1)} } | |
>> y.report("sort send") { x.sort{|a,b| b.send('+', 1) <=> a.send('+', 1)}} | |
>> y.report('procs send') { x.sort(&(by_reverse.call('+',1))) } |