Skip to content

Instantly share code, notes, and snippets.

View davidbody's full-sized avatar

David W. Body davidbody

View GitHub Profile
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
# project/management/commands/showurls.py
# Put a __init__.py file in project/management/ and project/management/commands/
from django.conf import settings
from django.core.management.base import BaseCommand, CommandError
from django.urls import URLPattern, URLResolver
class Command(BaseCommand):
help = 'Shows all urls for the current project'
@davidbody
davidbody / Julia_notebook.ipynb
Created April 15, 2019 13:02
Jupyter notebook examples
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@davidbody
davidbody / fib.py
Created March 14, 2019 19:54
TDD Fibonaci numbers
def memoize(func):
cache = {}
def wrapper(n):
if not n in cache:
cache[n] = func(n)
return cache[n]
return wrapper
@memoize
def fib(num):
@davidbody
davidbody / graze.jl
Created October 15, 2018 00:13
Julia code for 12-Oct-2018 Riddler about the goat
# https://fivethirtyeight.com/features/so-you-want-to-tether-your-goat-now-what/
# James Jones's Python solution translated to Julia
using Formatting
function randPoint()
randr = sqrt(rand())
theta = rand() * 2 * π
randr * cos(theta), randr * sin(theta)
end
@davidbody
davidbody / graze-plot.png
Last active October 14, 2018 22:03
Plotting the solution to the 12-Oct-2018 riddler about the goat
graze-plot.png
@davidbody
davidbody / iowa-shapfiles-example.R
Created March 7, 2017 15:54
Iowa precinct shapefile example
library(rgdal)
library(broom)
library(ggplot2)
setwd("~/work/data/iowa-election-results/")
# Download the shapefile data if we don't already have it
if (!file.exists("./data")) {
dir.create("./data")
if (!file.exists("./data/pcts_04172014_0908am.zip")) {
module MyApp
def self.api_keys
@api_keys ||= YAML::load_file("#{Rails.root}/config/api-keys.yml")[Rails.env]
end
end
@davidbody
davidbody / .ruby-gemset
Last active October 20, 2015 00:09
Read a Google spreadsheet from Ruby
google-apis
@davidbody
davidbody / keybase.md
Created April 15, 2015 15:22
Keybase proof

Keybase proof

I hereby claim:

  • I am davidbody on github.
  • I am davidbody (https://keybase.io/davidbody) on keybase.
  • I have a public key whose fingerprint is B08E 3971 4F4E E554 080A 51E5 5B74 76EF 8E00 7782

To claim this, I am signing this object: