Skip to content

Instantly share code, notes, and snippets.

View EmilHernvall's full-sized avatar

Emil Hernvall EmilHernvall

View GitHub Profile
Compiled from "Test1.java"
public class Test1 {
public Test1();
Code:
0: aload_0
1: invokespecial #1 // Method java/lang/Object."<init>":()V
4: return
public static void main(java.lang.String[]);
Code:
import json
import pymysql
import pymysql.cursors
import os
import csv
from datetime import datetime
with open("data/premier-league/schema.json") as fh:
schema = json.loads(fh.read())
fields = schema["fields"]
# -*- coding: utf-8 -*-
def columns_to_county(foo):
county = {}
county["id"] = int(foo[0])
county["name"] = foo[1]
county["lon"] = float(foo[3])
county["lat"] = float(foo[4])
return county

Keybase proof

I hereby claim:

  • I am emilhernvall on github.
  • I am aderyn (https://keybase.io/aderyn) on keybase.
  • I have a public key whose fingerprint is 8684 23E6 23E7 9338 7711 E0E1 5537 3432 E97B 576A

To claim this, I am signing this object:

Keybase proof

I hereby claim:

  • I am EmilHernvall on github.
  • I am aderyn (https://keybase.io/aderyn) on keybase.
  • I have a public key whose fingerprint is 5B7E 106F 7A1F B3B2 8236 78E1 398A 0566 9E87 493F

To claim this, I am signing this object:

@EmilHernvall
EmilHernvall / proxy.py
Last active October 17, 2023 20:30
Transparent proxy for rewriting web pages to include The Hoff
"""
Install twisted (pip install twisted) and PIL (pip install PIL), and run the script.
On your gateway, run the following commands:
iptables -t nat -A PREROUTING -i br0 -s ! 192.168.0.20 -p tcp --dport 80 -j DNAT --to 192.168.0.20:8080
iptables -t nat -A POSTROUTING -o br0 -s 192.168.0.0/24 -d 192.168.0.20 -j SNAT --to 192.168.0.1
iptables -A FORWARD -s 192.168.0.0/24 -d 192.168.0.20 -i br0 -o br0 -p tcp --dport 8080 -j ACCEPT
Substitute 192.168.0.20 for the computer running the proxy.
"""
@EmilHernvall
EmilHernvall / route53_dyndns.py
Created April 10, 2013 13:22
Script for dynamically updating a route53 record when your external ip changes.
#!/usr/bin/python
import boto.route53
import os
import sys
import urllib2
import time
def get_zone_id(r53, zone_name):
zone_result = r53.get_hosted_zone_by_name(zone_name)
if not zone_result:
import urllib2
import re
import base64
def searchForNext(str, unique):
d = 10
last = str[-d:]
print "searching for continuation of " + last
matches = []
for x in unique:
@EmilHernvall
EmilHernvall / data2sound.py
Created September 29, 2011 14:07
Encode data as sound, and retrieve it using a FFT
class GlobalFormat(object):
def __init__(self):
self.id = 0x46464952 # RIFF
self.size = 0
self.type = 0x45564157 # WAVE
def as_bin(self):
return struct.pack("III", self.id, self.size, self.type)
@EmilHernvall
EmilHernvall / sudoku.c
Created June 24, 2011 15:18
sudoku solver written in c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef struct grid_t_ {
unsigned int grid[81];
struct grid_t_ *next;
} grid_t;
typedef struct sub_t_ {