Skip to content

Instantly share code, notes, and snippets.

View rchampourlier's full-sized avatar

Romain Champourlier rchampourlier

View GitHub Profile
@rchampourlier
rchampourlier / ingredients.rb
Created August 9, 2012 10:20
A Ruby script to download cookbooks from Opscode Community repo or Git using a YAML file to describe required cookbooks
# Script to ease downloading of cookbooks from Opscode repo and Github
# by using a YAML file to describe the necessary cookbooks.
require 'yaml'
require 'fileutils'
script_dir = File.expand_path('.')
cookbooks_dir = File.join(script_dir, 'cookbooks')
archives_dir = File.join(script_dir, 'cookbooks_archives')
@rchampourlier
rchampourlier / Cheffile
Created August 9, 2012 07:50
librarian-chef failing with "Cheffile and Cheffile.lock are out of sync!"
site "http://community.opscode.com/api/v1"
##
# Base
#
cookbook "apt"
cookbook 'build-essential'
cookbook 'git'
@rchampourlier
rchampourlier / jst_haml_assets.rb
Created July 23, 2012 09:53
Sinatra extension to render HAML to JST assets as require.js modules
require 'sinatra/base'
module Sinatra
module JstHamlAssets
module Helpers
def not_found
[404, 'JST Haml template not found']
end
@rchampourlier
rchampourlier / jst_haml_assets.rb
Created July 23, 2012 09:21
Sinatra extension to render HAML to JST assets
require 'sinatra/base'
module Sinatra
module JstHamlAssets
module Helpers
def not_found
[404, 'JST Haml template not found']
end
@rchampourlier
rchampourlier / _flash.html.haml
Created June 7, 2012 09:27 — forked from potomak/_flash.html.erb
Rails flash messages using Twitter bootstrap
- if flash
- flash.each do |level, message|
%div{:class => "alert #{flash_level(level)}"}
%button.close{:"data-dismiss" => 'alert'}= "×"
= message
@rchampourlier
rchampourlier / lazy_script.scpt
Created May 26, 2012 14:24
AppleScript for lazy developer on a Mac: opens multiple terminal tabs, run a set of commands on each tab
-- This script...
-- It assumes when you ssh into the vagrant box you automatically cd into
-- the project's directory (by having a `cd /vagrant` within your
-- `~/.bashrc` for example)
using terms from application "Terminal"
tell application "Terminal"
activate
-- open the terminal's window, set its dimensions
@rchampourlier
rchampourlier / google_bot_aware.rb
Created May 3, 2012 22:32
Rack middleware to make Rails deal correctly with GoogleBot's '*/*;q=0.6' Accept header
# This Rack middleware helps solving the issue with some Rails versions which do not accept
# a '*/*;q=0.6' and their variants 'Accept' request header. This header is particularly used
# by Google Bot, and if Rails doesn't like it, it will return a 500 or 406 error to Google Bot,
# which is not the best way to get your pages indexed.
#
# References:
# - http://stackoverflow.com/questions/8881756/googlebot-receiving-missing-template-error-for-an-existing-template
# - https://github.com/rails/rails/issues/4127
#
class GoogleBotAware
@rchampourlier
rchampourlier / backup.log
Created April 27, 2012 07:23
Backup gem log for issue#301
[2012/04/27 09:00:05][message] Backup for 'App DB - frequent (db_frequent)' Completed Successfully in 00:00:03
[2012/04/27 09:08:02][message] Performing Backup for 'App files (system - avatars, qrcodes) (files)'!
[2012/04/27 09:08:02][message] [ backup 3.0.24 : ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-linux] ]
[2012/04/27 09:08:02][message] Syncer::Cloud::S3 started the syncing process:
[2012/04/27 09:08:03][message] Generating checksums for '/home/user/rails/app/shared/system'
[2012/04/27 09:08:05][message] [skipping] 'files/system/avatars/10/...
[2012/04/27 09:08:05][message] [skipping] 'files/system/avatars/10/...
[2012/04/27 09:08:05][message] [skipping] 'files/system/avatars/10/...
[2012/04/27 09:08:05][message] [skipping] 'files/system/avatars/10/...
[2012/04/27 09:08:05][message] [skipping] 'files/system/avatars/100/...
@rchampourlier
rchampourlier / correct.js
Created April 15, 2012 19:23
Examples for issue with ajaxorg/node-github
var GitHubApi = require("github");
var user = "ajaxorg";
var repos = ["ace", "cloud9"];
var github = new GitHubApi({
version: "3.0.0"
});
repos.forEach(function(repo) {
@rchampourlier
rchampourlier / hooks.rb
Created April 3, 2012 18:29
Hooks for Cucumber, enabling to examine @javascript scenarios and deal with SSL
# features/support/hooks.rb
# This ensure SslRequirement is enabled for all scenarios, except
# if stated otherwise elsewhere (such as within Before('@javascript@'))
Before do
SslRequirement.disable_ssl_check = false
end
Before('@javascript') do
SslRequirement.disable_ssl_check = true