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
$ irb | |
ruby-1.9.2-p180 :001 > Time.now | |
=> 2012-01-01 00:00:00 -0600 |
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
# | |
# Not currently dynamic for a i18n file -- it spits out "en/txt and en/errors" | |
# | |
require 'cgi' | |
require 'yaml' | |
require 'httparty' | |
@strings = YAML.load(File.read("")).to_hash | |
@api_key = '' |
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
## | |
# Benefits: plain text that can be discussed amongst stakeholders, | |
# repeatable "steps", Gherkin syntax to define state, more... | |
## | |
Feature: Manage Articles | |
In order to make a blog | |
As an author | |
I want to create and manage articles |
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 Device | |
include HTTParty | |
attr_accessor :mobile_device, :touch, :device_model, | |
:device_brand, :ua, :device_os, :bb_info, :properties, :mp4, :h264, :stream | |
def initialize(ua) | |
if ua.class == Hash | |
ua.each do |k, v| | |
send("#{k}=", v) |
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
require 'rubygems' | |
require 'aws/s3' | |
# Change the access key and secret to your amazon credentials | |
AWS::S3::Base.establish_connection!( | |
:access_key_id => 'ACCESS_KEY_ID', | |
:secret_access_key => 'SECRET' | |
) | |
# Change this to your S3 bucket name | |
WEBSITE_BUCKET_NAME = "YOUR_BUCKET_NAME" |
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
# Bundler output | |
-----> Heroku receiving push | |
-----> Ruby/Rails app detected | |
-----> Installing dependencies using Bundler version 1.1.pre.5 | |
Running: bundle install --without development:test --path vendor/bundle --deployment | |
Fetching dependency information from the API at http://rubygems.org/....... | |
Could not find fastercsv-1.5.4 in any of the sources | |
! | |
! Failed to install gems via Bundler. |
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
def force_ssl | |
pages = {"giving" => ["login", "give"]} | |
pages.each do |controller, actions| | |
if params[:controller] == controller && actions.include?(params[:action]) | |
if !request.ssl? && !Rails.env.development? | |
redirect_to :protocol => 'https://', :status => :moved_permanently | |
end | |
elsif request.ssl? | |
redirect_to :protocol => 'http://', :status => :moved_permanently | |
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
while Time.now.to_i < 1306476537 | |
puts "not time yet...\n" | |
sleep 120 | |
end | |
system "heroku db:push --tables search_terms --confirm myapp" |
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
Item.all.each {|item| item.update_attributes(description: Nokogiri::HTML(item.description).xpath("//text()").remove.to_s) } |
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
$ geocode Oklahoma City, OK | |
Latitude: 35.4675602 | |
Longitude: -97.5164276 | |
Full address: Oklahoma City, OK, USA | |
City: Oklahoma City | |
State/province: Oklahoma | |
Postal code: | |
Country: United States | |
Google map: http://maps.google.com/maps?q=35.4675602,-97.5164276 |