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
### meta magic boolean attributes | |
def self.attr_boolean(attr_name) | |
class_eval(<<-CODE, __FILE__, __LINE__) | |
def #{attr_name}=(#{attr_name}) | |
@#{attr_name} = !!(/^1|true$/i =~ #{attr_name}) # yes, we need a boolean | |
end | |
def #{attr_name} | |
@#{attr_name} | |
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
<h1>Listing topics</h1> | |
<table> | |
<tr> | |
<th> </th> | |
<th>Votes</th> | |
<th>Title</th> | |
<th>Description</th> | |
</tr> |
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
# put at top of test_helper.rb | |
require 'yaml' | |
Dir[File.expand_path(File.join(File.dirname(__FILE__), "fixtures/**/*.yml"))].each do |f| | |
begin | |
YAML.load_file(f) | |
rescue StandardError => e | |
puts "!!!!! YAML parse error in file: #{f}" | |
puts e.message | |
exit 1 |
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
[jruby:1.4.0RC1] potrero:tracker pivotal$ jruby -S gem uninstall twitter | |
Successfully uninstalled twitter-0.6.14 | |
[jruby:1.4.0RC1] potrero:tracker pivotal$ jruby -S geminstaller | |
Invoking gem install for mongrel, version 1.1.5. | |
Invoking gem install for nokogiri, version 1.3.3. | |
Invoking gem install for twitter, version 0.6.14. | |
[RubyGems:stderr] ERROR: Error installing twitter: | |
ERROR: Failed to build gem native extension. | |
/Users/pivotal/.rvm/jruby-1.4.0RC1/bin/jruby extconf.rb |
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
module Comparable | |
def min(*values) | |
(values << self).min | |
end | |
def max(*values) | |
(values << self).max | |
end | |
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
nkallen_: nkallen_: anyway, i want to stress that we basically agree about things so i want to be sure that the tone of the blog post is such | |
[7:25pm] nkallen_: [7:17pm] nkallen_: i would argue that what you do in rails 3 (according to these tweets I've read) | |
[7:25pm] nkallen_: [7:17pm] nkallen_: is exactly what I propose... this is just how one might do it in Ruby | |
[7:25pm] nkallen_: [7:18pm] nkallen_: but my point is conceptual and not about ruby | |
[7:25pm] nkallen_: [7:18pm] nkallen_: it applies to every oo language and also I might argue to functional languages | |
[7:25pm] nkallen_: [7:18pm] nkallen_: which is to structure a program around the ability to layer on enhanced functionality and ensure that no assumptions are hardcoded by abstracting over the manufacture of objects | |
[7:25pm] nkallen_: [7:19pm] nkallen_: in the literature, these techniques are called DI, decorators, and factories. | |
[7:25pm] nkallen_: [7:20pm] nkallen_: i like these terms because they reflect the concepts that are at work. because ruby m |
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
gem list | cut -f 1 -d " " | xargs -E gem gem dep -R $gem | grep -v "^ \w" | grep -P "^[^\s][^\n]+\n[^ ]" -o | grep -v "^$" | sort | cut -f 2 -d " " |
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
<!DOCTYPE HTML> | |
<html> | |
<head> | |
<script src="javascripts/jquery.js" type="text/javascript"></script> | |
<script src="javascripts/handlebars.js" type="text/javascript"></script> | |
<script id="main" type="text/html"> | |
<ul> | |
{{#people}} | |
<li>{{> link}}</li> |
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
alias bo="env EDITOR=mate bundle open $*" |
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
# reset tables | |
tables = ActiveRecord::Base.connection.tables | |
tables.delete("schema_migrations") | |
tables.each do |table| | |
ActiveRecord::Base.connection.execute("TRUNCATE TABLE #{table}") | |
ActiveRecord::Base.connection.reset_pk_sequence!(table) | |
end | |
# seed data | |
# |