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 June 19, 2016 16:26
Swift protocol for displaying popovers in UITableViewCells.
@dlo
dlo / no-magic.md
Last active February 19, 2016 16:43

All Lionheart Swift and Objective-C libraries are built with a "no magic" philosophy. This means absolutely no usage of:

  • Method swizzling.
  • Custom operators.
  • Associated Objects (objc_setAssociatedObject / objc_getAssociatedObject).
  • respondsToSelector(_:)

Our Swift libraries are all protocol-oriented. For more information on what this means, watch WWDC 2015, Session 408. Additionally, our Swift libraries:

  • Always unwrap optionals safely, and never define implicitly unwrapped optionals.
@dlo
dlo / Script.applescript
Last active March 15, 2017 04:06
Applescript / Keyboard Maestro Macro to switch to last tab in Safari.
tell application "Safari"
set tabCount to number of tabs in front window
end tell
tell front window of application "Safari"
set current tab to tab tabCount
end tell
@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 [email protected]

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