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
@dlo
dlo / README.md
Last active November 9, 2015 22:11
Turn @2x images into @1x on the command line.

This is a simple Bash function that will (should?) turn any @2x image into a non-retina version.

Usage

Place the contents of deretinize.sh in your .bashrc, .bash_profile, or any other file that will get executed when you load your shell. Then,

$ deretinize xyz@2x.png

This will output a file named xyz.png in the same directory. If the original image has odd dimensions, the script will resize it appropriately.

@dlo
dlo / pam-u2f.rb
Last active September 7, 2015 16:50
Homebrew formula for https://github.com/Yubico/pam-u2f/ (not fully-working)
class PamU2f < Formula
desc "The PAM U2F module provides an easy way to integrate the Yubikey (or other U2F-compliant authenticators) into your existing > user authentication infrastructure."
homepage "https://developers.yubico.com/pam-u2f/"
head "https://github.com/Yubico/pam-u2f.git"
depends_on 'libu2f-host' => :build
depends_on 'libu2f-server' => :build
# Required for `autoreconf --install`
depends_on 'pkg-config' => :build
class Libu2fHost < Formula
desc "Libu2f-host provide a C library and command-line tool that implements the host-side of the U2F protocol. "
homepage "https://developers.yubico.com/libu2f-host/"
url "https://developers.yubico.com/libu2f-host/Releases/libu2f-host-1.0.0.tar.xz"
version "1.0.0"
sha256 "18c56b9b5cfea2566925bba45b25a4e20b3ef8696905d8f2a06116316e164374"
depends_on "pkg-config" => :build
depends_on "hidapi" => :build
depends_on "json-c" => :build
class Libu2fServer < Formula
desc "Yubico Universal 2nd Factor (U2F) Server C Library"
homepage "https://developers.yubico.com/libu2f-server/"
url "https://developers.yubico.com/libu2f-server/Releases/libu2f-server-1.0.1.tar.xz"
version "1.0.1"
sha256 "a618f59051209d6d70c24cf42d64c9b67bd7dd5946b6dbd2c649181d7e8f1f6e"
depends_on "check" => :build
depends_on "json-c"
depends_on "openssl"
2015-09-03 20:47:18 -0500
autoreconf
-fvi
autoreconf: Entering directory `.'
autoreconf: configure.ac: not using Gettext
autoreconf: running: aclocal --force -I m4
autoreconf: configure.ac: tracing
autoreconf: running: glibtoolize --copy --force
@dlo
dlo / .tarsnaprc
Last active January 26, 2021 03:16
I guess this is a pretty good OS X tarsnap configuration.
### Recommended options
humanize-numbers
# Tarsnap cache directory
cachedir /usr/local/tarsnap-cache
# Tarsnap key file
keyfile ~/.tarsnap/tarsnap.key
# Don't archive files which have the nodump flag set
//: 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 / 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/
- (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) {
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