Skip to content

Instantly share code, notes, and snippets.

View DavidHickman's full-sized avatar

David Hickman DavidHickman

View GitHub Profile
import folium
def simple_folium_map(lat, lng, description):
"""
Create a simple webmap with a green circle marker
Stamen map tile options = ['Stamen Toner', 'Stamen Terrain']
"""
# Create webmap html
@DavidHickman
DavidHickman / get_weekdays_in_month.py
Last active July 19, 2016 21:55
Get all dates of a weekday for a month/year. For example, all Tuesdays in July, 2016.
import datetime
import calendar
def get_weekdays_in_month(weekday, month, year):
"""
Calculate a list of all dates of a given weekday in a particular month/year
:param weekday: (str) String of the day of the week
:param month: (int) of the month within the year
:param year: (int) four-digit year
import os
def clean_up_folder(dir_path, ext_keep=(".zip", ".kmz", ".GeoJSON", ".csv")):
"""
Loop through a directory looking for files with extensions
that match an extension in an array. If the file's extension
does not match, delete the file.
:param dir_path: (str) path to directory to search
@DavidHickman
DavidHickman / .gitignore_global
Created October 27, 2016 16:55
Global .gitignore file adding *.pyc and the recommended JetBrains IDE files
# Compiled source #
###################
*.com
*.class
*.dll
*.exe
*.o
*.pyc
*.so
@DavidHickman
DavidHickman / layout.html
Created December 6, 2016 15:55
Adding Bootstrap alerts as Flask flash messages
{% with messages = get_flashed_messages() %}
{% if messages %}
<ul class="flashes list-group">
{% for message in messages %}
<li class="list-group-item">
<div class="alert alert-success">{{message}}</div>
</li>
{% endfor %}
</ul>
{% endif %}
@DavidHickman
DavidHickman / index.html
Last active October 24, 2017 05:02
Leaflet Geoserver example
<!DOCTYPE html>
<html>
<head>
<title>Geoserver layer in Leaflet Example</title>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="shortcut icon" type="image/x-icon" href="docs/images/favicon.ico"/>
<link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/leaflet.css"
integrity="sha512-M2wvCLH6DSRazYeZRIm1JnYyh22purTM+FDB5CsyxtQJYeKq83arPe5wgbNmcFXGqiSH2XR8dT/fJISVA1r/zQ=="
crossorigin=""/>
@DavidHickman
DavidHickman / AnimatronicMusicScene.ino
Last active November 29, 2017 18:18
Arduino code for creating an animatronic scene
#include <SPI.h>
#include <Adafruit_VS1053.h>
#include <SD.h>
// These are the pins used for the music maker shield
const int SHIELD_RESET = -1; // VS1053 reset pin (unused!)
const int SHIELD_CS = 7; // VS1053 chip select pin (output)
const int SHIELD_DCS = 6; // VS1053 Data/command select pin (output)
const int DREQ = 3; // VS1053 Data request, ideally an Interrupt pin