Instantly share code, notes, and snippets.

🎯
Focusing

Josh Geller joshgeller

View GitHub Profile
@joshgeller
joshgeller / cities.json
Last active Jan 14, 2019 — forked from Miserlou/cities.json
1000 Largest US Cities By Population With Geographic Coordinates and Timezone, in JSON
View cities.json
[
{
"city": "New York",
"growth_from_2000_to_2013": "4.80%",
"latitude": 40.7127837,
"longitude": -74.0059413,
"population": 8405837,
"rank": 1,
"state": "New York",
"timezone": "America/New_York"
@joshgeller
joshgeller / today_to_midnight_utc.py
Created May 2, 2018
Convert local date to midnight UTC timestamp
View today_to_midnight_utc.py
import pytz
from datetime import date, datetime, time
def today_to_midnight_utc(local_tz='UTC'):
"""
Returns today's date (local timezone) as a midnight UTC timestamp.
e.g. If date is 04/20/18, and server timezone is America/Los_Angeles:
today_to_midnight_utc(local_tz='America/Los_Angeles')
>> 1524182400
@joshgeller
joshgeller / importcsv.py
Last active Aug 29, 2015
Add contents of specified columns in .csv file to a list of dictionaries
View importcsv.py
import csv
def import_csv(filename=None, import_all_columns=False, columns_to_import=None, remove_duplicates=False):
"""
Add contents of specified columns in .csv file to a list of dictionaries.
:param filename: string
:param import_all_columns: bool
:param columns_to_import: list