Skip to content

Instantly share code, notes, and snippets.

@zevaverbach
zevaverbach / gist:861aa14e438b2179937d
Created December 23, 2014 06:21
Cats in Hats True/False approach
theCats = {}
for i in range(1,101):
theCats[i] = False
for i in range(1,101):
for cats, hats in theCats.iteritems():
if cats % i == 0:
if theCats[cats] == True:
theCats[cats] = False
### Keybase proof
I hereby claim:
* I am zevav on github.
* I am zevav (https://keybase.io/zevav) on keybase.
* I have a public key whose fingerprint is 96F2 1B88 D92A E682 AD9D FD59 50EB C01D 3390 FFDD
To claim this, I am signing this object:
@zevaverbach
zevaverbach / download_speechmatics_transcripts.py
Created January 27, 2016 22:02
Downloading .json transcripts from Speechmatics with Selenium
from selenium import webdriver
import time
from selenium.webdriver.common.keys import Keys
from config import username, password
"""This downloads *all* the .json transcripts from your Speechmatics account. Why didn't I use the API? The docs are down, so voila."""
fp = webdriver.FirefoxProfile()
fp.set_preference("browser.download.folderList",2)
fp.set_preference("browser.download.manager.showWhenStarting", False)
@zevaverbach
zevaverbach / convert_ghost_markdown_to_lektor.py
Created September 15, 2016 21:06
Convert Ghost blog markdown files to Lektor markdown files
# coding: utf-8
import os
class Converter:
"""Converts Ghost markdown files to Lektor markdown."""
def __init__(self, from_dir, to_dir, author):
self.from_dir = from_dir
self.to_dir = to_dir
self.author = author
@zevaverbach
zevaverbach / Meetup-past-events.py
Last active September 28, 2016 14:19 — forked from samatjain/Meetup-past-events.py
Create an HTML file of all previous events for a Meetup.com group. Forked from https://gist.github.com/samatjain/5ae8860b0754eb1fa3cc.
#!/usr/bin/env python3
"""
This requires a _config.py file containing a dictionary called config.
There should be a dictionary in config for each meetup group, the key
being a shorthand title for the meetup group's name, and the values
dicts with key 'meetup_name' and 'meetup_api_key' with corresponding
values for those.
eg.: config = {'my_cool_meetup':
{'meetup_name': <the value after the '/' in your meetup URL>,
@zevaverbach
zevaverbach / email_automation.py
Created April 13, 2017 16:22
basic email automation proof of concept for teaching
from datetime import date
from email import encoders
from email.mime.application import MIMEApplication
from email.mime.base import MIMEBase
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
import smtplib
from time import sleep
FROM_EMAIL = 'put your from email here (can be same as MAIL_USERNAME)'
@zevaverbach
zevaverbach / named_range.py
Created April 14, 2017 17:05
Get the value of the first cell of a named range from Google Sheets.
import pygsheets
def get_value_of_named_range_from_google_sheet(sheet_name: str, worksheet_title: str, range_name: str) -> str:
"""return the value of the first cell from a named range
great for treating Google Sheets NamedRanges as variables in Python scripts"""
# https://pygsheets.readthedocs.io/en/latest/authorizing.html
gc = pygsheets.authorize(outh_file='client_secret.json', outh_nonlocal=True)
sh = gc.open(sheet_name)
@zevaverbach
zevaverbach / gist:0c33d4bccf413e2debdf8cd4ffc76a8f
Last active September 26, 2017 02:02
Area code to gmt mapping
# http://greatdata.com/areacodetimezone
area_code_gmt_dict = {
201: -5,
202: -5,
203: -5,
205: -6,
206: -8,
207: -5,
208: -7,
@zevaverbach
zevaverbach / get_square_tenders.py
Last active July 16, 2018 13:27
Get tenders from Square, optionally from a specific location and/or time.
"""
The star of this show is get_tenders, which will return all tenders
if there are no keyword arguments supplied, or tenders from a specific location,
and/or before/after datetimes.
For convenience, here are the fields of a Tender:
'id'
'location_id'
'transaction_id'
@zevaverbach
zevaverbach / tic.py
Last active August 17, 2018 11:44
Tic Tac Toe!
from time import sleep
BOARD_WIDTH = 17
LEFT_PAD_30 = " " * 30
LEFT_PAD_10 = " " * 10
WIN_BOXES = [(0, 1, 2),
(3, 4, 5),
(6, 7, 8),
(0, 3, 6),
(1, 4, 7),