Skip to content

Instantly share code, notes, and snippets.

View CloudCray's full-sized avatar

Cloud Cray CloudCray

  • Cedar
  • Cleveland, OH
View GitHub Profile
@CloudCray
CloudCray / colorize_zipcodes.py
Last active August 13, 2018 03:26
Download all US Zip Code Tabulation Area shapefiles (ZCTA) with Python 3
"""
Author: Cloud Cray
Date: 2014-01-04
This is an example script to read Zip Code data from a US shapefile,
then colorize all zip codes, then save the result to a png file.
"""
import shapefile
import matplotlib.patches as patches
@CloudCray
CloudCray / TKInterGUIDict_0.py
Last active August 29, 2015 14:01
GUI with TKinter Gists
from Tkinter import * # Python 2
# from tkinter import * # Python 3
class GuiRec(Frame): # We're going to "inherit" the Frame class.
def __init__(self, master, rec): # What happens when you initialize the GuiRec
Frame.__init__(self, master) # Like any frame, you gotta set the parent.
self.record = rec
# You could also make these "public properties" or whatever. Your call.
@CloudCray
CloudCray / geocode_sample.py
Last active August 29, 2015 14:02
Geocoding with Google Geocoding API
# Keep in mind, google has some strict policy on usage (2,500 per day from any IP address)
# Python 3
# Also see the API docs:
# https://developers.google.com/maps/documentation/geocoding/
import urllib.request
import urllib.parse
from PIL import Image, ImageDraw, ImageFont
from random import randint as rand
# Get the font we want from our OS
# create an image big enough to hold the text
# write on the image
img_font = ImageFont.truetype("courbd.ttf", 280) # Courier New, Bold; Windows 7
im = Image.new("RGB", (2560, 640), "white")
img_draw = ImageDraw.Draw(im)
img_draw.text((0, 0), "Hello World", font=img_font, fill="black")
@CloudCray
CloudCray / comp_manager_entry_list_to_csv.py
Last active August 29, 2015 14:03
Comp Manager Entry List Scraper - Single Event
# Python 3.4
import urllib.request as r
import urllib.parse as p
import gzip
import io
import bs4
import os
import csv
@CloudCray
CloudCray / resolve_shortcuts.py
Created September 9, 2014 14:15
Resolve all shortcuts in the active directory
import os, sys, pythoncom
from win32com.shell import shell
def shortcut_resolves_to(shortcut_path):
shortcut = pythoncom.CoCreateInstance (
shell.CLSID_ShellLink,
None,
pythoncom.CLSCTX_INPROC_SERVER,
shell.IID_IShellLink
)
@CloudCray
CloudCray / CallSolver.vba
Created September 17, 2014 13:52
Solve a cell by changing another cell using Solver in VBA
'' First, you have to open the Visual Basic for Applications editor
'' Tools > References > Check "Solver" (near the top)
'' Setup here: http://imgur.com/UZPmZQQ
Sub MyMacro()
'' x is going to store your target value, which currently sits in cell C5
Dim x As Integer
x = Range("$C$5").Value
@CloudCray
CloudCray / scrape_stock.py
Created November 24, 2014 17:53
Scrape stock price from google finance
# Python 3.4
import urllib
import bs4
def get_stock_price(name):
url = "https://www.google.com/finance"
req = urllib.request.Request(url)
url_full = url + "?" + urllib.parse.urlencode({"q": name})
req = urllib.request.Request(url_full)
@CloudCray
CloudCray / export_to_pdf.py
Last active November 23, 2018 07:25
Quick script to convert IPython Notebooks to PDFs
# Author: Cloud Cray
# 2014-12-30
# Run this script in the same folder as the notebook(s) you wish to convert
# This will create both an HTML and a PDF file
#
# You'll need wkhtmltopdf (this will keep syntax highlighting, etc)
# http://wkhtmltopdf.org/downloads.html
import subprocess
import os
@CloudCray
CloudCray / ndca-adjudicators.py
Last active August 29, 2015 14:14
Download csv of NDCA judges
import urllib
import bs4
import csv
p = urllib.parse
request = urllib.request
url = 'http://www.ndca.org/directories/'
urls = []
for i in range(18): # There are 436 adjudicators right now; the loads in sets of 25. 18 pages needed