Skip to content

Instantly share code, notes, and snippets.

View taylorbrooks's full-sized avatar

Taylor Brooks taylorbrooks

  • Simple
  • Austin, TX
View GitHub Profile
def self.last_12_monthly
start_date = (Time.now - 11.months).beginning_of_month
end_date = Time.now.end_of_month
h = Donation.calculate(:sum, :gross_amount, conditions: {
created_at: (start_date..end_date) },
order: "date_trunc('month', created_at)",
group: ["date_trunc('month', created_at)"])
h = h.to_a.map {|k,v| [k.to_date, v]}
num_of_months = 0..11
m = Hash[(num_of_months.to_a.reverse).map { |month| [month.months.ago.beginning_of_month.to_date, 0]}].merge(Hash[h])
@taylorbrooks
taylorbrooks / gist:3915457
Created October 18, 2012 23:45
heroku deploy
WARNING: Nokogiri was built against LibXML version 2.7.3, but has dynamically loaded 2.7.8
AssetSync: using /Users/taylorbrooks/Documents/Rails/subscriptions/config/initializers/asset_sync.rb
rake aborted!
Invalid CSS after "a ": expected ")", was "[class^="icon-"..."
(in /Users/taylorbrooks/Documents/Rails/subscriptions/app/assets/stylesheets/application.css)
Tasks: TOP => assets:precompile:primary
(See full trace by running task with --trace)
rake aborted!
Command failed with status (1): [/Users/taylorbrooks/.rbenv/versions/1.9.3-...]
@taylorbrooks
taylorbrooks / gist:3107549
Created July 13, 2012 21:19
Error Messages Helper for Bootstrap
# app/helpers/application_helper.rb
def twitterized_type(type)
case type
when :alert
"alert-block"
when :error
"alert-error"
when :notice
"alert-info"
when :success
@taylorbrooks
taylorbrooks / DeliciousScraper.rb
Created April 12, 2012 07:21
Scrape a Delicious Feed and Save the data to a CSV
require 'rubygems'
require 'csv'
require 'json'
require 'net/http'
def scrape(username, tag)
url = "http://www.delicious.com/v2/json/#{username}/#{tag}?count=1000"
resp = Net::HTTP.get_response(URI.parse(url))
data = resp.body
@taylorbrooks
taylorbrooks / .bash_profile
Created September 16, 2011 20:21
Bash Profile
alias rs="rails s"
alias rc="rails c"
alias gco="git checkout"
alias gpl="git pull"
alias gps="git push"
alias gcm="git commit -a -m"
alias cdup="cd ~/Documents/Upstream"
alias cdra="cd ~/Documents/Rails"
alias cdpow="cd ~/.pow"
alias start_redis="cd /usr/local/Cellar/redis/2.2.12/bin && ./redis-server"
~/Documents/speakerwiki[taylor]$ rake ts:config
(in /Users/taylorbrooks/Documents/speakerwiki)
Sphinx cannot be found on your system. You may need to configure the following
settings in your config/sphinx.yml file:
* bin_path
* searchd_binary_name
* indexer_binary_name
For more information, read the documentation:
@taylorbrooks
taylorbrooks / gist:741375
Created December 14, 2010 23:55
config/preinitializer.rb
require 'rubygems'
begin
gem 'i18n', "~> 0.4.0"
rescue LoadError
# no biggie, optional anyway
end
SampleApp::Application.routes.draw do |map|
match "/home" => "pages#home"
match "/contact" => "pages#contact"
match "/about" => "pages#about"
require 'spec_helper'
describe PagesController do
render_views
describe "GET 'home'" do
it "should be successful" do
get 'home'
response.should be_success
end
Finished in 0.05004 seconds
3 examples, 1 failure
1) PagesController GET 'about' should be successful
Failure/Error: get 'about'
No route matches {:controller=>"pages", :action=>"about"}
# /Users/taylorbrooks/.rvm/gems/ruby-1.8.7-p174/gems/actionpack-3.0.0.rc/lib/action_dispatch/routing/route_set.rb:407:in `generate'
# /Users/taylorbrooks/.rvm/gems/ruby-1.8.7-p174/gems/actionpack-3.0.0.rc/lib/action_dispatch/routing/route_set.rb:450:in `generate'
# /Users/taylorbrooks/.rvm/gems/ruby-1.8.7-p174/gems/actionpack-3.0.0.rc/lib/action_dispatch/routing/route_set.rb:446:in `generate_extras'
# /Users/taylorbrooks/.rvm/gems/ruby-1.8.7-p174/gems/actionpack-3.0.0.rc/lib/action_dispatch/routing/route_set.rb:442:in `extra_keys'