Skip to content

Instantly share code, notes, and snippets.

Always shipping.

Dan Loewenherz dlo

Always shipping.
View GitHub Profile
View handle.ts
Typescript erroring:
Type 'Promise<(T | undefined)[] | [any, undefined]>' is not assignable to type 'Promise<[void | Error, void | T]>'.
Type '(T | undefined)[] | [any, undefined]' is not assignable to type '[void | Error, void | T]'.
Type '(T | undefined)[]' is not assignable to type '[void | Error, void | T]'.
Target requires 2 element(s) but source may have fewer.ts(2322)
export default function <T> (promise: Promise<T>): Promise<[Error | void, T | void]> {
This is from mixpanel customer service, I just PEP8ified it. Update api key, secret and token.
You can define which users you want to delete on line 125. Right now it will delete users who haven't
been seen in over 7 weeks. You will recieve a confirmation prompt before the people are deleted.
import hashlib
import time
import urllib
import base64

Better SSH Authorized Keys Management

A seemingly common problem that people encounter is how to handle all of your users authorized_keys file.

People struggle over management, ensuring that users only have specific keys in the authorized_keys file or even a method for expiring keys. A centralized key management system could help provide all of this functionality with a little scripting.

One piece of functionality overlooked in OpenSSH is the AuthorizedKeysCommand configuration keyword. This configuration allows you to specify a command that will run during login to retrieve a users public key file from a remote source and perform validation just as if the authorized_keys file was local.

Here is an example directory structure for a set of users with SSH public keys that can be shared out via a web server:

dlo / NSDecimalNumber.swift
Last active Nov 13, 2017 — forked from mattt/NSDecimalNumber.swift
NSDecimalNumber Additions for Swift 3 - Updated
View NSDecimalNumber.swift
import Foundation
public func ==(lhs: NSDecimalNumber, rhs: NSDecimalNumber) -> Bool {
return == .orderedSame
public func <(lhs: NSDecimalNumber, rhs: NSDecimalNumber) -> Bool {
return == .orderedAscending
import operator
def build_book_inventory(book_ids, shops):
shop_labels = map(operator.itemgetter('label'), shops)
books =, books=book_ids)
inventory = {}
for book in books:
shop_inventory = inventory.setdefault(book['shop_label'])
book_inventory = shop_inventory.setdefault(book['cell_label'], {})
dlo / dispatch_once.swift
Created Jun 20, 2016 — forked from kristopherjohnson/dispatch_once.swift
Example of using dispatch_once() in Swift
View dispatch_once.swift
import Foundation
var token: dispatch_once_t = 0
func test() {
dispatch_once(&token) {
println("This is printed only on the first call to test()")
println("This is printed for each call to test()")
View protocolequatable.swift
//: Playground - noun: a place where people can play
import UIKit
protocol AccountLike: Equatable {
var accountID: String {get}
class Account : AccountLike {
let accountID = nil
# Ref:
# 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/ /usr/lib/
ln -sf /usr/lib/x86_64-linux-gnu/ /usr/lib/
ln -sf /usr/lib/x86_64-linux-gnu/ /usr/lib/
#coding: utf-8
import console
import keychain
import pickle
import requests
import json
from urllib import quote
import webbrowser
View gist:8042879
// TMSerialAnimationQueue.h
// Orangina
// Created by Bryan Irace on 10/9/13.
// Copyright (c) 2013 Tumblr. All rights reserved.
Contains boilerplate for performing animations serially, without blocking the main thread.