Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf8 -*- | |
def countdown(counter, s): | |
""" | |
Print factorial numbers of emoji beasts | |
Inspired by @direlog | |
""" | |
if counter < 1: | |
return | |
else: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# original: http://julianoliver.com/output/log_2014-05-30_20-52 | |
# GLASSHOLE.SH | |
# | |
# Find and kick Google Glass devices from your local wireless network. Requires | |
# 'beep', 'arp-scan', 'aircrack-ng' and a GNU/Linux host. Put on a BeagleBone | |
# black or Raspberry Pi. Plug in a good USB wireless NIC (like the TL-WN722N) | |
# and wear it, hide it in your workplace or your exhibition. | |
# | |
# Save as glasshole.sh, 'chmod +x glasshole.sh' and exec as follows: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pysal.esda.mapclassify import Natural_Breaks as nb | |
# Calculate Jenks natural breaks | |
# Assumes that there are no NaN values in Series | |
breaks = nb( | |
df['column'].values, | |
initial=300, | |
k=5) | |
jb = pd.DataFrame({'jenks_bins': breaks.yb}, index=df['column'].index) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from statsmodels.stats.outliers_influence import summary_table | |
from statsmodels.sandbox.regression.predstd import wls_prediction_std | |
# carry out yr fit | |
# ols cinv | |
st, data, ss2 = summary_table(ols_fit, alpha=0.05) | |
fittedvalues = data[:,2] | |
predict_mean_se = data[:,3] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
import numpy as np | |
from pysal.esda.mapclassify import Natural_Breaks as nb | |
df = pd.DataFrame({'density': np.random.randint(0, 10, 500)}) | |
# replace zero values with NaN | |
df.replace(to_replace={'density': {0: np.nan}}, inplace=True) | |
breaks = nb(df[df['density'].notnull()].density.values, k=5) | |
# this index will allow us to perform the join correctly |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
from pprint import pprint as pp | |
def jenks_matrices_init(data, n_classes): | |
#fill the matrices with data+1 arrays of n_classes 0s | |
lower_class_limits = [] | |
variance_combinations = [] | |
for i in xrange(0, len(data)+1): | |
temp1 = [] | |
temp2 = [] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import matplotlib.pyplot as plt | |
from matplotlib.collections import PatchCollection | |
from descartes import PolygonPatch | |
import fiona | |
from shapely.geometry import Polygon, MultiPolygon, shape | |
# We can extract the London Borough boundaries by filtering on the AREA_CODE key | |
mp = MultiPolygon( | |
[shape(pol['geometry']) for pol in fiona.open('data/boroughs/boroughs.shp') | |
if pol['properties']['AREA_CODE'] == 'LBO']) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
required packages: | |
numpy | |
matplotlib | |
basemap: http://matplotlib.org/basemap/users/installing.html | |
shapely: https://pypi.python.org/pypi/Shapely | |
descartes: https://pypi.python.org/pypi/descartes | |
random | |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.