Skip to content

Instantly share code, notes, and snippets.

View pdonadeo's full-sized avatar

Paolo Donadeo pdonadeo

View GitHub Profile
@henrik
henrik / .bashrc
Created December 3, 2008 17:56
Git branch and dirty state in Bash prompt.
# 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 {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/[\1$(parse_git_dirty)]/"
@zbroyar
zbroyar / gist:756823
Created December 28, 2010 02:33
Converter of PEM RSA private key to OCaml Cryptokit
#!/usr/bin/env ocaml
(*
Prerequisites: Findlib, Pcre, Cryptokit
Usage: openssl rsa -in privkey.pem -text | ./pem2ck.ml > privkey.cryptokit
*)
#use "topfind" ;;
#require "pcre" ;;
#require "cryptokit" ;;
@enaeher
enaeher / tiered_archives.rb
Created September 5, 2011 21:49
Tiered Archives plugin
# A quick and dirty plugin for Jekyll by Eli Naeher
#
# This plugin creates a site.years template variable which allow you to group archive links by year and month.
# The structure of site.years is:
# site.years = 2001=>[[post1, post2...], [...]], 2002=>[...]
#
# Usage should look something like this:
# {% for year in site.years %}
# <h2>Year {{ year.first.first.date | date: "%Y" }}</h2>
@frbayart
frbayart / virt-manager_run.py
Created June 23, 2012 13:45
virt-manager on MACOSX
MBA-FBA:bin francois$ ./virt-manager
RuntimeWarning: tp_compare didn't return -1 or -2 for exception
RuntimeWarning: tp_compare didn't return -1 or -2 for exception
Traceback (most recent call last):
File "/Users/francois/bin/mybuild/share/virt-manager/virt-manager.py", line 393, in <module>
_show_startup_error(str(run_e), "".join(traceback.format_exc()))
File "/Users/francois/bin/mybuild/share/virt-manager/virt-manager.py", line 63, in _show_startup_error
from virtManager.error import vmmErrorDialog
File "/Users/francois/bin/mybuild/share/virt-manager/virtManager/error.py", line 173, in <module>
class _errorDialog (gtk.MessageDialog):
@magnetikonline
magnetikonline / README.md
Last active March 14, 2024 22:48
IE 7/8/9/10/11 Virtual machines from Microsoft - Linux w/VirtualBox installation notes.
@wandernauta
wandernauta / sp
Last active July 10, 2024 07:57
sp is a command-line client for Spotify's dbus interface. Play, pause, skip and search tracks from the comfort of your command line.
#!/usr/bin/env bash
#
# This is sp, the command-line Spotify controller. It talks to a running
# instance of the Spotify Linux client over dbus, providing an interface not
# unlike mpc.
#
# Put differently, it allows you to control Spotify without leaving the comfort
# of your command line, and without a custom client or Premium subscription.
#
@e4c5
e4c5 / paginator
Last active January 7, 2022 14:29
The django admin change_list template causes the execution of the 'select count(*) from table_name' type query which can be very slow when the table has a few million entries. The problem is better described at https://code.djangoproject.com/ticket/8408 The following custom paginator will solve this issue by caching the row count for a short per…
import collections
from math import ceil
from django.core.paginator import Page
from django.core.cache import cache
# To use the paginator, add the following to your admin class:
# from myapp import CachingPaginator
#
# ...
@andrejbauer
andrejbauer / mandelbrot.c
Created December 11, 2013 22:23
A simple program for computing the Mandelbrot set.
/*
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:
@andrejbauer
andrejbauer / mandelbrot.ml
Created December 28, 2013 22:48
A simple program to compute the Mandelbrot set.
(* 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
@naufraghi
naufraghi / backup-google-authenticator.py
Last active July 10, 2020 20:11
Script to backup Google Authenticator secrets as QR-codes
#!/usr/bin/env python3
# Copyright 2014 Matteo Bertini matteo@naufraghi.net
# Released as Public Domain
#
# Latest version:
# wget http://slug.it/backup-google-authenticator.py
#
# Requirements
# ============
#