Skip to content

Instantly share code, notes, and snippets.

View actongorton's full-sized avatar

A. H. Gorton actongorton

  • A. H. Gorton
  • California
View GitHub Profile
### Keybase proof
I hereby claim:
* I am actongorton on github.
* I am agorton (https://keybase.io/agorton) on keybase.
* I have a public key ASBS6RXDsX-FSV6MVfE4DM2zfOAP_NjSAm16sfmWjpCtqQo
To claim this, I am signing this object:
@actongorton
actongorton / instructions.md
Created August 6, 2018 14:38 — forked from rshorey/instructions.md
description of Lights, Camera, Algorithms session from SRCCON 2018

Lights, Camera, Algorithm

Act out and discuss machine learning algorithms. This activity is from a SRCCON 2018 session led by Jeremy Merrill and Rachel Shorey.

Materials

  • Index cards
  • pens/pencils
  • Dice with varying numbers of faces (several D10 and one D6 for sure)
  • Masking tape to mark floor
  • Paper, easel, marker
  • Stickers in several colors
@actongorton
actongorton / django_reverse_inline.py
Created May 14, 2018 16:03
Django Reverse Inlines
class SchoolAdminForm(forms.ModelForm):
students = forms.ModelMultipleChoiceField(
queryset=Student.objects.all(),
widget=FilteredSelectMultiple(verbose_name='students', is_stacked=False))
class Meta:
model = School
fields = ['your_school_fields_go_here']
def __init__(self, *args, **kwargs):
@actongorton
actongorton / jail_scraper.py
Created March 29, 2016 04:27
Jail Scraper
# coding: utf-8
# import python libraries
from bs4 import BeautifulSoup
import urllib2
from urlparse import urlparse, parse_qs
import re
@actongorton
actongorton / bearing
Last active September 18, 2015 17:15
Calculate direction, bearing, radians and distance between two location points
static double DegreeBearing(
double lat1, double lon1,
double lat2, double lon2)
{
const double R = 6371; //earth’s radius (mean radius = 6,371km)
var dLon = ToRad(lon2-lon1);
var dPhi = Math.Log(
Math.Tan(ToRad(lat2)/2+Math.PI/4)/Math.Tan(ToRad(lat1)/2+Math.PI/4));
if (Math.Abs(dLon) > Math.PI)
dLon = dLon > 0 ? -(2*Math.PI-dLon) : (2*Math.PI+dLon);
@actongorton
actongorton / reverse_geocoding.py
Last active August 29, 2015 14:20
Geocoding Gists
import csv
import time
from pygeocoder import Geocoder
# file to write to:
f = open('results.csv', 'a')
# separate instance to read the file / might just comment this and the if statement out if file does not yet exist
rf = open('results.csv', 'rb')
@actongorton
actongorton / calendar_heatmap.r
Last active August 29, 2015 14:19
Create a Calendar Heatmap using R with the GoogleVis Library
# ###
# Original credit: http://www.r-bloggers.com/calendar-charts-with-googlevis/
# ###
#
# load the csv as a dataframe:
insp_data <- read.csv(insp_avg_scores.csv, as.is=TRUE)
#
# create dates (evaluate the data to find the earliest date)
start.date = "2012-11-19"
end.date = end.date <- Sys.Date()
@actongorton
actongorton / getget.js
Created October 22, 2014 00:07
Get GET and POST values from URL
// get query arguments
var test
var $_GET = {},
args = location.search.substr(1).split(/&/);
for (var i=0; i<args.length; ++i) {
var tmp = args[i].split(/=/);
if (tmp[0] != "") {
test = $_GET[decodeURIComponent(tmp[0])] = decodeURIComponent(tmp.slice(1).join("").replace("+", " "));
}
}
@actongorton
actongorton / api.py
Last active August 29, 2015 14:04
Restaurant Inspections v3.0
from django.conf.urls import url
from tastypie.paginator import Paginator
from tastypie.exceptions import BadRequest
from tastypie import fields
from tastypie.resources import ModelResource, ALL_WITH_RELATIONS
from haystack.query import SearchQuerySet
from restaurants.models import RestaurantInformation, InspectionInformation
class InspectionResource(ModelResource):
@actongorton
actongorton / admin.py
Created May 28, 2014 02:16
Housing Inspections
from django.contrib import admin
from housing.models import HouseInformation, InspectionReport
class InspectionReportInline(admin.TabularInline):
model = InspectionReport
class InspectionReportAdmin(admin.ModelAdmin):
inlines = [
InspectionReportInline
]