Skip to content

Instantly share code, notes, and snippets.

import urllib2, json, re
raw = open("data.txt").read() #[\w\d]{2}:[\w\d]{2}:[\w\d]{2}:[\w\d]{2}:[\w\d]{2}
parse = re.compile("\t(.*?)\s((?:[\w\d]{2}:?){6}).*?(-\d+\s*dBm)\s*(-\d+\s*dBm)")
kml = open("data.kml", "w")
#"signal_strength": 8, "request_address": true,
request = '{"version": "1.1.0","host": "maps.google.com","address_language": "en_US", "wifi_towers": [{"mac_address": "%s","age": 0}]}'
kmlHead = '<?xml version="1.0" encoding="UTF-8"?>\n<kml xmlns="http://www.opengis.net/kml/2.2">\n<Folder>\n'
import glob
presets = {}
preset_list = ["default","fastfirstpass","hq","lossless_fast","lossless_max","lossless_medium","lossless_slow","lossless_slower","lossless_ultrafast","max","normal","slowfirstpass"]
for preset_file in preset_list:
current = map(lambda x: x.split("="), open(preset_file + ".ffpreset").read().splitlines())
preset_name = preset_file.replace(".ffpreset", "")
presets[preset_name] = {}
import sqlite3, re, math, os
con = sqlite3.connect(':memory:')
db = con.cursor()
contigs = [425,424,3472,7154,6911,7165,6940,4912,421,422,423,7155]
# Set filename and open input
in_file = open("trimmed.ace", "r")
#include <iostream>
#include <math.h>
using namespace std;
// declare functions
int prime(int n);
int main() {
int n1;
int i;
bool isprime;
@bemasher
bemasher / Henon.py
Created October 27, 2010 06:17
Given a set of x,y data points, a viewport and the recursion depth, calculate box counts at a particular level.
def quarter((x0, y0, x1, y1)):
quadrants = []
# Define the width and height as half the width and height of the given box
width = (max(x0,x1) - min(x0,x1)) / 2.0
height = (max(y0,y1) - min(y0,y1)) / 2.0
# Starting with the bottom left corner
x = min(x0,x1)
# Go through all 4 combinations of adding width and height to x and y
/* LOGISTIC EQUATION */
#include <stdio.h>
#include <math.h>
int main()
{
FILE *fp;
int i;
int k;
@bemasher
bemasher / laplace.cpp
Created November 19, 2010 05:22 — forked from alexg228/laplace
#include <stdio.h>
#include <iostream>
#include <math.h>
using namespace std;
int main(void) {
FILE * fp5;
int Max(11);
double V[20000];
double diff(1.0);
@bemasher
bemasher / ShowRename.py
Created December 2, 2010 00:46
Uses tvrage.com's xml api to retrieve episode titles for a specific show and rename files accordingly.
import glob, os, urllib2, re
from xml.etree import ElementTree
# Input: Takes in "S##E##.avi" or "S##E##.mkv"
# Output: Renames to "S##E## - [Episode title].avi" (or mkv)
# Search: http://services.tvrage.com/feeds/search.php?show=Mythbusters for sid
show_id = 4605
# Get episode list from tvrage.com for the selected show
import gobject
import matplotlib
matplotlib.use('GTKAgg')
import matplotlib.pyplot as plt
current_pos = 0
temps = []
pad = 5.0
import random
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.mlab as mlab
from math import sqrt
def magnitude(x, y, z):
return sqrt(x**2 + y**2 + z**2)
for k in xrange(1,3):