Skip to content

Instantly share code, notes, and snippets.

View yuletide's full-sized avatar
🤘

Alex Yule yuletide

🤘
View GitHub Profile
@omarish
omarish / gist:3080200
Created July 10, 2012 00:42
Priceonomics Puzzles

Priceonomics Programming Puzzle, Summer 2012

We love solving puzzles at Priceonomics. We also like meeting people who like to solve puzzles. Here are two interesting puzzles we've faced at some point in the past months that we'd like to share with you.

If you have any questions, contact [email protected].


Puzzle 1: Heatwave

anonymous
anonymous / income_df
Created June 14, 2012 22:43
income_df
all_tracts = lapply(income, function(county)
lapply(county$tracts, function(tract) as.data.frame(c(county[1:3],tract))))
all_tracts_temp = lapply(all_tracts, function(county) as.data.frame(do.call(rbind, county)))
income_df = as.data.frame(do.call(rbind, all_tracts_temp))
summary(income_df)
ff = as.numeric(income_df$medianIncome)
ff = as.numeric(as.character(income_df$medianIncome))
income_df$medianIncome = as.numeric(as.character(income_df$medianIncome))
@jboner
jboner / latency.txt
Last active April 29, 2025 15:40
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
@scw
scw / true-distance-to-shore.py
Created May 30, 2012 20:03
Example using OGR and Shapely to compute true distances between geometries and points.
#!/usr/bin/env python
# distance_from_shore.py: compute true distance between points
# and closest geometry.
# shaun walbridge, 2012.05.15
# TODO: no indexing used currently, could stand if performance needs
# improving (currently runs in ~1.5hr for 13k points)
from geopy import distance
@companje
companje / FibonacciSpiral.pde
Created May 21, 2012 22:32
Fibonacci Spiral in Processing
float phi = (sqrt(5)+1)/2;
size(323,200);
translate(height/phi,0);
scale(height);
noStroke();
smooth();
for (float i=0; i<10; i++) {
fill(i/10*255);
@tristen
tristen / README.md
Last active June 21, 2016 22:15
Great Circle

Great Circle

Create an arc like shape by specifying two points and drawing the points between them using HTML canvas

Contributors

@erikh
erikh / hack.sh
Created March 31, 2012 07:02 — forked from DAddYE/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#
@jaidevd
jaidevd / ann.py
Created March 24, 2012 22:55
Basic Perceptron Learning for AND Gate
import numpy as np
class Perceptron:
def __init__(self,Weights,Biases):
self.Weights = Weights
self.Biases = Biases
def Train(self, Training, LearningRate):
if (typeof (AC) === "undefined") {
AC = {}
}
AC.ImageReplacer = Class.create({
_defaultOptions: {
listenToSwapView: true,
filenameRegex: /(.*)(\.[a-z]{3}($|#.*|\?.*))/i,
filenameInsert: "_☃x",
ignoreCheck: /(^http:\/\/movies\.apple\.com\/|\/105\/|\/global\/elements\/quicktime\/|_(([2-9]|[1-9][0-9]+)x|nohires)(\.[a-z]{3})($|#.*|\?.*))/i,
attribute: "data-hires",
@boundsj
boundsj / create_template_postgis.sh
Created March 13, 2012 14:24
Create the postgis template on a mac that had postgis installed from brew
# path taken from brew install notes
POSTGIS_SQL_PATH=/usr/local/share/postgis
# Creating the template spatial database.
createdb -E UTF8 template_postgis
createlang -d template_postgis plpgsql # Adding PLPGSQL language support.
# Allows non-superusers the ability to create from this template
psql -d postgres -c "UPDATE pg_database SET datistemplate='true' WHERE datname='template_postgis';"