Skip to content

Instantly share code, notes, and snippets.

Till Dettmering dettmering

Block or report user

Report or block dettmering

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@dettmering
dettmering / gist:4045392
Created Nov 9, 2012
Bash: Add all EPS files in the directory to a TeX file
View gist:4045392
#!/bin/bash
# Puts all eps files in folder in figure environment
rm figures.tex
echo "\documentclass[a4paper,10pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{graphicx} % support the \includegraphics command and options
\usepackage{epstopdf}
@dettmering
dettmering / bbox.sh
Created Nov 9, 2012
Shell: Recalculate bounding box of EPS files
View bbox.sh
#!/bin/bash
# This script recalculates all bounding boxes of all eps files in the same folder
# requires epstool
for f in *.eps
do
g=$(echo $f | sed 's/\(.*\)\..*/\1/')
echo Processing $f ...
epstool --copy --bbox $g.eps $g-new.eps
done
@dettmering
dettmering / gist:3767424
Created Sep 22, 2012
PHP: Convert UNIX time into relative timestamp
View gist:3767424
// converts UNIX seconds into relative format
function relativeDate($date) {
$secondsago = time() - $date;
if ($secondsago <= 59) {$timestamp = "less than a minute ago";}
else if ($secondsago <= 119) {$timestamp = floor(($secondsago / 60)) . " minute ago (" . strftime('%R', $date) . ")";}
else if ($secondsago <= 3599) {$timestamp = round(($secondsago / 60)) . " minutes ago (" . strftime('%R', $date) . ")";}
else if ($secondsago <= 7199) {$timestamp = round(($secondsago / 3600),1) . " hours ago (" . strftime('%a %R', $date) . ")";}
else if ($secondsago <= 86400) {$timestamp = round(($secondsago / 3600)) . " hours ago (" . strftime('%a %R', $date) . ")";}
else if ($secondsago <= 345600) {$timestamp = round(($secondsago / 86400)) . " days ago (" . strftime('%a %R', $date) . ")";}
@dettmering
dettmering / gist:3767366
Created Sep 22, 2012
Python: Read CSV file into array
View gist:3767366
def readcsv(filename):
ifile = open(filename, "rU")
reader = csv.reader(ifile, delimiter=";")
rownum = 0
a = []
for row in reader:
a.append (row)
rownum += 1
You can’t perform that action at this time.