Skip to content

Instantly share code, notes, and snippets.

View motdotla's full-sized avatar
🏆

Mot motdotla

🏆
View GitHub Profile
namespace :cron do
task :start, :roles => :app, :only => {:cron => true} do
cron_tab = "#{shared_path}/cron.tab"
run "mkdir -p #{shared_path}/log/cron"
require 'erb'
template = File.read("config/cron.erb")
file = ERB.new(template).result(binding)
put file, cron_tab, :mode => 0644
username: [email protected] # or for google apps: [email protected]
password: dude123
host: imap.gmail.com
port: 993
Rails::Initializer.run do |config|
...
config.gem "lockfile"
config.gem "tmail"
...
end
task :each_minute => :environment do
chore("Each minute") do
# big thanks to
# require rails environment file which basically "boots" up rails for this script
require File.join(File.dirname(__FILE__), '..', '..', 'config', 'environment')
require 'net/imap'
require 'net/http'
begin
Lockfile.new('cron_mail_fetcher.lock', :retries => 0) do
rake email:invitations RAILS_ENV=production
class Video < ActiveRecord::Base
# Paperclip
# http://www.thoughtbot.com/projects/paperclip
has_attached_file :video,
:storage => :s3,
:s3_credentials => "#{RAILS_ROOT}/config/s3.yml",
:path => ":attachment/:id/:style/:basename.:extension",
:bucket => 'yourbucketname'
access_key_id: YOURSECRETACCESSID
secret_access_key: YOUR-secRE/TACCe\ssKEy
class VideosController < ApplicationController
def index
@videos = Video.find :all
end
def new
@video = Video.new
end
Rails::Initializer.run do |config|
...
config.gem 'right_aws', :version => '1.9.0'
...
end
<head>
<meta http-equiv="content-type" content="text/html;charset=UTF-8" />
<title><%= SITE_NAME %></title>
<%= stylesheet_link_tag 'application' %>
<%= javascript_include_tag :defaults %>
<%= javascript_include_tag 'swfobject' %>
</head>