Skip to content

Instantly share code, notes, and snippets.


Troy Anderson theinventor

View GitHub Profile
View api.rb
def unsubscribe
token = Base64.decode64(params[:token]) #using base64 encoding in the url to prevent unsubscribe abuse
@user = User.find_by_access_token(token) #find the user from the ID in url
@user.opt_out = true #change them to not get email #save the changes
redirect_to "/", :notice => "We won't bug you with emails!" #give them a little notice that it worked
View en-GB.yaml
- Sun
- Mon
- Tue
- Wed
- Thu
- Fri
- Sat
View gist:3194027
2012-07-28T17:05:43+00:00 app[web.1]: [2012-07-28 10:05:43] INFO WEBrick 1.3.1
2012-07-28T17:05:43+00:00 app[web.1]: [2012-07-28 10:05:43] INFO ruby 1.9.2 (2011-07-09) [x86_64-linux]
2012-07-28T17:05:43+00:00 app[web.1]: [2012-07-28 10:05:43] INFO WEBrick::HTTPServer#start: pid=2 port=49545
2012-07-28T17:05:44+00:00 heroku[web.1]: State changed from starting to up
2012-07-28T17:05:46+00:00 app[web.1]: => Booting WEBrick
2012-07-28T17:05:46+00:00 app[web.1]: => Rails 3.2.6 application starting in production on
2012-07-28T17:05:46+00:00 app[web.1]: => Call with -d to detach
2012-07-28T17:05:46+00:00 app[web.1]: => Ctrl-C to shutdown server
2012-07-28T17:05:46+00:00 app[web.1]:
2012-07-28T17:05:46+00:00 app[web.1]:
View gist:3201730
Troys-MacBook-Pro:BackOffice troy$ b rake assets:precompile --trace
/Users/troy/.rvm/gems/ruby-1.9.3-p0@threetwo/gems/prawn-core-0.8.4/lib/prawn/core.rb:34: warning: already initialized constant VERSION
/Users/troy/.rvm/gems/ruby-1.9.3-p0@threetwo/gems/cloudprint-0.1.2/lib/cloudprint/connection.rb:5: warning: already initialized constant VERIFY_PEER
** Invoke assets:precompile (first_time)
** Execute assets:precompile
/Users/troy/.rvm/rubies/ruby-1.9.3-p0/bin/ruby /Users/troy/.rvm/gems/ruby-1.9.3-p0@threetwo/bin/rake assets:precompile:all RAILS_ENV=production RAILS_GROUPS=assets --trace
/Users/troy/.rvm/gems/ruby-1.9.3-p0@threetwo/gems/prawn-core-0.8.4/lib/prawn/core.rb:34: warning: already initialized constant VERSION
/Users/troy/.rvm/gems/ruby-1.9.3-p0@threetwo/gems/cloudprint-0.1.2/lib/cloudprint/connection.rb:5: warning: already initialized constant VERIFY_PEER
** Invoke assets:precompile:all (first_time)
** Execute assets:precompile:all
View rake_task_template.rake
namespace :some_thingy do
task :my_big_fixer, [:production_run] => :environment do |t, args|
production_run = args[:production_run] == "true"
ap "doing a dry run" unless production_run
my_logger ="#{Rails.root}/log/my_thingy.log")
require 'progress_bar'
bar = # pass the total for the progress bar "Starting at #{}"
theinventor / processing.rb
Created Oct 25, 2012
asset precompile timing per file
View processing.rb
require 'sprockets/engines'
require 'sprockets/mime'
require 'sprockets/processor'
require 'sprockets/utils'
module Sprockets
# `Processing` is an internal mixin whose public methods are exposed on
# the `Environment` and `Index` classes.
module Processing
include Engines, Mime
View thingy.rb
if ad_records.count == 1
ad_record = ad_records.first
ad =
:tagline => ad_record['tag_line'],
:service => service,
:image_url => ad_record['image_external_url'],
:citygrid_ad_id => ad_record['ad_id']
ad.image = => ad_record['image_external_url'], :role => "AD_IMAGE", :url => ad_record['image_external_url'], :format => ad_record['image_external_url'].to_s.split('.').last )
View simple_form_stuff.rb
##In the model:
class Person < ActiveRecord::Base
validates_acceptance_of :terms_of_service
#if using attr_accessible
attr_accessible :name, :etc, :terms_of_service
theinventor / photos_uploaded_per_day.json.jsonify.rb
Last active Dec 18, 2015
Example jsonify builder view for making a nice blob to drive a highcarts widget on geckoboard :)
View photos_uploaded_per_day.json.jsonify.rb
#we populated some @markets sort of like this;
# @results << group[1], color: colors[index], data: [], city_id: group[0])
# later.... each << photos_that_day.to_i
json.chart do
json.type 'column'
json.backgroundColor 'rgba(255, 255, 255, 0.1)' do
json.fontFamily 'monospace'
json.color "#000"
View en-NG.yml
- Sun
- Mon
- Tue
- Wed
- Thu
- Fri
- Sat