Skip to content

Instantly share code, notes, and snippets.

View controversial's full-sized avatar
🧙‍♂️
doing magic

Luke Deen Taylor controversial

🧙‍♂️
doing magic
View GitHub Profile
@controversial
controversial / satellite.py
Created December 19, 2015 18:19
satellite.py
import urllib2
import json
import time
from io import BytesIO
from PIL import Image
URL="https://api.nasa.gov/planetary/earth/imagery?lon={}&lat={}&date={}&api_key={}"
API_KEY="ymjXp9qz2jJDR5tNEb0qa5YekynvAcVLJvKVcxYH"
def get_satellite_image(location=None,date=None):
@controversial
controversial / FTP.py
Created December 26, 2015 19:16
FTP.py
import ftplib, os, shutil, tempfile, time
ftp=ftplib.FTP('ftp.deentaylor.com')
print ftp.login('pythonista@deentaylor.com', 'FTPythonista')
doc_path = os.path.expanduser('~/Documents/')
filename=time.strftime("%Y-%m-%d&%H:%M:%S")
backup_path = filename+'.zip'
if os.path.exists(backup_path):
os.remove(backup_path)
@controversial
controversial / Spirograph.py
Last active January 10, 2016 16:39
Spirograph.py
#Spirograph.py
from math import *
import canvas
canvas.set_size(1024, 768)
import time
COLOR = "#000000"
def rotate(point, angle, center=(0, 0)):
@controversial
controversial / ProgressBadge.py
Last active July 19, 2022 19:31
ProgressBadge.py
from objc_util import *
import time
import notification
APP=UIApplication.sharedApplication()
DISPLAYMODE=0
def setBadge(text):
APP.setApplicationBadgeString_(text)
@controversial
controversial / safarihistory.py
Last active January 26, 2016 23:46
Plot the 25 most common domains found in Safari's history cache using matplotlib
import os
import urllib2
from collections import Counter
#FETCH DATA
files=os.listdir(os.path.expanduser("~/Library/Caches/Metadata/Safari/History"))
webpages=[f for f in files if f.startswith("http")] #https also starts with http
print "Found {} pieces of data".format(len(webpages))
@controversial
controversial / WikiScrape.py
Created January 29, 2016 23:31
Wikipedia Scraper
#Scrapes wikipedia. Start with the name of a page. Then, it will click the first
#5 links on this page. For each of these links, it will click the first 5 links
#on *that* page. It will not stray more than 5 pages away from the start page.
#These attributes can be adjusted by changing BREADTH and MAXDEPTH. This script
#will output a PNG file of your wikipedia map.
#REQUIREMENTS: `wikipedia` and `pydot`
import wikipedia as wp
import pydot
@controversial
controversial / Foundation.py
Created February 6, 2016 20:11
Foundation.py
classes=['NSAKDeserializer', 'NSAKDeserializerStream', 'NSAKSerializer', 'NSAKSerializerStream', 'NSAbstractLayoutGuide', 'NSAddressCheckingResult', 'NSAffineTransform', 'NSArchiver', 'NSArrayChange', 'NSArrayChanges', 'NSAssertionHandler', 'NSAttributedString', 'NSAutoreleasePool', 'NSAutoresizingMaskLayoutConstraint', 'NSBigMutableString', 'NSBlockExpression', 'NSBlockOperation', 'NSBlockPredicate', 'NSBoundKeyPath', 'NSBundle', 'NSBundleResourceRequest', 'NSByteCountFormatter', 'NSCachedURLResponse', 'NSCalendarDate', 'NSCharacterSet', 'NSCheapMutableString', 'NSCoder', 'NSComparisonPredicate', 'NSComparisonPredicateOperator', 'NSComplexOrthography', 'NSComplexRegularExpressionCheckingResult', 'NSCompoundPredicate', 'NSCompoundPredicateOperator', 'NSConcreteAttributedString', 'NSConcreteMutableAttributedString', 'NSConcreteValue', 'NSCondition', 'NSConditionLock', 'NSConstantString', 'NSConstantValueExpression', 'NSContentSizeLayoutConstraint', 'NSCorrectionCheckingResult', 'NSCountedSet', 'NSDashCheckingR
@controversial
controversial / FileListOps.py
Created February 20, 2016 03:06
FileListOps.py
"""A set of operations for working with the file lists returned from zipfile.ZipFile.namelist()"""
import os
def getParentDirs(path):
""" "test/again/hello" -> ["test", "test/again"] """
dirs = path.split("/")[:-1]
if dirs:
return ["/".join(dirs[:i+1]) for i,d in enumerate(dirs) if dirs[:i+1]]
else:
# Tool to sort organization repos by star count, as a workaround for https://github.com/isaacs/github/issues/201.
# It would be *awesome* if GitHub could implement this...
import requests, json
USERNAME = "YOUR_USERNAME_HERE"
PASSWORD = "YOUR_PASSWORD_HERE"
def parse_links(linkstr):
# At the end of paging, 'last' is no longer returned as second link
@controversial
controversial / .hyper.js
Last active February 20, 2017 17:40
Hyper config
module.exports = {
config: {
// default font size in pixels for all tabs
fontSize: 12,
// font family with optional fallbacks
fontFamily: '"Fira Code", Menlo, "DejaVu Sans Mono", "Lucida Console", monospace',
// terminal cursor background color and opacity (hex, rgb, hsl, hsv, hwb or cmyk)
cursorColor: '#cdd2e9',