Skip to content

Instantly share code, notes, and snippets.

View taylorbrooks's full-sized avatar

Taylor Brooks taylorbrooks

  • Simple
  • Austin, TX
View GitHub Profile
{
"id": 4567,
"date": "2010-10-04",
"title": "Christian Hedonism",
"description": "short description",
"type": "sermon", // sermon, article, book
"format": "audio", // audio, video, text
"file_url": "http://aws.amazon.com/john_piper/sermons/2010-10-04.mp3",
"tag_ids": [234, 456, 678],
"bookmarks": [
@taylorbrooks
taylorbrooks / screenshot.py
Last active August 29, 2015 14:02
Screenshots
import subprocess
from urlparse import urlparse
from pngquant import tiny
def webkit2png(name, site):
subprocess.call(['webkit2png', '-F', '-W', '1440', '-D', 'screenshots', '-o', name, site])
sites = []
for site in sites:
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:3710800
Created September 12, 2012 23:40
Parsing CSVs
# Finds CSV file
csv = File.open('lib/contacts.csv')
# Opens CSV to read rows
CSV.read(csv, headers: true).each do |row|
# Finds the churches that haven't been contacted
if row[4] != 'x'
puts "#{row.inspect}"
end
@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