Skip to content

Instantly share code, notes, and snippets.

View ptitfred's full-sized avatar

Frédéric Menou ptitfred

View GitHub Profile
sudo adduser --disabled-password backuper
sudo su backuper
cd ~/.ssh
ssh-keygen -t dsa
# entrée pour ne pas saisir de passphrase
# entrée pour garder le nom par défaut, très satisfaisant
@ptitfred
ptitfred / email-on-update.sh
Created August 28, 2010 20:28
Hook for Git emailing content of a push
#!/bin/bash
refname="$1"
oldrev="$2"
newrev="$3"
PATH=~/bin:$PATH
if [ -z "$GIT_DIR" ]; then
echo "Don't run this script from the command line." >&2
@ptitfred
ptitfred / server.cpp
Created October 5, 2010 21:17
C++ HTTP server
#include "server.hpp"
#include <iostream>
#include <fstream>
#include <sstream>
using std::cout;
using std::cerr;
using std::cin;
using std::endl;
using std::fstream;
@ptitfred
ptitfred / Makefile
Created July 25, 2011 22:30
Makeflags regression (3.80-3.81)
all:
@echo MAKEFLAGS = $(MAKEFLAGS)
@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/"
@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 / 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 / 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 / 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 / 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"
}