Skip to content

Instantly share code, notes, and snippets.

View ptitfred's full-sized avatar

Frédéric Menou ptitfred

View GitHub Profile
@ptitfred
ptitfred / wait-tcp.sh
Created February 9, 2012 18:19
Wait for a TCP port to be open
#!/bin/bash
function help {
echo "Usage: wait-for port [timeout]"
echo " port is a TCP port number, or the service name (for instance http, ssh)"
echo " timeout is expressed in seconds"
echo " optional (defaulted to 30)"
echo " if <= 0, no timeout"
exit 1
}
@ptitfred
ptitfred / gist:1396436
Created November 26, 2011 22:48
Git current-branch
git rev-parse --symbolic-full-name --abbrev-ref HEAD
@ptitfred
ptitfred / find-cvs-files.sh
Created October 18, 2011 15:08
Find CVS files
#!/bin/bash
find . -path "*/CVS/Entries*"
@ptitfred
ptitfred / gist:1241877
Created September 26, 2011 08:46
Clean whitespace problems in eclipse
Clean whitespace "problems" :
Find: [\t ]+$
Replace with: (nothing)
with Regex mode
@ptitfred
ptitfred / colorize.sh
Created September 21, 2011 12:31
fonction bash pour colorer un text
#!/bin/bash
function color {
echo -e "\x1b[${2}m$1\x1b[0m"
}
@ptitfred
ptitfred / git-cd.sh
Created September 5, 2011 08:15
Diff 2 commits
#!/bin/bash
from="$1"
to="$2"
for file in $(git show --numstat $from --pretty=format: | cut -f3)
do
git diff $from $to -- $file
done
@ptitfred
ptitfred / build-v8-shell.sh
Created August 7, 2011 01:16
Script de compilation du module de shell de V8
sudo apt-get install scons g++-multilib
scons sample=shell regexp=interpreted
@ptitfred
ptitfred / model.test.coffee
Created August 6, 2011 23:23
TDD en Coffee Script avec QUnit
test "Bookmark toString works", ->
### given ###
bookmark = new Bookmark "lien@localhost", "lien", new Point 0, 1
### when ###
text = bookmark.toString()
### then ###
equals "Bookmark \"lien\" lien@localhost at (0,1)", text, "Bookmark.toString()"
@ptitfred
ptitfred / dbstorage.coffee
Created August 5, 2011 22:42
HTML5 DBStorage en CoffeeScript
# Handlers
nope = (tx, obj) ->
displayResult = (tx, rs) ->
alert "Succeeded!"
displayError = (tx, err) ->
alert "Error: #{err.message}"
class Storage
@ptitfred
ptitfred / colorize.sh
Created August 1, 2011 16:45
Colorise stderr from a executable ; ERROR and WARNING rows are colorized in red and orange
#!/bin/bash
error="91"
warning="35"
( $1 3>&1 1>&2- 2>&3- ) | sed \
-e "s/^\(.* ERROR - \)\(.*\)$/\1\x1b[${error}m\2\x1b[0m/" \
-e "s/^\(.* WARNING - \)\(.*\)$/\1\x1b[${warning}m\2\x1b[0m/"