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
packages: | |
yum: | |
python26: [] |
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
# | |
# Usage: | |
# sms = SMS.new('+1XXXXXX', 'Message') | |
# sms = SMS.new('+1XXXXXX', 'Message', :full_sms_queue, :invalid) | |
# sms.data - results in hash | |
# | |
class SMS | |
def initialize(number, message, from_error=nil, to_error=nil) | |
@client = SMS.client | |
send_sms(number, message, from_error, to_error) |
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 Api::V1::SessionsController < Api::V1::BaseController | |
skip_before_filter :verify_authenticity_token, only: :create | |
skip_before_filter :authenticate_user!, only: :create | |
before_filter :ensure_params_exist, only: :create | |
before_filter :ensure_token_exist, only: :destroy | |
def create | |
resource = User.find_for_database_authentication(email: params[:user][:email]) | |
return invalid_login_attempt unless resource |
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
#Session controller provides a token | |
#/controllers/api/sessions_controller.rb | |
class Api::SessionsController < Devise::SessionsController | |
before_filter :authenticate_user!, :except => [:create] | |
before_filter :ensure_params_exist, :except => [:destroy] | |
respond_to :json | |
def create | |
resource = User.find_for_database_authentication(:email => params[:user_login][:email]) | |
return invalid_login_attempt unless resource |
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
$ cd /usr/src | |
$ wget http://nginx.org/download/nginx-0.8.52.tar.gz | |
$ tar xzvf ./nginx-0.8.52.tar.gz | |
$ rm ./nginx-0.8.52.tar.gz | |
$ gem install s3sync capistrano capistrano-ext passenger --no-ri --no-rdoc | |
$ passenger-install-nginx-module | |
# Automatically download and install Nginx? 2. No: I want to customize my Nginx installation | |
# Where is your Nginx source code located?: /usr/src/nginx-0.8.52 | |
# Where do you want to install Nginx to?: /opt/nginx |
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
Paperclip.interpolates(:s3_eu_url) { |attachment, style| | |
"#{attachment.s3_protocol}://s3-eu-west-1.amazonaws.com/#{attachment.bucket_name}/#{attachment.path(style).gsub(%r{^/}, "")}" | |
} | |
require 'aws/s3' | |
AWS::S3::DEFAULT_HOST.replace "s3-eu-west-1.amazonaws.com" |
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
# include at least one source and the rails gem | |
source :gemcutter | |
gem 'rails', '~> 2.3.5', :require => nil | |
gem 'sqlite3-ruby', :require => 'sqlite3' | |
# Devise 1.0.2 is not a valid gem plugin for Rails, so use git until 1.0.3 | |
# gem 'devise', :git => 'git://github.com/plataformatec/devise.git', :ref => 'v1.0' | |
group :development do | |
# bundler requires these gems in development |
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 ConvertImagesToPaperclip < ActiveRecord::Migration | |
include PaperclipMigrations | |
def self.up | |
# Paperclip | |
add_column :images, :data_file_name, :string | |
add_column :images, :data_content_type, :string | |
add_column :images, :data_file_size, :integer | |
add_column :images, :data_updated_at, :datetime |
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
# part of config/enviroment.rb | |
... | |
Rails::Initializer.run do |config| | |
# Load model files from sub folders | |
config.load_paths += Dir["#{RAILS_ROOT}/app/models/*"].find_all { |f| File.stat(f).directory? } | |
# Load middleware - initially used by flash-session-hack | |
config.load_paths << "#{RAILS_ROOT}/app/middleware" |
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
module ApplicationHelper | |
# Access Levels | |
ACCESS_LEVELS = { :private => 0, :friends => 1, :public => 2 } | |
# Access levels i18n translation | |
def access_levels | |
ACCESS_LEVELS.collect{|k,v| [I18n.t("access." + k.to_s), v]} | |
end | |
end |
NewerOlder