Skip to content

Instantly share code, notes, and snippets.

View dlo's full-sized avatar
Always shipping.

Dan Loewenherz dlo

Always shipping.
View GitHub Profile
#coding: utf-8
import console
import keychain
import pickle
import requests
import json
from urllib import quote
import webbrowser
# vim: set ft=python :
from __future__ import print_function
import json
import sys
import datetime
from redis import StrictRedis as Redis
import datetime
class FakeDateTime(datetime.datetime):
def __eq__(self, instance):
try:
return (self.year, self.month, self.day, self.hour, self.minute, self.second) == (instance.year, instance.month, instance.day, instance.hour, instance.minute, instance.second)
except:
return False
@classmethod
- (void)cancelLongRunningTasks:(id)sender {
NSDate *date = [NSDate date];
void (^CompletionHandler)(NSArray *dataTasks, NSArray *uploadTasks, NSArray *downloadTasks) = ^(NSArray *dataTasks, NSArray *uploadTasks, NSArray *downloadTasks) {
for (NSURLSessionDownloadTask *task in downloadTasks) {
if (task.state == NSURLSessionTaskStateRunning) {
NSDate *startDate = self.sessionDownloadTaskStartDates[@(task.taskIdentifier)];
if (startDate) {
NSTimeInterval interval = [date timeIntervalSinceDate:startDate];
if (interval > 30) {
@dlo
dlo / patch.sh
Created January 27, 2015 20:45 — forked from lambdalisue/patch.sh
#!/bin/sh
# Ref: http://ubuntuforums.org/showthread.php?t=1751455
# Install required libs
apt-get -y install build-essential python-dev libjpeg62-dev zlib1g-dev libfreetype6-dev liblcms1-dev
# Link to correct location
if [ -d /usr/lib/x86_64-linux-gnu ]; then
# Ubuntu 11.04 64bit
ln -sf /usr/lib/x86_64-linux-gnu/libfreetype.so /usr/lib/
ln -sf /usr/lib/x86_64-linux-gnu/libz.so /usr/lib/
ln -sf /usr/lib/x86_64-linux-gnu/libjpeg.so /usr/lib/
//: Playground - noun: a place where people can play
import UIKit
protocol AccountLike: Equatable {
var accountID: String {get}
}
class Account : AccountLike {
let accountID = nil
@dlo
dlo / wsp.py
Created November 11, 2009 06:51
Shorthand for Go compilation.
#!/usr/bin/env python
import sys
from os import system
prog = sys.argv[1]
pos = prog.find(".")
name = prog[:pos]
system("8g " + prog)
system("8l -o %s.out %s.8" % (name, name))
@dlo
dlo / README.md
Created November 18, 2009 17:30
A bare-bones tweet notifier for OS X.

Growl Tweet Notifier

This gist has graduated into a real repository! Check it out at dlo/growltweet.

@dlo
dlo / textile.py
Created November 21, 2009 03:31
Textile 2.1.3
#!/usr/bin/env python
"""
PyTextile
A Humane Web Text Generator
"""
__version__ = '2.1.3'
__date__ = '2009/02/07'
@dlo
dlo / issue.py
Created November 24, 2009 06:44
git hook to push issues to github
#!/usr/bin/env python
"""
LICENSE
=======
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2004 Sam Hocevar