Skip to content

Instantly share code, notes, and snippets.

View HeinrichHartmann's full-sized avatar

Heinrich Hartmann HeinrichHartmann

View GitHub Profile
@HeinrichHartmann
HeinrichHartmann / DistributedUrlDownloader.py
Created December 6, 2013 20:07
Distributed File Donwloader using ZMQ. List of urls is read from a file dstributed to workers, gathered and written to a directory.
#
# Distributed File Dowoloader
# ===========================
#
# List of urls is read from a file, distributed to workers, gathered and written to a directory.
#
# INSTALLATION & USAGE
# --------------------
# sudo apt-get install python-pip python-dev build-essential git screen
# sudo pip install pyzmq requests
@HeinrichHartmann
HeinrichHartmann / ZmqAppender.java
Created December 6, 2013 20:11
ZmqAppender for Log4j. Publishes log messages on a zmq socket.
package net.heinrich-hartmann.gists.ZmqAppender;
import org.apache.log4j.AppenderSkeleton;
import org.apache.log4j.Layout;
import org.apache.log4j.SimpleLayout;
import org.apache.log4j.spi.LoggingEvent;
import org.jeromq.ZMQ;
/**
* ZmqAppender for Log4j.
@HeinrichHartmann
HeinrichHartmann / markdown.css
Created December 15, 2013 14:15
Slightly customized version of Kevin Burke's markdown.css released under Apache License here https://bitbucket.org/kevinburke/markdowncss/overview http://kevinburke.bitbucket.org/markdowncss/markdown.css
/*
Customized version of Kevin Burke's markdown.css released under Apache License here
https://bitbucket.org/kevinburke/markdowncss/overview
*/
body{
margin: 0 auto;
@HeinrichHartmann
HeinrichHartmann / EtcGit.md
Last active January 1, 2016 14:59
Monitor /etc/ using git

Monitor /etc/ using git

  1. Initialize a new git repository at /etc/

     cd /etc/
     sudo git init
    
  2. Setup .gitignore

cat << EOF | sudo tee .gitignore

DROP VIEW IF EXISTS ft_trips;
DROP VIEW IF EXISTS ft_stats;
-- Create view with basic gps statistics:
-- a) trip_id
-- b) Sample Count
-- c) Maximal Distance to Helsinki Train Station
CREATE VIEW ft_stats(trip_id, count, dist) AS
SELECT trip_id, count(lonlat), Max(st_distance(lonlat, St_geometryfromtext('POINT(24.6006695 60.1893798)',4326)))
FROM sensor_gps
@HeinrichHartmann
HeinrichHartmann / gps_tag_generator.py
Last active August 29, 2015 13:56
GPS TAG Generation
import psycopg2, psycopg2.extras
DSN = {
'dbname': "xxx",
'user': "xxx",
'password': "xxx"}
def main():
con = psycopg2.connect(connection_factory=psycopg2.extras.NamedTupleConnection, **DSN)
cur = con.cursor()
@HeinrichHartmann
HeinrichHartmann / postgres.conf
Last active August 29, 2015 13:56
Postgres Upstart Script
# postgres.conf
#
# A simple upstart script for the postgresql server as installed from source
# http://www.postgresql.org/docs/9.3/interactive/installation.html
#
# Place this file in /etc/init/
#
# Usage:
# $ sudo service postgres start|stop|status
#
@HeinrichHartmann
HeinrichHartmann / TermOnSend.java
Created March 21, 2014 08:19
Failing context termination on send
import org.zeromq.ZMQ;
import org.zeromq.ZMQException;
public class TermOnSend {
public static void main(String[] args) {
final ZMQ.Context ctx = ZMQ.context(1);
Thread threadB = new Thread(new Runnable() {
@Override
public void run() {
@HeinrichHartmann
HeinrichHartmann / wct.py
Last active August 29, 2015 14:03
WorldCupTime
#!/usr/bin/python
import sys
import BaseHTTPServer
import urllib2
from dateutil import parser, tz as dutz
from datetime import datetime, tzinfo
import ipdb
BREAK=ipdb.set_trace
@HeinrichHartmann
HeinrichHartmann / account-summary.py
Created July 22, 2014 12:28
Bank Account Analytics for Sparda-Bank csv files
"""
Computes a summary of (unique) bank transactions from CSV files
USAGE:
python account-summary.py account_statment1.csv account_statement2.csv ...
OUTPUT:
CSV printed to stdout with the following colums