Skip to content

Instantly share code, notes, and snippets.

View ssaunier's full-sized avatar

Sébastien Saunier ssaunier

View GitHub Profile
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)
@apneadiving
apneadiving / before.rb
Last active August 29, 2015 14:07
The before is some standard code, `with_waterfall` presents another way to write it (fully chainable)
# 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

#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 !

@benpickles
benpickles / minify
Created January 4, 2011 21:17
Swiftly concat and minify JavaScript files from the command line
#!/usr/bin/env ruby
dry_run = ARGV.delete('--dry-run')
force = ARGV.delete('--force')
if ARGV.empty?
puts <<-USAGE
minify, swiftly concat and minify JavaScript files from the command line
Pass a single argument to create a .min.js version:
@jpmckinney
jpmckinney / twitter.add_self_to_list.rb
Created June 1, 2011 23:33
Add yourself to your Twitter list
# blog post: http://blog.slashpoundbang.com/post/6087617126/how-to-add-yourself-to-your-own-twitter-list
#!/usr/bin/env ruby
require 'twitter'
# Replace the four strings below with your own values.
Twitter.configure do |config|
config.consumer_key = 'CONSUMER_KEY'
config.consumer_secret = 'CONSUMER_SECRET'
config.oauth_token = 'OAUTH_TOKEN'
config.oauth_token_secret = 'OAUTH_TOKEN_SECRET'
@happy15
happy15 / gist:2179728
Created March 24, 2012 07:40
wired benchmark: cuba vs sinatra
simple.rb
=========
require 'sinatra'
use Rack::CommonLogger
get '/' do
'hello'
end
@fourseven
fourseven / retina-sprites.css.scss
Created August 16, 2012 09:19
A compass function to handle spriting with normal and retina images automatically.
// @Mixin Retina Sprite Sass
// ======================================================
// This requires two folders full of *.png files, normal and then
// 2x resolution. Please ensure that they have the same number and names
// of files.
// I've written this based off other efforts on the web, but none did
// both background-images and a set of sprites automatically.
// Still very much a work in progress.
// To use see the bottom three lines.
anonymous
anonymous / imagemagick_brew.sh
Created December 19, 2012 11:49
How to downgrade imagemagick with brew if you have issues with rmagick gem
brew uninstall imagemagick
cd /usr/local/Cellar
git checkout 834ce4a /usr/local/Library/Formula/imagemagick.rb
brew install imagemagick
@nicolasblanco
nicolasblanco / gist:5684809
Last active December 17, 2015 22:49
The gems I use on almost all my projects (because today is Friday... if you know what I mean)

The gems I use on almost all my projects (because today is Friday... if you know what I mean)

  • kaminari

    Great pagination gem. I like writing my custom paginators as partials instead of Ruby classes.

  • rails_config

Even if there's "rails" in the name, this gem also works with other frameworks. Essential to have a global configuration object available everywhere in your app. I like the fact that it is environment-aware.

@thbar
thbar / proby
Last active December 18, 2015 01:38 — forked from jwood/proby
#!/bin/bash
#
# This script surrounds the command passed in with start and finish notifications
# to the Proby task monitoring application.
#
# Note thbar: this version is modified to properly handle errors when they happen,
# since the original version always returned a success.
#
# === SETUP
#