Skip to content

Instantly share code, notes, and snippets.

@RichardHyde
RichardHyde / ROT13.py
Created May 20, 2013 11:07
ROT13 Encryption in Python
#!/usr/bin/python
from string import maketrans
from sys import stdin, stdout
alpha = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
rot13 = 'nopqrstuvwxyzabcdefghijklmNOPQRSTUVWXYZABCDEFGHIJKLM'
r13table = maketrans(alpha, rot13)
orig = stdin.read()
stdout.write(orig.translate(r13table))
@RichardHyde
RichardHyde / gist:5715894
Last active December 18, 2015 03:08
Create OmniFocus items assigned to a context and project from a text file
tell application "OmniFocus"
tell front document
set theContext to first flattened context where its name = "Tesco"
set theProject to first flattened project where its name = "Groceries Shopping"
set txt to (read (POSIX file "/users/rjhyde/Dropbox/Documents/groceries.txt") as «class utf8»)
set gitems to every paragraph of txt
repeat with gitem in gitems
if (length of gitem) > 0 then
tell theProject to make new task with properties {name:gitem, context:theContext}
@RichardHyde
RichardHyde / gist:6130447
Last active December 20, 2015 12:19
Add to Evernote
tell application "Evernote"
activate
set note1 to create note from file theFile notebook {"Notebook Name"} tags {"tag1", "tag 2", "tag 3", "tag 4"}
open note window with note1
end tell
@RichardHyde
RichardHyde / PostToDayOne.py
Created January 20, 2014 22:58
Post to Day One Sublime Text 2 Command
import sublime, sublime_plugin
import urllib, webbrowser
class PostToDayOneCommand(sublime_plugin.TextCommand):
def run(self, edit):
selections = self.view.sel()
selection = self.view.substr(selections[0])
url = "dayone://post?entry=%s" % urllib.quote(selection)
@RichardHyde
RichardHyde / gist:8664682
Created January 28, 2014 09:36
Markdown link bookmarklet
javascript:var str = %27[%27+document.title+%27](%27+document.URL+%27)%27;prompt("Copy...",str);
@RichardHyde
RichardHyde / gist:3386ac57b55455b71140
Last active June 21, 2020 09:09
Convert a date string to a date in Applescript
-- Convert date function. Call with string in YYYY-MM-DD HH:MM:SS format (time part optional)
to convertDate(textDate)
set resultDate to the current date
set the month of resultDate to (1 as integer)
set the day of resultDate to (1 as integer)
set the year of resultDate to (text 1 thru 4 of textDate)
set the month of resultDate to (text 6 thru 7 of textDate)
set the day of resultDate to (text 9 thru 10 of textDate)
set the time of resultDate to 0
@RichardHyde
RichardHyde / gist:072b9902efce87947c9e
Last active February 16, 2016 11:06
Parse RFC2822 date strings into datetime object
class FixedOffset(tzinfo):
"""Fixed offset in minutes east from UTC."""
def __init__(self, offset, name):
self.__offset = timedelta(minutes=offset)
self.__name = name
def utcoffset(self, dt):
return self.__offset
def tzname(self, dt):
return self.__name
def dst(self, dt):
@RichardHyde
RichardHyde / keybase.md
Created March 13, 2017 09:48
Proof for Keybase.io

Keybase proof

I hereby claim:

  • I am RichardHyde on github.
  • I am richardhyde (https://keybase.io/richardhyde) on keybase.
  • I have a public key whose fingerprint is 0613 FD8F CAD4 DB02 A8F9 9544 2C9F 9316 06A2 8316

To claim this, I am signing this object: