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
<?php | |
$Members = new Pod('members'); | |
$Members->findRecords($orderby = 'city ASC', 100); | |
// group members by city | |
$members_by_city = array(); | |
while ($data = $Members->fetchRecord()) { | |
$city_name = $data["city"]; | |
if(!$members_by_city[$city_name]) { | |
$members_by_city[$city_name] = array($data); |
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
# requires Ruby 1.9 | |
require "open-uri" | |
VALID_FORMAT = "[VALID] %s" | |
INVALID_FORMAT = "[INVALID] %s" | |
def valid?(url) | |
open(url).read.force_encoding("UTF-8").valid_encoding? | |
end |
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
~/Projects/Personal/demo $ rake db:migrate --trace | |
(in /Users/tjsingleton/Projects/Personal/demo) | |
rake aborted! | |
undefined method `insert' for Paperclip::Railtie:Class | |
/Users/tjsingleton/.rvm/gems/ruby-1.9.1-p378/gems/paperclip-2.3.2/lib/paperclip/railtie.rb:8:in `block in <class:Railtie>' | |
/Users/tjsingleton/.rvm/gems/ruby-1.9.1-p378/gems/activesupport-3.0.0.beta3/lib/active_support/lazy_load_hooks.rb:7:in `instance_eval' | |
/Users/tjsingleton/.rvm/gems/ruby-1.9.1-p378/gems/activesupport-3.0.0.beta3/lib/active_support/lazy_load_hooks.rb:7:in `on_load' | |
/Users/tjsingleton/.rvm/gems/ruby-1.9.1-p378/gems/paperclip-2.3.2/lib/paperclip/railtie.rb:7:in `<class:Railtie>' | |
/Users/tjsingleton/.rvm/gems/ruby-1.9.1-p378/gems/paperclip-2.3.2/lib/paperclip/railtie.rb:6:in `<module:Paperclip>' | |
/Users/tjsingleton/.rvm/gems/ruby-1.9.1-p378/gems/paperclip-2.3.2/lib/paperclip/railtie.rb:3:in `<top (required)>' |
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
# you can turn two tests into one if you are testing almost the same thing | |
# example | |
before(:each) do | |
@project = Project.new | |
end | |
it "should contain errors on a blank url" do | |
@project.save | |
@project.errors.should include({:url=>["can't be blank"]}) | |
end |
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
# you can turn two tests into one if you are testing almost the same thing | |
# example | |
before(:each) do | |
@project = Project.new | |
end | |
it "should contain errors on a blank url" do | |
@project.save | |
@project.errors.should include({:url=>["can't be blank"]}) | |
end |
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
require "benchmark" | |
N = 1_000_000 | |
Benchmark.bmbm do |sample| | |
HAYSTACK = "qqq100601.txt" | |
PATTERN = /\A([a-z]+)/ | |
raise unless HAYSTACK[PATTERN, 1] == HAYSTACK.match(PATTERN)[0] |
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
n.times { doc.add_text(msg) } |
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
By elasped time | |
+-------------------------+-----------+-----+------+-------+--------+-----------+-----------+ | |
| Name | Start Mem | 100 | 1000 | 10000 | 100000 | Final Mem | Time | | |
+-------------------------+-----------+-----+------+-------+--------+-----------+-----------+ | |
| ali_rizvi | 4896 | 100 | 804 | 10452 | 121132 | 126028 | 1.006372 | | |
| ali_rizvi_fixed | 4896 | 100 | 944 | 11100 | 121868 | 126764 | 1.214406 | | |
| ali_rizvi_fixed_inc | 4896 | 100 | 948 | 11100 | 121868 | 126764 | 1.265896 | | |
| alberto_fernandez_capel | 4896 | 104 | 396 | 4124 | 37372 | 42268 | 4.254412 | | |
| tim_liner | 4896 | 104 | 288 | 4836 | 35284 | 40180 | 18.820256 | | |
| walton_hoops | 4896 | 108 | 536 | 5524 | 36592 | 41488 | 23.587876 | |
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
By elasped time | |
+---------------------------+-----------+-----+------+-------+--------+-----------+-----------+ | |
| Name | Start Mem | 100 | 1000 | 10000 | 100000 | Final Mem | Time | | |
+---------------------------+-----------+-----+------+-------+--------+-----------+-----------+ | |
| ricardo_mendes_refactored | 10292 | 20 | 20 | 696 | 4420 | 14712 | 0.228459 | | |
| ali_rizvi | 10784 | 56 | 404 | 2568 | 31824 | 42608 | 0.323051 | | |
| ali_rizvi_fixed_inc | 9380 | 44 | 236 | 2096 | 32744 | 42124 | 0.370307 | | |
| ali_rizvi_fixed | 10048 | 56 | 428 | 2092 | 32100 | 42148 | 0.371651 | | |
| alberto_fernandez_capel | 10764 | 36 | 364 | 888 | 6288 | 17052 | 0.618822 | | |
| tj_singleton_refactored | 8232 | 20 | 300 | 828 | 16676 | 24908 | 0.733384 | |
OlderNewer