This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'' 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Python 3.4 | |
import urllib.request as r | |
import urllib.parse as p | |
import gzip | |
import io | |
import bs4 | |
import os | |
import csv |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
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 |
NewerOlder