Skip to content

Instantly share code, notes, and snippets.

View msadouni's full-sized avatar

Matthieu Sadouni msadouni

View GitHub Profile
@msadouni
msadouni / init-git-cakephp.sh
Created September 23, 2009 09:50
Initializes a git repository for a new CakePHP 1.2 application with the DebugKit plugin
#!/bin/bash
git init
echo "<?php" > config/config.php
find . -type d -empty | xargs -I % touch %/.gitignore
echo 'tmp/**/*' >> .gitignore
echo 'tmp/**/**/*' >> .gitignore
ignored_files=( .htaccess config/core.php config/config.php config/database.php webroot/.htaccess webroot/index.php webroot/test.php )
for ignored_file in ${ignored_files[@]}
do
cp $ignored_file $ignored_file.default
@msadouni
msadouni / rails-template.rb
Created October 16, 2009 10:27
Basic Rails template
# ~/rails-modele.rb
# Initialisation du dépôt
git :init
# Copie du fichier de configuration de la base de données vers une version d'exemple
run "cp config/database.yml config/database.yml.default"
# Ajout d'un fichier .gitignore dans chaque répertoire vide
# Git ne versionne que le contenu des fichiers, un répertoire ou fichier vide est ignoré
@msadouni
msadouni / backup-all-databases-separate-files.sh
Created October 20, 2009 09:43
Backup all dbs in separate files
#!/bin/sh
# Backup all dbs in separate files
# adapted from
# http://www.usercore.com/backup-all-mysql-databases-as-seperate-sql-files/
# use mysqldump5 for MacPorts, mysqldump otherwise
user='user'
password='password'
to='/path/to/backup/folder' # without final /
def random_string(length=10)
chars = 'abcdefghjkmnpqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789'
string = ''
length.times { string << chars[rand(chars.size)] }
string
end
@msadouni
msadouni / random_string.rb
Created January 22, 2010 10:09
Generates a random string via the commande line
#!/opt/local/bin/ruby
def random_string(length=15)
chars = 'abcdefghjkmnpqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789'
password = ''
length.times { password << chars[rand(chars.size)] }
password
end
if ARGV.first
puts random_string(ARGV.first.to_i)
#!/bin/bash
export_to='/path/to/export/without/slash'
login='login'
server='server.com'
root='/path/to/app/without/slash'
rm -rf $export_to
git checkout-index -a --prefix=$export_to/
rsync -avz -e ssh $export_to/ $login@$server:$root --exclude-from 'exclude.rsync'
#!/usr/bin/env ruby
unless ARGV[0]
puts 'Usage: newpost "the post title"'
exit(-1)
end
date_prefix = Time.now.strftime("%Y-%m-%d")
postname = ARGV[0].strip.downcase.gsub(/ /, '-')
post = "/Users/al3x/src/al3x.github.com/_posts/#{date_prefix}-#{postname}.textile"
@msadouni
msadouni / restart-ad.rb
Created April 2, 2010 15:23
Redémarrage d'un pack Alwaysdata
require 'net/https'
require 'rubygems'
require 'nokogiri'
require 'open-uri'
username = 'courriel'
password = 'mot de passe'
pack = 'nom du pack'
urls = ['http://www.monsite.com', 'http://test.monsite.com']
@msadouni
msadouni / pre-commit
Created October 14, 2011 14:05
Git pre-commit hook to compile Compass files to production for a CakePHP app
#!/bin/sh
if git-rev-parse --verify HEAD >/dev/null 2>&1; then
against=HEAD
else
against=4b825dc642cb6eb9a060e54bf8d69288fbee4904
fi
compass compile --output-style compressed --force
git add webroot/css/*.css
@msadouni
msadouni / pre-commit
Created October 14, 2011 14:29
Git pre-commit hook to compile Compass files to production for a Rails (<= 3.0) app
#!/bin/sh
if git-rev-parse --verify HEAD >/dev/null 2>&1; then
against=HEAD
else
against=4b825dc642cb6eb9a060e54bf8d69288fbee4904
fi
compass compile --output-style compressed --force
git add public/stylesheets/*.css