Skip to content

Instantly share code, notes, and snippets.

View mikeyk's full-sized avatar

Mike Krieger mikeyk

  • San Francisco, CA
View GitHub Profile
from BeautifulSoup import BeautifulSoup
def main():
friendsfl = open('friends.xml')
followersfl = open('followers.xml')
friendsoup = BeautifulSoup(friendsfl)
followsoup = BeautifulSoup(followersfl)
friend_list = set()
follow_list = set()
#!/usr/local/bin/python2.5
from BeautifulSoup import BeautifulSoup
import urllib
import cgitb
import cgi
cgitb.enable()
MAX_PAGES = 50
// ==UserScript==
// @name RetweetHelper
// @namespace retweethelper
// @include http://twitter.com/home
// @exclude http://twitter.com/*/status/*
// ==/UserScript==
/*
by Mike Krieger (@mikeyk)
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html>
<head>
<style type="text/css">
#simone {
background: black;
height: 10px;
width: 500px;
height: 5px;
function normalizeData(data){
for (entry in data) {
var deduplicatedEntries = {};
var originalData = data[entry]['data'];
for (var i = 0; i < originalData.length; i++) {
var keyindex = originalData[i][0];
var value = originalData[i][1];
deduplicatedEntries[keyindex] = (deduplicatedEntries[keyindex] || 0) + value;
}
var deduplicatedArray = [];
NSMutableDictionary * hashedLocations = [NSMutableDictionary dictionaryWithCapacity:100];
NSArray * lastResultList = [dataSource locations];
for (InfoLocation * infoloc in lastResultList) {
InfoLocation * infoLocCopy = [[InfoLocation alloc] initWithInfoLocation:infoloc];
CLLocationCoordinate2D coord = [infoloc coordinate];
NSString * hash = [NSString stringWithFormat:@"%.5f-%.5f", coord.latitude, coord.longitude];
if (![hashedLocations objectForKey:hash]) {
[hashedLocations setValue:[[NSNumber alloc] initWithInt:1] forKey:hash];
} else {
// offset a bit so we don't have a bunch of clustered ones
//
// InfoLocation.h
// sfinfo
//
// Created by Mike Krieger on 8/30/09.
// Copyright 2009 Mike Krieger. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <MapKit/MapKit.h>
- (NSString *)stringFromURL:(NSURL *)url
{
NSURLRequest *urlRequest = [NSURLRequest requestWithURL:url
cachePolicy:NSURLRequestReturnCacheDataElseLoad
timeoutInterval:30];
// Fetch the response
NSData *urlData;
NSURLResponse *response;
NSError *error;
/* for query: nearby?lat=37.756988&lon=-122.394458&boxheight=0.001449&boxwidth=0.001449&days=60&apiv=1 */
{"discarded": 0, "num_results": 51, "result_set": [{"category": "Vehicle Theft", "description": "Stolen automobile", "timestamp": 1250335800.0, "lon": -122.394072983, "incident": "090831906", "lat": 37.7576318072}, {"category": "Assault", "description": "Battery", "timestamp": 1249933500.0, "lon": -122.395208449, "incident": "090813346", "lat": 37.7565874457}, {"category": "Assault", "description": "Battery", "timestamp": 1248226200.0, "lon": -122.395383155, "incident": "090742983", "lat": 37.7568374893}, {"category": "Drug\/narcotic", "description": "Possession of base\/rock cocaine for sale", "timestamp": 1252990860.0, "lon": -122.395636483, "incident": "090949060", "lat": 37.7567322847}, {"category": "Assault", "description": "Battery", "timestamp": 1250029800.0, "lon": -122.395685391, "incident": "090817940", "lat": 37.7570410309}, {"category": "Robbery", "description": "Robbery, armed with a knife",
function Post(){};
Post.prototype = {test : function(){console.log("hello there")}};
p = new Post();
p.test();
/* but I prefer to do two things differently: define my member functions in the 'class' function, and have objects inherit from objects: */
function Post() {
this.test = function(){ console.log("hello there") }
}