Skip to content

Instantly share code, notes, and snippets.

View ssaunier's full-sized avatar

Sébastien Saunier ssaunier

View GitHub Profile
@ssaunier
ssaunier / Gemfile
Last active December 24, 2015 21:19
Prevent stubbing nonexistant method with rspec-fire and rspec-mocks. Discussed at http://sebastien.saunier.me/blog/2013/10/06/on-testing.html
source 'https://rubygems.org'
ruby "2.0.0"
gem "rspec"
gem "rspec-mocks"
gem "rspec-fire"
@ssaunier
ssaunier / mandrill_api_mailer.rb
Created October 16, 2013 10:26
Mandril API Mailer used by http://www.mobicheckin.com for Mailing campaigns.
# Copyright: Applidget - 2013
# License: MIT
# Author: Sébastien Saunier (@ssaunier)
require "mandrill"
class MandrillApiMailer
def initialize(key = nil)
key ||= ENV['MANDRILL_PASSWORD']
@ssaunier
ssaunier / mobicheckin_room_booking.rb
Last active December 25, 2015 18:49
Using MobiCheckin API to create 210 check-in points representing a time and room to be booked.
#!/usr/bin/env ruby
# Usage: MOBICHECKIN_API_TOKEN=#### MOBICHECKIN_EVENT_ID=##### ./rooms.rb
require "rubygems"
require "httparty"
class MobiCheckin
include HTTParty
# base_uri "localhost:5000/api/v1"
base_uri "https://app.mobicheckin.com/api/v1"
@ssaunier
ssaunier / heroku-CVE-2013-4164.rb
Last active December 29, 2015 04:09
On Saturday November 23rd, 2013, Heroku sent an email about CVE-2013-4164 to tell us to upgrade. Here is a script listing vulnerable apps.
#!/usr/bin/env ruby
#
# To simply run this script from your terminal:
# $ ruby -e "$(curl -fsSL https://gist.github.com/ssaunier/7612827/raw/heroku-CVE-2013-4164.rb)"
#
# From Heroku email, you must upgrade your ruby version to:
#
# New: ruby 1.8.7p375 (2013-11-22 revision 375) [x86_64-linux]
# New: ruby 1.9.2p321 (2013-11-22 revision 321) [x86_64-linux]
# New: ruby 1.9.3p484 (2013-11-22 revision 43786) [x86_64-linux]
@ssaunier
ssaunier / so_colissimo_iframe.php
Last active January 2, 2016 05:29
Simple snippet of PHP iframe to put in your website to integrate So Colissimo.
<?php
// To be included in iframe 1100x550
// Config from https://www.colissimo.fr/pudo-bo/configuration.htm
$front_office_identifier = 'YOUR_ID';
$crypt_key = 'YOUR_KEY';
// Form input fields. Order is important (for signature), do not change
$inputs = [
class IntegerFormatter
def with_commas(integer)
quotient = integer / 1000
remainder = integer % 1000
if quotient == 0
remainder.to_s
else
prepend = with_commas(quotient)
"#{prepend},#{"%03d" % remainder}"
@ssaunier
ssaunier / git-pre-push-hook-install.sh
Last active June 9, 2018 02:51
Hook to rub rspec and karma before each `git push`. Can be bypassed with `git push --no-verify`
cd /path/to/your/repo
curl https://gist.github.com/ssaunier/8704755/raw/pre-push.sh > .git/hooks/pre-push
chmod u+x .git/hooks/pre-push
@ssaunier
ssaunier / embedded_video_helper.rb
Created February 26, 2014 19:04
Youtube embed video Helper
require "uri"
require "cgi"
class ApplicationHelper
def embedded_video(url, options = {})
if url
# TODO: Handle other sources than Youtube video
params = CGI::parse(URI.parse(url).query || "")
if params["v"]
embedded_url = "//www.youtube.com/embed/#{params["v"].first}"
@ssaunier
ssaunier / minitest_rake_runner.rb
Created March 22, 2014 19:43
A rake runner for minitest, capturing the outcome of the test
# app/services/minitest_rake_runner.rb
require 'open3'
class MinitestRakeRunner
attr_reader :stdout_lines
class RakefileMissingError < StandardError; end
PATTERN = /(?<tests>\d+) (tests|runs), (?<assertions>\d+) assertions, (?<failures>\d+) failures, (?<errors>\d+) errors, (?<skips>\d+) skips/

Keybase proof

I hereby claim:

  • I am ssaunier on github.
  • I am ssaunier (https://keybase.io/ssaunier) on keybase.
  • I have a public key ASCsw5K7-RA-3BDEFl9tlnCPXVIbO_Z8-lOaSAxT6u-pBgo

To claim this, I am signing this object: