Skip to content

Instantly share code, notes, and snippets.

View ssaunier's full-sized avatar

Sébastien Saunier ssaunier

View GitHub Profile
@ssaunier
ssaunier / application.html.erb
Last active August 29, 2015 14:09
Google maps footer
<!-- app/views/layouts/application.html.erb -->
<!-- [...] -->
<script src="//maps.google.com/maps/api/js?sensor=false" type="text/javascript"></script>
<script src="//google-maps-utility-library-v3.googlecode.com/svn/tags/markerclustererplus/2.0.14/src/markerclusterer_packed.js" type="text/javascript"></script>
<%= javascript_include_tag "application" %>
<%= yield(:js) %>
</body>
@ssaunier
ssaunier / Gemfile
Created November 19, 2014 15:26
Sass environment for rails developer
source "https://rubygems.org"
@ssaunier
ssaunier / heroku-checklist.md
Last active March 22, 2018 08:03
Heroku Checklist
  • Buy a domain and map a CNAME to your Heroku app. Use www.example.com, not example.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
def sum_odd_indexed(array)
# TODO: computes the sum of elements at odd indices (1, 3, 5, 7, etc.)
# You should make use Enumerable#each_with_index
end
def even_numbers(array)
# TODO: Return the even numbers from a list of integers.
# You should use Enumerable#select
end
def correct?(users_guess,computer_number)
return computer_number == users_guess
end
require 'sinatra'
require 'sinatra/reloader'
require_relative "cookbook"
filename = "recipes.csv"
cookbook = Cookbook.new(filename)
get '/' do
@recipes = cookbook.all
@ssaunier
ssaunier / upgrade_postgres_93_94.sh
Created February 7, 2015 10:11
Postgresql - Upgrade from 9.3 to 9.4 on Mac OSX with HomeBrew
pkill -f rails
launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
brew update
brew upgrade postgresql
initdb /usr/local/var/postgres9.4 -E utf8
pg_upgrade -v \
-d /usr/local/var/postgres \
-D /usr/local/var/postgres9.4 \
-b /usr/local/Cellar/postgresql/9.3.5_1/bin/ \
-B /usr/local/Cellar/postgresql/9.4.1/bin/
@ssaunier
ssaunier / install.sh
Last active June 22, 2016 21:42
Prepare Rails app for Heroku with Puma
echo "web: bundle exec puma -C config/puma.rb" > Procfile
curl -L https://gist.githubusercontent.com/ssaunier/24bc1c4db955c19e3289/raw/puma.rb > config/puma.rb
@ssaunier
ssaunier / hello_sign_webhooks_controller.rb
Last active August 29, 2015 14:17
Respond to HelloSign callback (or webhook) from within a Rails application - https://www.hellosign.com/api/eventsAndCallbacksWalkthrough
# app/controllers/hello_sign_webhooks_controller.rb
require 'openssl' unless defined?(OpenSSL)
class HelloSignWebhooksController < ApplicationController
class InvalidSignature < StandardError; end
before_action :parse_params
before_action :check_event_hash!
def create
@ssaunier
ssaunier / redis_cloud_heroku_cli.rb
Created August 2, 2015 10:58
Connect to Heroku RedisCloud as `redis-cli`
#!/usr/bin/env ruby
url_matcher = %r{REDISCLOUD_URL:\s*redis://rediscloud:(\w+)@([\w\-.]+):(\d+)}
env_string = `heroku config | grep REDISCLOUD_URL`
env_settings = env_string.split('\n')
match_data = url_matcher.match(env_settings[0])
db = ARGV[0] || 0