Skip to content

Instantly share code, notes, and snippets.

View freddyb's full-sized avatar

Frederik B freddyb

View GitHub Profile
@freddyb
freddyb / pickle_compiler.py
Created August 15, 2012 14:36
compile arbitrary python source code into pickle format. will execute on unpickling
## Frederik Braun, Jun 2011
## Contact: <fb(AT)frederik-braun.com>
## Licence: WTFPL
## Python 2.7x
try:
import cPickle as pickle
except ImportError:
import pickle
@freddyb
freddyb / check.js
Created May 10, 2012 21:19
check code integrity of JS files for ZeroBin (uncompressed version)
// checking integrity of JS files by freddyb
// using SHA256 by Chris Veness, licensed under LGPL
// but, to be honest, do whatever the heck you want
// it's not black magic, you know ;)
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
/* SHA-256 implementation in JavaScript | (c) Chris Veness 2002-2010 | www.movable-type.co.uk */
/* - see http://csrc.nist.gov/groups/ST/toolkit/secure_hashing.html */
/* http://csrc.nist.gov/groups/ST/toolkit/examples.html */
@freddyb
freddyb / check_minified.js
Created May 10, 2012 21:18
check code integrity of JS files for ZeroBin
function getSource(a){x=new XMLHttpRequest;x.open("GET",a,false);try{x.send()}catch(b){console.dir("Could not get JavaScript source due to some external JS references");alert("Code Integrity check failed")}sources.push(x.response.replace(/\s+/g,""));if(sources.length==document.scripts.length){computedHash=Sha256.hash(sources.join(""));console.dir("Hash of all JavaScript is "+computedHash);if(computedHash=="43958ba2baa4cc09552a52066cb13cd732141a4a920f6b4873c44f643ed1985b"){alert("Code Integrity verified")}else{alert("Warning, code integrity error. Do not trust this site with your code")}}}var Sha256={};Sha256.hash=function(a,b){b=typeof b=="undefined"?true:b;if(b)a=Utf8.encode(a);var c=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,11392
@freddyb
freddyb / debug_net.py
Created March 22, 2012 08:09
whenever my intarwebs fail, I debug my connection with this old, dirty hack of a python script
#!/usr/bin/env python
import subprocess
def get_default_gw():
''' returns ip address of default gateway as a string'''
res = subprocess.check_output(['route','-n'])
for line in res.split('\n'):
if line.startswith('0.0.0.0'):
@freddyb
freddyb / rssgrep.py
Created November 4, 2011 21:42
grep for keywords in rss files
import feedparser
import datetime
def main(urls, keywords):
keywords = map(lambda x: x.lower(), keywords)
for url in urls:
print "Starting to parse", url
feed = feedparser.parse(url)
for item in feed['items']:
title_text = item['title_detail']['value']