Skip to content

Instantly share code, notes, and snippets.

View ssaunier's full-sized avatar

Sébastien Saunier ssaunier

View GitHub Profile
@ssaunier
ssaunier / github_pages_repo.sh
Last active August 29, 2015 14:00
Quickly create a Github Pages repo
# What is your GitHub username? & your project name? Change with your own
GITHUB_USERNAME="ssaunier"
PROJECT_NAME="minesweep"
# We can create GitHub repo from the terminal, with https://github.com/github/hub
# It's really convinient. You can download it with:
brew install hub
# Say you want to work on a minesweep, create the repo:
mkdir -p ~/code/$GITHUB_USERNAME/$PROJECT_NAME && cd $_
@ssaunier
ssaunier / premiere_classe_wufoo.css
Last active August 29, 2015 14:00
External CSS for Premiere Classe Registration form
body {
font-size: 16px;
}
.wufoo li.focused {
background: none;
}
.wufoo input.text, .wufoo textarea.textarea {
background: none !important;
@ssaunier
ssaunier / cities.rb
Created May 10, 2014 07:41
FrenchTech cities
require 'yaml'
require "octokit"
client = Octokit::Client.new :access_token => `cat ~/.gist`
results = {}
# Cities from http://fr.wikipedia.org/wiki/Liste_des_communes_de_France_les_plus_peupl%C3%A9es
cities = File.readlines("cities.txt")
@ssaunier
ssaunier / like.rb
Created June 1, 2014 23:40
User like Postcards
class Like < ActiveRecord::Base
belongs_to :user
belongs_to :postcard
end
@ssaunier
ssaunier / email_parser.rb
Created June 11, 2014 08:49
Email parser
EMAIL_PATTERN = /([^\.@]+)(\.([^@]+))?@([^@]+)/
def parse_email(email)
groups = EMAIL_PATTERN.match(email)
if groups.nil?
raise ArgumentError.new("'#{email}' is not a valid email address")
else
firstname = groups[1]
lastname = groups[3]
email_domain = groups[4]
@ssaunier
ssaunier / subl_as_git_editor.sh
Created July 9, 2014 09:13
Set sublime as the git editor
subl_path=`alias subl | grep -o '\(/[a-zA-Z0-9. ]\+\)\+'`
git config --global core.editor "'$subl_path' -n -w"
@ssaunier
ssaunier / cat.rb
Created October 17, 2014 07:32
cat.rb
class Cat
def initialize(name, color)
@name = name
@color = color
@alive = true
@color_history = [ color ]
end
attr_reader :name, :color, :color_history
@ssaunier
ssaunier / app.rb
Last active August 29, 2015 14:07
Todo Manager - 17 octobre 2014 - Promo 4 de http://www.lewagon.org
require_relative "task_repository"
require_relative "display"
require_relative "controller"
# Creer fausse base de données
task_repository = TaskRepository.new
# Creer un Display
display = Display.new
@ssaunier
ssaunier / mess_up_sum.rb
Created October 30, 2014 18:20
Mess up the sum of your projects!
class Fixnum
def +(other)
self * other
end
end
@ssaunier
ssaunier / db.rake
Last active January 8, 2021 11:46 — forked from abstractcoder/import.rake
Rake task to back up heroku database and restore it locally.
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}`