Skip to content

Instantly share code, notes, and snippets.

View jessedhillon's full-sized avatar

Jesse Dhillon jessedhillon

View GitHub Profile
# http.py
# usage: python -m http port
# e.g.: python -m http 8080
import sys
from random import randint
from SimpleHTTPServer import SimpleHTTPRequestHandler
from SocketServer import TCPServer
@jessedhillon
jessedhillon / human_evasion.md
Created December 18, 2012 23:26
The Human Evasion, Celia Green -- Markdown
<title>The Human Evasion</title>

The Human Evasion

by Celia Green

@jessedhillon
jessedhillon / findoriginal.py
Created May 19, 2013 07:40
First, the *good* answer is just a cleaned up version of your solution -- the main difference is that I'm leveraging the ability of Python `for ... in` loops to iterate through a string. The *better?* answer uses another optimization (or is it really optimized?) -- try and understand what it's doing.
# return the first non repeated character in a string
def find_original(string):
count_dict = {}
order = []
for char in string:
if char in count_dict:
count_dict[char] += 1
else:
count_dict[char] = 1
@jessedhillon
jessedhillon / heatmap.py
Created June 24, 2013 22:01
Distance-decayed weighted average heatmaps
from cStringIO import StringIO
import Image
import logging
import math
import numpy as np
import geoalchemy.functions as functions
from geoalchemy import WKTSpatialElement
from project.lib.models import Listing
@jessedhillon
jessedhillon / divided_times.js
Created August 16, 2014 23:36
Refactor of The Divided Times
$(document).ready(function(){
$('#primary-nav li').on('click', function(event) {
event.preventDefault();
var topic = $(this).attr('class').split(' ')[0];
doNavigationEffect(topic);
});
function doNavigationEffect(theTopic) {
// switching the active tab
@jessedhillon
jessedhillon / stringFormat.js
Created August 17, 2014 04:19
Nice and crappy string formatting in Javascript
String.prototype.format = function(args) {
var paramsRegex = /\(([A-Za-z_0-9:.,\'\"]*)\)/;
var replaceRegex = /{([A-Za-z_0-9:.,\'\"\(\)]+)}/g;
var string = this;
return string.replace(replaceRegex, function(match, key) {
if(/:/.test(key)) {
var filters = key.split(':');
var value = args[filters.shift()];
for(var i = 0; i < filters.length; i++) {
var filterName = filters[i];
@jessedhillon
jessedhillon / gamail.js
Created September 20, 2014 20:41
GAmail.js
GAmail = function(options, data) {
this.options = options;
this.data = data;
this.currentUser = randomElement(data.friends);
this.labels = [{
id: 'inbox',
displayName: 'Inbox',
}, {
id: 'important',
displayName: 'High Priority',
@jessedhillon
jessedhillon / carousel.html
Created November 20, 2014 04:36
Basic Angular Carousel Example
@jessedhillon
jessedhillon / style.css
Created January 7, 2015 04:08
Submenu example
#menubar {
position: absolute;
top: 300px;
left: 300px;
width: 500px;
background: #aaa;
}
.menu {
margin: 0;
@jessedhillon
jessedhillon / iconbox.html
Created January 7, 2015 04:11
Images, icons and boxes
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="icon-box left-icon width-2">
<div class="icon">
<img src="http://placehold.it/48x48">