Skip to content

Instantly share code, notes, and snippets.

View philipbl's full-sized avatar

Philip Lundrigan philipbl

View GitHub Profile
@font-face {
font-family: "Fira Code NF";
font-style: normal;
font-weight: 200;
src: url('https://raw.githubusercontent.com/ryanoasis/nerd-fonts/master/patched-fonts/FiraCode/Light/complete/Fura%20Code%20Light%20Nerd%20Font%20Complete%20Mono.ttf' format('truetype'));
}
@font-face {
font-family: "Fira Code NF";
@philipbl
philipbl / time_test.py
Created April 27, 2017 15:47
Experimenting with time zones with Python datetime module
from __future__ import print_function
from datetime import datetime
import pytz
epoch_time = 1493307387
dt1 = datetime.fromtimestamp(epoch_time)
print("Local time:", dt1)
print("Not tz aware:", dt1.tzinfo)
print()
@philipbl
philipbl / thread_test.py
Created December 1, 2016 18:47
Code that causes persistent queue to crash.
import os
import random
import threading
import uuid
from persistent_queue import PersistentQueue
random.seed(5)
filename = '{}'.format(str(uuid.uuid4()).replace('-', ''))
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@philipbl
philipbl / to_reference.py
Created September 27, 2013 15:39
Converts markdown inline links to reference links. Inspired by Brett Terpstra's to reference service, written in Ruby. This can be used as an OS X service or in a Editorial workflow.
#!/usr/bin/env python
import re
import operator
import re
RE_REF = "\\[(.+?)\\]:\\s*(\\S+(\\s+?\".*\")?)\\s*"
RE_LINK = "\\((https?://(.+?))\\)"
@philipbl
philipbl / time_parser.py
Created September 13, 2013 15:39
Parses time data into total hours. This can be used to parse time card information. See the grammar at the top of the file to know how what is allowed. Example: 10:01 AM to 12:41 PM and 3:15 PM to 6:11 PM - 10 min + 1 hour
#!/usr/bin/env python
import re
from datetime import datetime
# <COMPOUND_STATEMENT> : <STATEMENT> (and <COMPOUND_STATEMENT>)*
# <STATEMENT> : <ABS_TIME> to <ABS_TIME> (<REL_OPERATOR> <REL_TIME>)*
# <REL_OPERATOR> : -, +
# <ABS_TIME> : XX:XX AM|PM
# <REL_TIME> : X+ min|hour|mins|hours
@philipbl
philipbl / search_link.py
Last active December 21, 2015 05:38
Based on Brett Terpstra's SearchLink (https://gist.github.com/ttscoff/3900158), ported over to Python. The reason I ported it over to Python is to be used with Editorial for iPad (http://omz-software.com/editorial/), which can run Python. For more information, visit http://brettterpstra.com/projects/searchlink/
@philipbl
philipbl / pictures.py
Created August 15, 2012 22:58
Finds pictures paths (surrounded with [ ]) and adds a new entry in Day One with the same date and time
#!/bin/python
import os
directory = '/Users/philiplundrigan/Dropbox/Journal_dayone/entries'
src_directory = '/Users/philiplundrigan/Documents/Journal Backups/Journal Backup (2012)/Journal Backup (2012)'.replace(' ', '\ ').replace('(', '\(').replace(')', '\)')
def getDate(file):
for line in open(directory + '/' + file):
@philipbl
philipbl / import.py
Created August 15, 2012 22:57
Imports Evernote HTML into DayOne
from optparse import OptionParser
from HTMLParser import HTMLParser
import os
import glob
import sys
import re
class Entry():
def __init__(self):
self.tags = []