Skip to content

Instantly share code, notes, and snippets.

View goerz's full-sized avatar

Michael Goerz goerz

View GitHub Profile
#!/usr/bin/python
from time import strftime
import sqlite3
import sys
import twitter #http://code.google.com/p/python-twitter/
import feedparser #available at feedparser.org
DATABASE = "/Users/goerz/.twitter_bot/tweets.sqlite"
@goerz
goerz / ma.f90
Created August 19, 2009 15:01
Fortran90 Pointers: is foo reliably 1?
module a_mod
use b_mod
implicit none
public
private :: a, b
integer, target :: a
integer, pointer :: b
contains
subroutine run_test()
a = 1
partCounter = 1
for part in msg.walk():
if part.get_main_type()=="multipart":
continue
name = part.get_param("name")
if name==None:
name = "part-%i" % partCounter
partCounter+=1
f = open(name,"wb")
f.write(part.get_payload(decode=1))
@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`;
require 'rubygems'
require 'sequel'
require 'fileutils'
# NOTE: This converter requires Sequel and the MySQL gems.
# The MySQL gem can be difficult to install on OS X. Once you have MySQL
# installed, running the following commands should work:
# $ sudo gem install sequel
# $ sudo gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
@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);