Skip to content

Instantly share code, notes, and snippets.

@schocco
schocco / mongo_import.py
Created January 4, 2019 08:45
Import JSON Lines in batches into MongoDB
#!/usr/bin/env python3
import argparse
import json
import os
from concurrent.futures import ProcessPoolExecutor
from pymongo import MongoClient
from gpx import Track
@schocco
schocco / git-features-u-should-start-using.md
Last active April 3, 2018 08:11
git features that you should start using

git features that you should start using

A collection of basic and advanced features which come in handy for developers but are not known or used by many among us.

First of all: don't be afraid of command line interfaces!

Managing the git history

rewriting with interactive rebase and amend searching in the history https://git-scm.com/book/en/v2/Git-Tools-Searching

@schocco
schocco / concat-stock-csvs.ipynb
Created January 15, 2018 19:20
Concat Stock Market Data CSVs
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@schocco
schocco / crop-border.sh
Created March 27, 2015 11:05
remove letterbox border with ffmpeg
#!/bin/bash
# autodetect crop size
crop=`ffmpeg -i $1 -t 1 -vf cropdetect -f null - 2>&1 | awk '/crop/ { print $NF }' | tail -1`
# cut string from "crop=1280:528:0:0" to "crop=1280:528"
crop=`echo "${crop%:*}"`
crop=`echo "${crop%:*}"`
echo "detected crop fromat: $crop"
echo "input: $1"
echo "output: $2"
#!/usr/bin/env python3
# coding=utf-8
import sys, getopt
def update_progress(progress, barLength = 12, status = ""):
'display a progress bar in the console and update in-place'
if isinstance(progress, int):
progress = float(progress)
if not isinstance(progress, float):
progress = 0
@schocco
schocco / issues.py
Created June 20, 2013 14:14
quick and dirty script to transfer passed proposals from the iuf committee to a github repository. Requires python 2.x
#!/usr/bin/python
# -*- coding: <utf-8> -*-
import getopt
import sys
import urllib2
from urllib2 import URLError, HTTPError
import base64
import json
import getpass
from BeautifulSoup import BeautifulSoup, Tag
ab -n10000 -c100 http://127.0.0.1:8080/index.html
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking 127.0.0.1 (be patient)
Completed 1000 requests
Completed 2000 requests
Completed 3000 requests
Completed 4000 requests
#!/bin/bash
if [ $# == 1 ]; then
echo building pdf...
pdflatex $1.tex
biber $1
makeindex $1.nlo -s nomencl.ist -o $1.nls
pdflatex $1.tex
pdflatex $1.tex
@schocco
schocco / pubkey_enc.py
Created June 5, 2012 00:12
Public key encryption - Diffie–Hellman key exchange
# -*- coding: utf-8 -*-
'''
A very basic example for the Diffie–Hellman key exchange.
'''
class Machine(object):
'''
Represents a machine in the network
'''
def __init__(self, private_key, shared_keyset):
@schocco
schocco / gist:1781655
Created February 9, 2012 18:06
Simple loop for printing stars
% required packages
\usepackage{ifthen}
\usepackage{bbding} % for star symbols
% command for star printing
% \level{3} would print 3 stars
\newcounter{levelcounter} %init counter
\newcommand{\level}[1]{%
\ifthenelse{ \value{levelcounter}<#1 }%
{%