Skip to content

Instantly share code, notes, and snippets.

@MaZderMind
MaZderMind / require.js
Last active August 29, 2015 14:01 — forked from louisstow/require.js
/**
* Shim the require function used in node.js
*/
(function() {
if (window.require !== undefined)
throw 'RequireException: \'require\' already defined in global scope';
window.require = function(module) {
var url = window.require.resolve(module);
@MaZderMind
MaZderMind / docrypt.py
Created May 28, 2014 13:50
generte a unix-shadow-compatible password on systems with python <3.3
#!/usr/bin/python
# Wrapper to the POSIX crypt library call and associated functionality.
import sys
import crypt as _crypt
import string as _string
from random import SystemRandom as _SystemRandom
from collections import namedtuple as _namedtuple
@MaZderMind
MaZderMind / guthaben.sh
Created June 5, 2014 16:14
Aktuelles Guthaben via Shell von einem angeschlossenen Prepaid-USB-3G-Stick auslesen. Getestet mit Congstar Prepaid-Stick.
#!/bin/sh
export LANG=C
echo "wait 60 seconds"
{
gammu getussd "*100#" |\
grep reply |\
awk '{print substr($4, 2, length($4)-2)}' |\
sed 's/\([0-9A-F]\{2\}\)/\\\\\\x\1/gI' |\
xargs printf;
} &
@MaZderMind
MaZderMind / gist:635538724c885a63e1c3
Created July 31, 2014 20:18
libleibzig w/ unicode - \o/ - yay
mkdir test; chdir test
virtualenv -p python3 .
./bin/pip install -U setuptools
./bin/pip install https://github.com/MaZderMind/libleipzig-python/archive/master.zip
./bin/python
Python 3.3.2+ (default, Feb 28 2014, 00:52:16)
[GCC 4.8.1] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import libleipzig
>>> >>> print(libleipzig.Cooccurrences("müde", 0, 1, corpus="de"))
@MaZderMind
MaZderMind / bgpdump_to_asn.py
Last active August 29, 2015 14:08
bgpdump to postges
# echo 'DROP TABLE IF EXISTS asn_lookup; CREATE TABLE asn_lookup (prefix INET, asn BIGINT, name VARCHAR(500))' | psql
# bgpdump -m latest-bview.gz | python bgpdump_to_asn.py data-used-autnums | psql -c 'COPY asn_lookup FROM STDIN'
# echo 'CREATE INDEX asn_prefix ON asn_lookup (prefix);' | psql
# echo "SELECT * FROM asn_lookup WHERE prefix >> '`curl -s http://wtfismyip.com/text`';" | psql
import fileinput
import sys
import re
reload(sys)
@MaZderMind
MaZderMind / media_ccc_de.py
Created April 9, 2015 12:20
media_ccc_de livestreamer plugin
"""Plugin for media.ccc.de
Supports:
- http://media.ccc.de
- http://streaming.media.ccc.de (not yet implemented)
"""
import re
import requests
import json
@MaZderMind
MaZderMind / gist:5ef15902e0a3e6b04d47
Created April 28, 2015 12:57
jQuery - Wait for multiple Ajax-Calls
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<script src="https://code.jquery.com/jquery-1.11.2.min.js"></script>
<script>
var reqs = [];
@MaZderMind
MaZderMind / log-after
Created June 6, 2015 03:57
gstreamer interaudiosrc timestamps before and after the a/v-sync-patch
outgoing dumb gap ts 0:00:00.000000000 duration 0:00:00.025000000
outgoing dumb gap ts 0:00:00.025000000 duration 0:00:00.025000000
outgoing dumb gap ts 0:00:00.050000000 duration 0:00:00.025000000
outgoing dumb gap ts 0:00:00.075000000 duration 0:00:00.025000000
outgoing dumb gap ts 0:00:00.100000000 duration 0:00:00.025000000
outgoing dumb gap ts 0:00:00.125000000 duration 0:00:00.025000000
outgoing dumb gap ts 0:00:00.150000000 duration 0:00:00.025000000
outgoing dumb gap ts 0:00:00.175000000 duration 0:00:00.025000000
outgoing dumb gap ts 0:00:00.200000000 duration 0:00:00.025000000
outgoing dumb gap ts 0:00:00.225000000 duration 0:00:00.025000000
[
{
"conference": "32C3",
"group": "Lecture Rooms",
"rooms": [
{
"slug": "hall1",
"schedulename": "Hall 1",
"thumb": "https://streaming.media.ccc.de/32c3/../thumbs/s1.png",
"link": "https://streaming.media.ccc.de/32c3/hall1/",
@MaZderMind
MaZderMind / easing.py
Last active August 29, 2015 14:26 — forked from th0ma5w/easing.py
Easing Equations in Python (orig by Robert Penner)
# ported from http://www.gizma.com/easing/ to https://gist.github.com/th0ma5w/9883420
# added some from https://gist.github.com/cleure/e5ba94f94e828a3f5466
# added some from http://gsgd.co.uk/sandbox/jquery/easing/jquery.easing.1.3.js
import math
def easeLinear(t, b, c, d):
return c*t/d + b
def easeInQuad(t, b, c, d):