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
Note: | |
This is the bare minimum to get hbase, pig, and JRuby talking. Follow the link for further configs. | |
brew doctor | |
brew install hadoop | |
brew install hbase | |
brew install pig | |
in your .zshrc (or .bash_profile if you insist on BASH) |
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
class Comment < ActiveRecord::Base | |
attr_accessible :subject, :body, :category, :reply_to | |
belongs_to :user | |
has_many :replies, :class_name => 'Comment', | |
:foreign_key => 'reply_to' | |
has_many :tags | |
scope :root, -> { where("reply_to = ?", 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
cd /tmp | |
wget ftp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p327.tar.gz | |
tar -xvzf ruby-1.9.3-p327.tar.gz | |
cd ruby-1.9.3-p327 | |
./configure | |
make | |
make install | |
echo "gem: --no-ri --no-rdoc" >> ~/.gemrc | |
source ~/.bashrc |
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
var App = Ember.Application.create(); | |
//Router | |
App.Router.map(function () { | |
this.resource('tables'); | |
}); | |
App.TablesRoute = Ember.Route.extend({ | |
model: function () { | |
return App.Table.find(); |
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
class RockScore | |
NoScore = Class.new | |
def self.for_term(term) | |
positive = SearchEngine.count_results(%{"#{term} rocks"}).to_f | |
negative = SearchEngine.count_results(%{"#{term} sucks"}).to_f | |
score = 10 * positive / (positive + negative) | |
score.nan? ? NoScore : score | |
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
call pathogen#runtime_append_all_bundles() | |
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" BASIC EDITING CONFIGURATION | |
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
set nocompatible | |
" allow unsaved background buffers and remember marks/undo for them | |
set hidden | |
" remember more commands and search history | |
set history=10000 |
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
names = ['Last, First M', 'Last,First!@#$'] | |
def word_after_comma | |
/(?<=[,])(\s?)(\w*)/ | |
end | |
first_names = names.map { |x| x.slice(word_after_comma).strip } | |
#=> ["First", "First"] |
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
path = "#{Rails.root}/config/mysweetconfig.yml" | |
configfile = YAML.load_file(path)[Rails.env] | |
MySweetModule::MySweetClass.setup do |config| | |
config.host = configfile['host'] | |
config.port = configfile['port'] | |
config.database = configfile['database'] | |
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
config = YAML.load_file(path) | |
# => {"ip" => "0.0.0.0", "port" => "3000"} | |
# each_with_object for 1.9+ | |
config.each_with_object({}) { |(k,v),memo| memo[k.to_sym] = v } | |
# => {:ip=>"0.0.0.0", :port=>"3000"} | |
# inject for 1.8 | |
config.inject({}){ |memo,(k,v)| memo[k.to_sym] = v; memo } | |
# => {:ip=>"0.0.0.0", :port=>"3000"} |
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
class AddHstoreExtension < ActiveRecord::Migration | |
def up | |
execute 'CREATE EXTENSION hstore' | |
end | |
def down | |
execute 'DROP EXTENSION hstore' | |
end | |
end |
OlderNewer