This file contains hidden or 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
| t = 236 # seconds | |
| Time.at(t).utc.strftime("%H:%M:%S") | |
| => "00:03:56" | |
| # Reference | |
| # http://stackoverflow.com/questions/3963930/ruby-rails-how-to-convert-seconds-to-time |
This file contains hidden or 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 'yajl' | |
| module Rack | |
| # A Rack middleware for parsing POST/PUT body data when Content-Type is | |
| # <tt>application/json</tt>. | |
| # | |
| class JsonPostBody |
This file contains hidden or 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
| after "deploy:symlink", "deploy:restart_workers" | |
| ## | |
| # Rake helper task. | |
| # http://pastie.org/255489 | |
| # http://geminstallthat.wordpress.com/2008/01/27/rake-tasks-through-capistrano/ | |
| # http://ananelson.com/said/on/2007/12/30/remote-rake-tasks-with-capistrano/ | |
| def run_remote_rake(rake_cmd) | |
| rake_args = ENV['RAKE_ARGS'].to_s.split(',') | |
| cmd = "cd #{fetch(:latest_release)} && #{fetch(:rake, "rake")} RAILS_ENV=#{fetch(:rails_env, "production")} #{rake_cmd}" |
This file contains hidden or 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
| ... | |
| gem 'devise', | |
| :git => 'https://github.com/plataformatec/devise.git', | |
| :branch => 'omniauth' | |
| gem 'oa-oauth', :require => 'omniauth/oauth' | |
| ... |
This file contains hidden or 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
| module Paperclip | |
| class AutoOrient < Paperclip::Processor | |
| def initialize(file, options = {}, *args) | |
| @file = file | |
| end | |
| def make( *args ) | |
| dst = Tempfile.new([@basename, @format].compact.join(".")) | |
| dst.binmode | |
This file contains hidden or 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 PagesController < ApplicationController | |
| before_filter :login_required, :except => [ :show ] | |
| # GET /pages | |
| # GET /pages.xml | |
| def index | |
| @pages = Page.find(:all) | |
| respond_to do |format| | |
| format.html # index.html.erb |