Skip to content

Instantly share code, notes, and snippets.

View HeinrichHartmann's full-sized avatar

Heinrich Hartmann HeinrichHartmann

View GitHub Profile
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@HeinrichHartmann
HeinrichHartmann / ignite.el
Last active May 2, 2018 19:18
emacs functions to simulate ignite talks
(defun ignite-start ()
"Auto advaince slides"
(interactive)
(set 'ignite-interval 15)
(set 'ignite-t ignite-interval)
(message (format "Go! (%d sec)" ignite-interval))
(run-at-time 0 1 (lambda ()
(if (<= ignite-t 0)
(progn
(doc-view-next-page)
@HeinrichHartmann
HeinrichHartmann / RPi_ADC8032.py
Created December 14, 2014 21:04
Raspbery Pi Analog Input with ADC0832
#!/usr/bin/env python
#
# Analog Input with ADC0832 chip
#
# Datasheet: http://www.ti.com/lit/ds/symlink/adc0838-n.pdf
# Part of SunFounder LCD StarterKit
# http://www.sunfounder.com/index.php?c=show&id=21&model=LCD%20Starter%20Kit
#
import time
@HeinrichHartmann
HeinrichHartmann / lua_examples.c
Created April 19, 2018 09:20
Lua C API Examples
#include <stdio.h>
#include <string.h>
#include <lua.h>
#include <lauxlib.h>
#include <lualib.h>
// Helper function to print the stack contents
// Values other than numbers and strings are printed as "(null)"
void print_stack(lua_State *L, char* title){
int nargs = lua_gettop(L);
@HeinrichHartmann
HeinrichHartmann / GoogleSheetsExample.py
Last active December 5, 2016 20:34
Convenient Access to Google Spreadsheets
# Copyright (c) 2015 Heinrich Hartmann
# MIT License http://choosealicense.com/licenses/mit/
import gdata.spreadsheet.service
class GoogleDriveConnection(object):
def __init__(self, email, password):
self.client = gdata.spreadsheet.service.SpreadsheetsService()
self.client.ClientLogin(email, password)
@HeinrichHartmann
HeinrichHartmann / Monitoring Gloassary.md
Last active July 3, 2016 11:33
Monitoring Glossary

Glossary of Monitoring

  • A system is a set of connected components

The definition of connected and components is missing. I think we can go with definitions like:

  • A components is a set of processes (in the OS sense)
  • Two components are connected if they can talk to each other (over a network or IPC).

Example: A LAMP system, consists of components:

@HeinrichHartmann
HeinrichHartmann / pinbuffer.el
Created June 15, 2016 16:06
Pin an buffer to a window in #emacs
;; Similar to: http://stackoverflow.com/questions/43765/pin-emacs-buffers-to-windows-for-cscope/65992#65992
(defun pin-buffer ()
"Pin buffer to current window."
(interactive)
(message
(if (let (window (get-buffer-window (current-buffer)))
(set-window-dedicated-p window (not (window-dedicated-p window))))
"pinned buffer" "un-pinned buffer")
))
@HeinrichHartmann
HeinrichHartmann / histogram.py
Created January 15, 2016 13:56
Simple (inefficient) example of how to create a histogram with python
from matplotlib import pyplot as plt
import numpy as np
X = np.genfromtxt("DataSets/RequestRates.csv", delimiter=",")[:,1]
bins = [500, 700, 800, 900, 1000, 1500, 1800, 2000, 2200]
bin_count = len(bins) - 1
sample_counts = [0] * bin_count
for x in X:
for i in range(bin_count):
if (bins[i] <= x) and (x < bins[i + 1]):
sample_counts[i] += 1
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 / 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