Skip to content

Instantly share code, notes, and snippets.

View kkroesch's full-sized avatar

Karsten Kroesch kkroesch

View GitHub Profile
#
# Minimal CORS config for nginx
#
# A modification of https://gist.github.com/alexjs/4165271
#
# NB: This relies on the use of the 'Origin' HTTP Header.
location /static {
if ($http_origin ~* (whitelist\.address\.one|whitelist\.address\.two)$) {

Description

This simple script will take a picture of a whiteboard and use parts of the ImageMagick library with sane defaults to clean it up tremendously.

The script is here:

#!/bin/bash
convert "$1" -morphology Convolve DoG:15,100,0 -negate -normalize -blur 0x1 -channel RBG -level 60%,91%,0.1 "$2"

Results

* {
font-size: 12pt;
font-family: monospace;
font-weight: normal;
font-style: normal;
text-decoration: none;
color: black;
cursor: default;
}
@kkroesch
kkroesch / recent-50
Last active August 29, 2015 14:24
Elasticsearch Netflow Search API
curl -X POST -d '
{
"query": {
"bool": {
"must": [
{
"match_all": {}
}
],
"must_not": [],
@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"
}
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 / AbstractUndoTableModel.java
Created October 1, 2015 09:07
Base class to enable undo-support for JTable
/*
* Copyright © 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;
@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 / 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 / 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)