Skip to content

Instantly share code, notes, and snippets.

@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 }%
{%
@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):
#!/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
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
@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
@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")
'&#116;&#101;&#115;&#116;&#64;&#119;&#101;&#98;&#115;&#105;&#116;&#101;&#46;&#111;&#114;&#103'
'''
@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 / 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 / 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):