Skip to content

Instantly share code, notes, and snippets.

View janernsting's full-sized avatar

Jan Ernsting janernsting

View GitHub Profile
@janernsting
janernsting / numeric_entry_sorter.py
Last active March 14, 2016 09:59
Sorts a BibTex file according to its cited order (used in conjunction with biber and parallel alphabetic style)
#!/usr/bin/env python
from __future__ import print_function
import getopt, sys
bib_types = ("@misc", "@online")
def main(options):
aux_file = options[0]
bib_file = options[1]
@janernsting
janernsting / game_of_life_test.py
Last active August 29, 2015 14:01
Tell, Don't Ask in Python
from hamcrest import *
import unittest
class GameOfLifeTest(unittest.TestCase):
def setUp(self):
self.was_invoked = False
def invoke(self):
self.was_invoked = True
@janernsting
janernsting / CreateDrug.java
Created June 24, 2013 12:11
avoiding JSF validation
public void pznChanged() {
// set dummy value for name
drug.setName("drug");
}
@janernsting
janernsting / 5_battery_drain
Last active December 10, 2015 19:48
battery drain notification for byobu
#!/bin/sh -e
for bat in /sys/class/power_supply/*; do
status=""; drain=""
if [ -r "$bat/power_now" ] && [ -r "$bat/status" ]; then
drain=`cat "$bat/power_now"`
status=`cat "$bat/status"`
[ $status = "Discharging" ] && break
fi
done
if [ "$status" = "Discharging" ]; then
@janernsting
janernsting / bestellsystem.mf
Last active December 10, 2015 00:39
Ant-Buildscript für Aufgabe 12
Main-Class: de.pizza.views.BestellsystemApplication
@janernsting
janernsting / Bestellung.java
Created November 28, 2012 10:58
SE 2012 WS / Aufgabe 10
import java.util.Calendar;
import java.util.Date;
import javax.persistence.*;
@Entity
public class Bestellung {
private Long id;
@janernsting
janernsting / HelloWorldInvoker.java
Created November 28, 2012 10:53
Beispiel für Aufgabe 11
package de.wwu.pi;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
@janernsting
janernsting / uri.js
Created April 21, 2012 07:15 — forked from jlong/uri.js
URI Parsing with Javascript
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.host; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"