Skip to content

Instantly share code, notes, and snippets.

View pdonadeo's full-sized avatar

Paolo Donadeo pdonadeo

View GitHub Profile

Keybase proof

I hereby claim:

  • I am pdonadeo on github.
  • I am pdonadeo (https://keybase.io/pdonadeo) on keybase.
  • I have a public key whose fingerprint is 038E 2B3F 01A2 2582 210E A61C 12FD A58D B634 8E24

To claim this, I am signing this object:

@pdonadeo
pdonadeo / compile.sh
Last active August 29, 2015 14:12
ctypes bug description
#!/bin/bash
gcc -ansi -Wall foo_c.c -c -o foo_c.o
ocamlfind ocamlopt \
-verbose \
-linkpkg \
-package ctypes.foreign \
foo_c.o \
foo_ml.ml \
@pdonadeo
pdonadeo / snap.sh
Created December 3, 2014 22:53
Directory snapshot
#!/bin/bash
BACKUP_TS=`date +"%FT%H.%M.%S"`
DIR=`basename "$@"`
TAR_FILE=${DIR}_${BACKUP_TS}.tar.bz2
SHA=${TAR_FILE}.sha1
tar --acls --selinux --xattrs --force-local \
(* The Mandelbrot set.
Compile with:
ocamlbuild mandelbrot.native
Example usage:
./mandelbrot.native --xmin 0.27085 --xmax 0.27100 --ymin 0.004640 --ymax 0.004810 --xres 1000 --maxiter 1024 --file pic.ppm
/*
This program is an adaptation of the Mandelbrot program
from the Programming Rosetta Stone, see
http://rosettacode.org/wiki/Mandelbrot_set
Compile the program with:
gcc -o mandelbrot -O4 mandelbrot.c
Usage:
@pdonadeo
pdonadeo / .bashrc
Last active December 27, 2015 13:59 — forked from henrik/.bashrc
# http://henrik.nyh.se/2008/12/git-dirty-prompt
# http://www.simplisticcomplexity.com/2008/03/13/show-your-git-branch-name-in-your-prompt/
# username@Machine ~/dev/dir[master]$ # clean working directory
# username@Machine ~/dev/dir[master*]$ # dirty working directory
function parse_git_dirty {
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit, working directory clean" ]] && echo "*"
}
function parse_git_branch {
if [ "`git rev-parse --show-toplevel`" != "${HOME}" ]
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys, os, re, glob
import subprocess
from subprocess import *
def check_output(*popenargs, **kwargs):
# WORKS WITH PYTHON 2.6.x
if 'stdout' in kwargs:
@pdonadeo
pdonadeo / broken_client.ml
Created November 6, 2011 13:36
Source to reproduce a possible bug in BatEnum.lines_of
(* COMPILE WITH:
* ocamlfind ocamlc -g -linkpkg -package batteries broken_client.ml -o client *)
let in_, out_ = BatUnix.open_connection (Unix.ADDR_UNIX "my_socket");;
BatEnum.fold
(fun count l -> Printf.printf "%s\n%!" l; count + 1)
1
(BatIO.lines_of in_)
;;