Skip to content

Instantly share code, notes, and snippets.

View kkroesch's full-sized avatar

Karsten Kroesch kkroesch

View GitHub Profile
@kkroesch
kkroesch / gallery.sh
Last active October 11, 2016 08:06
Minimalistic approach to create a gallery page from image directory.
@kkroesch
kkroesch / isnat.sh
Created July 13, 2016 12:45
Figure out if your computer is behind NATing firewall.
INTERFACE=$(ifconfig en0 | grep 'inet ' | cut -f2 | awk '{ print $2}')
PUBLIC=$(curl -s http://ifconfig.co)
[ $INTERFACE = $PUBLIC ] || echo NAT
@kkroesch
kkroesch / asset_finder.py
Created June 30, 2016 10:34
Finds references to external scripts and stylesheets from HTML page and prints download instructions for those files.
import sys
import argparse
from HTMLParser import HTMLParser
file_list = []
class AssetFinder(HTMLParser):
def handle_starttag(self, tag, attrs):
@kkroesch
kkroesch / index.htm
Created June 28, 2016 13:51
Angular Material Start
<html lang="en" >
<head>
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/angular_material/1.0.0/angular-material.min.css">
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
<style type="text/css">
.location-item { padding: 0.5em; cursor: pointer; }
.level-2 { padding-left: 1.5em; }
.level-3 { padding-left: 2.5em; }
.level-4 { padding-left: 3.5em; }
@kkroesch
kkroesch / app.js
Last active April 18, 2016 12:12
Failsafe setting of NODE_PATH in scripts. Put this line before importing your own modules to avoid statements like `require('../../middleware')'.
process.env.NODE_PATH || (process.env.NODE_PATH = __dirname)
@kkroesch
kkroesch / colors.py
Last active June 4, 2022 21:57
Color definitions for console output.
DOUBLE_LINE = '=' * 80
OUTPUT_TEMPLATE = "{0:32}{1:>6}"
DEVICE_TEMPLATE = "{0:35}{1:22}{2:>12}"
CHECK_SIGN = u'✔'.encode('utf-8')
FAIL_SIGN = u'✘'.encode('utf-8')
class Colors:
""" Colors for console putput as ANSI code.
@kkroesch
kkroesch / date.js
Created October 1, 2015 09:45
Calendar-related calculations.
/*
* Calendar calculations
*
* The following enhancements on the standard JavaScript Date object
* allow advanced calculations for calendars, especially the
* calculation of the calendar weeks.
*
* @author Karsten Kroesch
*/
@kkroesch
kkroesch / AbstractUndoTableModel.java
Created October 1, 2015 09:07
Base class to enable undo-support for JTable
/*
* Copyright &copy; 2005 by Karsten Kroesch.
*/
import java.util.List;
import java.awt.Toolkit;
import java.awt.datatransfer.*;
import java.io.IOException;
import javax.swing.event.UndoableEditListener;
import javax.swing.table.AbstractTableModel;
import numpy as np
def GEPP(A, b, doPricing = True):
'''
Gaussian elimination with partial pivoting.
input: A is an n x n numpy matrix
b is an n x 1 numpy array
output: x is the solution of Ax=b
with the entries permuted in
@kkroesch
kkroesch / time-range
Last active August 29, 2015 14:24
time-range
{
"query": {
"bool": {
"must": [
{
"range": {
"_default_.nf_f_event_time_msec": {
"from": "1436140797628",
"to": "1436140797628"
}