Skip to content

Instantly share code, notes, and snippets.

View msadouni's full-sized avatar

Matthieu Sadouni msadouni

View GitHub Profile
#!/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"
#!/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'
@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)
def random_string(length=10)
chars = 'abcdefghjkmnpqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789'
string = ''
length.times { string << chars[rand(chars.size)] }
string
end
@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 /
@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 / 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