Skip to content

Instantly share code, notes, and snippets.

View mattliving's full-sized avatar

Matthew Livingston mattliving

View GitHub Profile
@mattliving
mattliving / airbnb-avg-prices.js
Created February 5, 2016 23:10
Airbnb average price of area (for shown tooltips)
$('.map-marker .tooltip').map(function(i, node) { return Number($(node).text().replace(/(\s*[£])|(\s*$)/g, '')) }).toArray().reduce(function(sum, val) { return sum + val }, 0) / $('.map-marker .tooltip').length
@mattliving
mattliving / designer.html
Last active August 29, 2015 14:08
designer
<link rel="import" href="../core-ajax/core-ajax.html">
<link rel="import" href="../google-map/google-map.html">
<polymer-element name="my-element">
<template>
<style>
:host {
position: absolute;
width: 100%;
@mattliving
mattliving / findfact.py
Created June 7, 2012 13:02
Find the first factor of a number in Python
#!/usr/bin/env
def findfact(n):
for x in xrange(2,n+1):
if (n % x) == 0:
return x
return n
print findfact(11)
@mattliving
mattliving / palin.py
Created June 4, 2012 19:43
palindromic Python algorithm
#!/usr/bin/env
def palin(s):
j = len(s)
if j == 1:
return True
i = 0
while i <= j:
if s[i] != s[j-1]:
return False
@mattliving
mattliving / sums.py
Created June 3, 2012 19:09
Simple Dynamic Programming in Python
def main():
coins = [1, 3, 5]
S = 11
M = [946958486]*(S+1)
M[0] = 0
print M
for i in range(1, S+1):
for j in range(0, len(coins)):
if coins[j] <= i and M[i-coins[j]]+1 < M[i]:
M[i] = M[i-coins[j]]+1