Skip to content

Instantly share code, notes, and snippets.

View goerz's full-sized avatar

Michael Goerz goerz

View GitHub Profile
@bagrow
bagrow / jet_colors.gnu
Created February 1, 2011 00:12
Love or hate the matlab jet colormap? Want it in gnuplot? Here's how to do it!
set palette defined (0 0.0 0.0 0.5, \
1 0.0 0.0 1.0, \
2 0.0 0.5 1.0, \
3 0.0 1.0 1.0, \
4 0.5 1.0 0.5, \
5 1.0 1.0 0.0, \
6 1.0 0.5 0.0, \
7 1.0 0.0 0.0, \
8 0.5 0.0 0.0 )
@beniwohli
beniwohli / unicode_to_latex.py
Created January 27, 2011 14:08
Map to convert unicode characters to their respective LaTeX representation
# original XML at http://www.w3.org/Math/characters/unicode.xml
# XSL for conversion: https://gist.github.com/798546
unicode_to_latex = {
u"\u0020": "\\space ",
u"\u0023": "\\#",
u"\u0024": "\\textdollar ",
u"\u0025": "\\%",
u"\u0026": "\\&",
@MicahElliott
MicahElliott / colortrans.py
Created November 29, 2010 07:57
Convert values between RGB hex codes and xterm-256 color codes.
#! /usr/bin/env python
""" Convert values between RGB hex codes and xterm-256 color codes.
Nice long listing of all 256 colors and their codes. Useful for
developing console color themes, or even script output schemes.
Resources:
* http://en.wikipedia.org/wiki/8-bit_color
* http://en.wikipedia.org/wiki/ANSI_escape_code
@drio
drio / tmux libevent
Created August 18, 2010 22:03
How to compile tmux
NOTE: I am using bash for this.
NOTE2: Another approach for getting tmux would be to use gentoo-prefix or netbsd's pkgsrc. I
didn't have too much luck with gentoo-prefix. NetBSD was pretty straight forward but it had
an old version of tmux (1.1).
Here is how to get tmux compiled if you can get your systadmins to installed it ... or
any other weird reason. I assume you have some basic libraries and headers installed (like
ncurses, etc...). If not, you'll have to compile those ones too.
@goerz
goerz / mountstick.pl
Created August 1, 2010 19:26
mountstick.pl
#!/usr/bin/perl -w
use strict;
my @devicelist = </dev/sdb?>; # order is important: first found device ist default
my %mountpaths = ( qr"/dev/sd??" => '/mnt' ); # default paths
my $UID = 'goerz'; # the user id the device is mounted as
my $GID = 'users'; # the group id the device is mounted as
my $FMASK = '000'; # the permissions of the mounted device (masked)
my $UMOUNT = '/home/goerz/bin/umountstick'; # the name of the script that should be written for umounting
my $TRFILE = '/home/goerz/.usbmounts'; # file used for tracking which devices are mounted
@goerz
goerz / scan.pl
Created August 1, 2010 18:47
scan.pl: A script that wraps sane to scan to a pdf file, A4, black-and-white.
#!/usr/bin/perl -w
use strict;
use threads;
# (c) 2007 Michael Goerz <[email protected]>
# usage:
# scan [pdffile]
# Prerequisites:
# iText (http://www.lowagie.com/iText/)
@goerz
goerz / deletedoubles.pl
Created August 1, 2010 18:45
deletedoubles.pl: Delete duplicate files, based on their md5 sum.
#!/usr/bin/perl -w
use strict;
my %files;
my @ignorepatterns = ();
my $defaultselection = 0;
@goerz
goerz / decrypt.pl
Created August 1, 2010 18:01
encrypt.pl, decrypt.pl: Two scripts that encrypt, and decrypt files using GPG
#!/usr/bin/perl -w
use strict;
my $recursive = 'false';
if ($ARGV[0] eq '-r') {
$recursive = shift @ARGV;
$recursive = 'true';
}
decrypt(\@ARGV);
@goerz
goerz / md5recursive.pl
Created August 1, 2010 17:59
md5recursive.pl: Wrapper around md5sum, can work on files recursively.
#!/usr/bin/perl -w
use strict;
my $recursive = 'true';
md5sum(\@ARGV);
sub md5sum{
my $filelist = shift;
foreach my $file (@{$filelist}){
if ( -f $file ){
@goerz
goerz / filter.pl
Created August 1, 2010 17:57
filter.pl: Filter the contents of the KDE clipboard through any pipe
#!/usr/bin/perl -w
use strict;
my $historyfile = glob '~/.filter.pl.last';
my $command = "";
system("touch $historyfile");
open(HIST, "$historyfile") or die "Can't open file: $!";
$command = <HIST>;