Skip to content

Instantly share code, notes, and snippets.

View goerz's full-sized avatar

Michael Goerz goerz

View GitHub Profile
@goerz
goerz / insomnia
Created September 3, 2009 19:07
insomnia: CLI interface to InsomniaX
#!/usr/bin/perl
use strict;
# Author: Michael Goerz <[email protected]>
# Make sure that $kextfile is owned by root!
my $app = '/Applications/InsomniaX.app';
my $kextfile = "$app/Contents/Resources/Insomnia_r6.kext/";
sub close_insomnia_x{
my $ps_line = `ps -A | grep $app | grep -v grep`;
@goerz
goerz / latex_checkascii.pl
Created August 1, 2010 17:43
latex_checkascii.pl: check latex files for non-ascii characters and optionally replaces them with tex-representations
#!/usr/bin/perl -w
use strict;
use utf8;
############################################################################
# Copyright (C) 2008 by Michael Goerz #
# http://www.physik.fu-berlin.de/~mgoerz #
# #
# This program is free software; you can redistribute it and/or modify #
# it under the terms of the GNU General Public License as published by #
# the Free Software Foundation; either version 3 of the License, or #
@goerz
goerz / quinegen.pl
Created August 1, 2010 17:53
quinegen.pl: Make a quine out of any perl program. Inspired by Douglas R. Hofstadter.
#!/usr/bin/perl -w
use strict;
# This program adds a function 'printself' to the end of an existing
# perl program, which prints out the entire program's listing. This
# will make the existing program to be a Quine
# (c)2006 Michael Goerz
# michaelgoerz.net
# This program is free software; you can redistribute it and/or modify
@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>;
@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 / 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 / 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 / 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 / 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
@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.