Skip to content

Instantly share code, notes, and snippets.

@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 / tex.py
Created December 29, 2011 00:36
Django filters, needed when creating LaTeX files with the django template language
# -*- coding: utf-8 -*-
'''
Django filters, needed when creating LaTeX files with the django template language
'''
from django.template.defaultfilters import stringfilter, register
from django.template.loader import render_to_string
@register.filter
@stringfilter
def brackets(value):
@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 / 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 / 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 / gist:1762611
Created February 7, 2012 22:36
encode any string to html
# can be used to hide email addresses in the html source of Web sites from spiders
def html_encode(email):
'''
Takes a unicode string as only parameter and returns
a sequence of html encoded chars.
>>> html_encode(u"test@website.org")
'test@website.or&#103'
'''
@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