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
# Recursively find EPS files and convert them to PDF | |
find . -type f -name '*.eps' -print0 | while IFS= read -r -d '' file; do | |
pstopdf "$file" | |
done | |
# Recursively find PDF files and convert them to EPS | |
find . -type f -name '*.pdf' -print0 | while IFS= read -r -d '' file; do | |
sips -s format png --deleteColorManagementProperties --out "${file}.png" "$file" | |
done |
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
/* | |
Based on https://developers.google.com/speed/docs/insights/OptimizeCSSDelivery | |
Further reading: | |
Preventing a Flash of Invisible Text | |
https://www.filamentgroup.com/lab/font-events.html | |
Detecting a stylesheet has loaded | |
https://viget.com/inspire/js-201-run-a-function-when-a-stylesheet-finishes-loading |
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
def get_spreadsheet_id(user_input): | |
"""Accepts any form of Google Sheet URL or just the raw ID""" | |
if user_input.__contains__("spreadsheets/d"): | |
parts = user_input.split("/", 7) | |
if parts[4] == 'd': | |
return parts[5] | |
raise Exception("Couldn't get spreadsheet ID") | |
return user_input | |
if __name__ == "__main__": |
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
function date_str_from_unix(unix_timestamp) { | |
// var my_date_str = date_str_from_unix(1370383708); | |
// my_date_str returns "2013-06-04 17:08" | |
var leading_zero = function(i) { | |
return i.toString().length < 2 ? "0" + i : i | |
} | |
var date = new Date(unix_timestamp * 1000); | |
var date_str = date.getFullYear() + "-" + leading_zero(date.getMonth() + 1) | |
+ "-" + leading_zero(date.getDate()) + " " | |
+ leading_zero(date.getHours()) + ":" |
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
from django.test.simple import DjangoTestSuiteRunner | |
class NoDbDjangoTestSuiteRunner(DjangoTestSuiteRunner): | |
def setup_databases(self, **kwargs): | |
return [], [] | |
def teardown_databases(self, old_config, **kwargs): | |
pass |
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
1998: 471 | |
1999: 472 | |
2000: 461 | |
2001: 453 | |
2002: 489 | |
2003: 480 | |
2004: 549 | |
2005: 592 | |
2006: 643 | |
2007: 647 |
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
""" | |
Script to grab lyrics from the song generator at phantomlyrics.org, | |
take 5 random verses from which you can choose, and make them ready | |
for Twitter. | |
""" | |
from httplib import HTTPConnection | |
from random import choice as random_choice | |
from sys import exit | |
from urllib import urlencode |
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
from django.db.models.query import EmptyQuerySet | |
class FakeQuerySet(EmptyQuerySet): | |
"""Turn a list into a Django QuerySet... kind of.""" | |
def __init__(self, model=None, query=None, using=None, items=[]): | |
super(FakeQuerySet, self).__init__(model, query, using) | |
self._result_cache = items | |
def count(self): | |
return len(self) |