Skip to content

Instantly share code, notes, and snippets.

View czj's full-sized avatar

Clément Joubert czj

View GitHub Profile
@dhh
dhh / gist:965746
Created May 11, 2011 01:33
Pjax helper
module Pjax
extend ActiveSupport::Concern
included do
layout ->(c) { pjax_request? ? false : 'application' }
end
private
def redirect_pjax_to(action, url = nil)
new_url = url_for(url ? url : { action: action })
@dhh
dhh / gist:1014971
Created June 8, 2011 18:09
Use concerns to keep your models manageable
# autoload concerns
module YourApp
class Application < Rails::Application
config.autoload_paths += %W(
#{config.root}/app/controllers/concerns
#{config.root}/app/models/concerns
)
end
end
@czj
czj / nginx
Created July 17, 2011 10:00
Ubuntu Server 10.04 init.d file for nginx (installed by Passenger)
#! /bin/sh
### BEGIN INIT INFO
# Provides: nginx
# Required-Start: $all
# Required-Stop: $all
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts the nginx web server
# Description: starts nginx using start-stop-daemon
@czj
czj / gist:1136385
Created August 10, 2011 08:41
Auto-login for Banque Populaire Ouest
var base_url = "https://www.secure3.banquepopulaire.fr/amserver/UI/Login?realm=ENTAO-ENV00030&goto=https%3A%2F%2Fwww.ibps.ouest.banquepopulaire.fr%3A443%2Fcyber%2Fibp%2Fate%2Fportal%2Finternet.html";
if (window.location != base_url)
{
window.location = base_url;
}
else
{
document.getElementById('IDToken1').value = "";
document.getElementById('IDToken2').value = "";
@czj
czj / gist:1136386
Created August 10, 2011 08:42
Auto-login bookmarklet for Boursorama Banque (site beta août 2011)
if (window.location != 'https://www.boursorama.com/connexion.phtml')
{
window.location = 'https://www.boursorama.com/connexion.phtml';
}
else
{
document.getElementById('login').value = "";
document.getElementById('password').value = "";
document.getElementById('identification').submit();
}
@czj
czj / gist:1149177
Created August 16, 2011 14:11
BNP Paribas almost-automatic login
var url = "https://www.secure.bnpparibas.net/banque/portail/particulier/HomeConnexion?type=homeconnex&identifiant=secure_bnpparibas_net_20021206152735"
if (window.location != url)
{
window.location = url;
}
else
{
// Add your login here
document.logincanalnet.ch1.value = "";
@czj
czj / sabnzdb_upgrade.sh
Created September 27, 2011 09:40
SABnzdb+ auto-update script
#!/bin/bash
cd ~/bin
API_KEY=`cat SABnzbd/sabnzbd.ini | grep ^api_key | awk '{print $3}'`
PORT=` cat SABnzbd/sabnzbd.ini | grep ^https_port | awk '{print $3}'`
VERSION=`curl -s http://sabnzbdplus.sourceforge.net/version/latest | head -n1`
VERSION=${VERSION%?}
DIR="SABnzbd-${VERSION}"
GZ="${DIR}-src.tar.gz"
@czj
czj / gist:1251031
Created September 29, 2011 15:43
.irbrc that runs Pry instead of IRB
# This script comes from Pry Everywhere by Luca Pette
# http://lucapette.com/pry/pry-everywhere/
# https://github.com/carlhuda/bundler/issues/183#issuecomment-1149953
if defined?(::Bundler)
global_gemset = ENV['GEM_PATH'].split(':').grep(/ruby.*@global/).first
if global_gemset
all_global_gem_paths = Dir.glob("#{global_gemset}/gems/*")
all_global_gem_paths.each do |p|
gem_path = "#{p}/lib"
@czj
czj / gist:1251040
Created September 29, 2011 15:45
Custom .pryrc for OSX + Rails + polite
# This script is greatly inspired by Pry Everywhere by Luca Pette
# http://lucapette.com/pry/pry-everywhere/
# Use TextMate as default editor
Pry.config.editor = "mate -w"
# My pry is polite
Pry.hooks = {
:after_session => proc {
puts "\nGoodbye." if Pry.active_sessions == 1
@czj
czj / gist:1261139
Created October 4, 2011 08:20
CSS filtering for Google Reader (remove ads & useless links)
/*
http://www.google.fr/reader/*
*/
a[href*=feedburner],
a[href*=feedsportal],
img[src*=feedsportal] {
display:none !important;
}