This file contains 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
#!/usr/bin/python | |
import sqlite3 | |
import os | |
import sys | |
from applescript import asrun | |
from subprocess import Popen, PIPE | |
import shutil | |
import requests | |
import json |
This file contains 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
// Change straight quotes to curly and double hyphens to em-dashes. | |
function smarten(a) { | |
a = a.replace(/(^|[-\u2014/(\[{"\s])'/g, "$1\u2018"); // opening singles | |
a = a.replace(/'/g, "\u2019"); // closing singles & apostrophes | |
a = a.replace(/(^|[-\u2014/(\[{\u2018\s])"/g, "$1\u201c"); // opening doubles | |
a = a.replace(/"/g, "\u201d"); // closing doubles | |
a = a.replace(/--/g, "\u2014"); // em-dashes | |
return a | |
}; |
This file contains 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
set remindersOpen to application "Reminders" is running | |
set monthAgo to (current date) - (30 * days) | |
tell application "Reminders" | |
set myLists to name of every list | |
repeat with thisList in myLists | |
tell list thisList | |
delete (every reminder whose completion date is less than monthAgo) | |
end tell | |
end repeat |
This file contains 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
#!/usr/bin/python | |
from plistlib import readPlist | |
from os import environ | |
from cgi import escape | |
# OPML template with header and footer. | |
opml = '''<?xml version="1.0"?> | |
<opml version="1.1"> | |
<head> |
This file contains 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 sys | |
import location, time | |
import urllib, webbrowser | |
# Handle argument, if present. | |
try: | |
a = sys.argv[1] | |
except IndexError: | |
a = '' |
This file contains 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
-- A function for escaping URLs and skeleton code for a test. | |
on URLescape(myURL) | |
set myURL to quoted form of myURL | |
set myURL to text from character 2 to -2 of myURL | |
set cmd to " | |
from urllib import quote | |
print quote(\"" & myURL & "\", \"/:\") | |
" | |
--return cmd |
This file contains 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
set myTag to "thingy" | |
tell application "Safari" to set theURL to the URL of the front document | |
set cmd to "echo '" & theURL & "' | perl -pe 's#^.*/(?:dp|gp/product)/([^/?]+).*$#$1#'" | |
set itemID to do shell script cmd | |
set aLink to "http://www.amazon.com/gp/product/" & itemID & "?tag=" & myTag |
This file contains 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
#!/usr/bin/python | |
from icalendar import Calendar | |
import sys | |
import copy | |
from datetime import timedelta | |
for ics in sys.argv[1:]: | |
# Open the ics file and extract the event and alarm. | |
cal = Calendar.from_ical(open(ics).read()) |
This file contains 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
#!/usr/bin/python | |
import Image | |
import base64, zlib | |
# Jay Parlar convinced me to turn this data structure | |
# from a dictionary into an object. | |
class PackedImage(object): | |
def __init__(self, mode, size, data): | |
self.mode = mode |
This file contains 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
#!/usr/bin/python | |
# -*- coding: utf-8 -*- | |
from sys import argv | |
from time import strftime | |
clocks = {'12:00': '🕛', '12:30': '🕧', '1:00': '🕐', '1:30': '🕜', | |
'2:00': '🕑', '2:30': '🕝', '3:00': '🕒', '3:30': '🕞', | |
'4:00': '🕓', '4:30': '🕟', '5:00': '🕔', '5:30': '🕠', | |
'6:00': '🕕', '6:30': '🕡', '7:00': '🕖', '7:30': '🕢', |
NewerOlder