Skip to content

Instantly share code, notes, and snippets.

View simonjodet's full-sized avatar

Simon Jodet simonjodet

View GitHub Profile
@simonjodet
simonjodet / .bashrc
Created January 2, 2012 13:52
My Mac .bashrc file
#Colors
export CLICOLOR=1
export LSCOLORS=ExFxCxDxBxegedabagacad
#General aliases
alias la='ls -la'
#Git branch indicator for bash prompt
parse_git_branch ()
{
@simonjodet
simonjodet / usb_eject.rb
Created December 18, 2011 08:35
Mac OS external drives eject tool
#!/usr/bin/env ruby
# External USB drives eject tool.
# You should install growlnotify to get notifications from http://growl.info/extras.php#growlnotify
# It will eject all USB disks and all mounted images. It will warn you with a red icon if something goes wrong
# It starts from the bottom to the top to tentavily eject the mounted images before the drive they could be on.
#
# Advices:
# - Use Automator to make this script an app
# - Install Better Touch Tool (http://www.boastr.de/) to give it a global shortcut
@simonjodet
simonjodet / gist:1472043
Created December 13, 2011 12:56
Ruby - Execute a shell command
cmd = 'ls'
stdin, stdout, stderr = Open3.popen3(cmd)
stdout = stdout.readlines.to_s
stderr = stderr.readlines.to_s
@simonjodet
simonjodet / gist:1471967
Created December 13, 2011 12:28
Check file path doesn't go up too much
path = ".."
rootpath = File.expand_path(".")
realpath = File.expand_path(rootpath + "/" + path)
if realpath == rootpath or realpath.index(rootpath).nil?
puts "You went too far up"
end
@simonjodet
simonjodet / packager.php
Created June 18, 2011 06:46
Build a PHAR without hidden files
<?php
//Cleaning up any existing phar
if(file_exists('package.phar'))
{
unlink('package.phar');
}
//Where are my application sources
$dir = '../app/';
//Quickly get a recursive folder list