- Buy a domain and map a
CNAME
to your Heroku app. Usewww.example.com
, notexample.com
- Register to Uptime Robot and set up a monitor on your website (keeps dyno alive!)
- Use Unicorn as the Webserver
- Add the Heroku add-on PG Backups with automatic backups and monthly retention
- Install NewRelic (provision the add-on and skip to the Ruby section)
- Add SPF and DKIM records to your Mandrill account if you send email with @yourdomain.com
- If your website uses Devise, buy a SSL certificate and set it up to get a
https://
URL. Otherwise passwords are in cl
task :outdated => :environment do | |
include ActionView::Helpers::DateHelper | |
regexp = /\* ([^ ]+) \((\S+) > ([^)]+)\)/ | |
outdated = `bundle outdated`.scan(regexp) | |
outdated.each do |gem_name, available, current| | |
data = JSON.parse(`curl --silent https://rubygems.org/api/v1/versions/#{gem_name}.json`) | |
version = data.find { |e| e['number'] == current } | |
age = distance_of_time_in_words_to_now(Time.parse(version['built_at'])) | |
puts " * #{gem_name}: (#{available} > #{current}, built #{age} ago)" | |
end |
module.exports = function(grunt) { | |
grunt.loadNpmTasks('grunt-contrib-connect'); | |
grunt.loadNpmTasks('grunt-contrib-watch'); | |
grunt.loadNpmTasks('grunt-contrib-sass'); | |
// don't watch node_modules | |
// used in watch files below | |
var excludes = [ | |
'!**/node_modules/**' |
# Original Rails controller and action | |
class EmployeesController < ApplicationController | |
def create | |
@employee = Employee.new(employee_params) | |
if @employee.save | |
redirect_to @employee, notice: "Employee #{@employee.name} created" | |
else | |
render :new | |
end |
class Users::RegistrationsController < Devise::RegistrationsController | |
before_action :configure_permitted_parameters | |
# Handles editing when provider is facebook | |
def update_resource(resource, params) | |
if current_user.provider == "facebook" | |
params.delete("current_password") | |
resource.update_without_password(params) | |
else | |
resource.update_with_password(params) |
# Elixir has pipes `|>`. Let's try to implement those in Ruby. | |
# | |
# I want to write this: | |
# | |
# email.body | RemoveSignature | HighlightMentions | :html_safe | |
# | |
# instead of: | |
# | |
# HighlightMentions.call(RemoveSignature.call(email.body)).html_safe | |
# |
# In controller | |
result = TaxCalculator.new(order).call | |
if result[:success] | |
render json: { value: result[:value] } | |
else | |
render json: { errors: result[:errors] }, status: 422 | |
end | |
# The service | |
class TaxCalculator |
namespace :db do | |
desc "Backs up heroku database and restores it locally." | |
task import_from_heroku: [ :environment, :create ] do | |
HEROKU_APP_NAME = nil # Change this if app name is not picked up by `heroku` git remote. | |
c = Rails.configuration.database_configuration[Rails.env] | |
heroku_app_flag = HEROKU_APP_NAME ? " --app #{HEROKU_APP_NAME}" : nil | |
Bundler.with_clean_env do | |
puts "[1/4] Capturing backup on Heroku" | |
`heroku pg:backups capture DATABASE_URL#{heroku_app_flag}` |
#cargo, docker hub without docker, how to
18 Jan 2015
###Background
I have been using linux containers for almost 2 years now. It started during an internship at Applidget, a startup in Paris. My job was to integrate linux containers technology in their private PaaS. At this time, there where no doubt, the technology to use was LXC. One week or so after I started digging into LXC, one of my co-worker talked to me about this new thing called docker. He told me "isn't it what you are supposed to do during your internship ?". And it was kind of it.
At this time I already highlighted a big challenge of containers in PaaS: creation time. Waiting for bundle install
to complete is already long enough to have to wait for another 40 secondes to create a container :). Docker landed just in time !