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 / handle.ts
Created December 18, 2020 23:57 — forked from destroytoday/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]> {
@dlo
dlo / mixpanel-delete-people.py
Created April 12, 2018 00:38 — forked from JorgenHookham/mixpanel-delete-people.py
Mixpanel Delete People
"""
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
@dlo
dlo / better-ssh-authorized-keys-management.md
Created February 5, 2018 01:04 — forked from sivel/better-ssh-authorized-keys-management.md
Better SSH Authorized Keys Management

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
dlo / NSDecimalNumber.swift
Last active November 13, 2017 10:23 — forked from mattt/NSDecimalNumber.swift
NSDecimalNumber Additions for Swift 3 - Updated
import Foundation
public func ==(lhs: NSDecimalNumber, rhs: NSDecimalNumber) -> Bool {
return lhs.compare(rhs) == .orderedSame
}
public func <(lhs: NSDecimalNumber, rhs: NSDecimalNumber) -> Bool {
return lhs.compare(rhs) == .orderedAscending
}
@dlo
dlo / sample.py
Last active August 25, 2016 15:24 — forked from afroisalreadyinu/sample.py
import operator
def build_book_inventory(book_ids, shops):
shop_labels = map(operator.itemgetter('label'), shops)
books = Persistency.books_table.read(shops=shop_labels, books=book_ids)
inventory = {}
for book in books:
shop_inventory = inventory.setdefault(book['shop_label'])
book_inventory = shop_inventory.setdefault(book['cell_label'], {})
@dlo
dlo / dispatch_once.swift
Created June 20, 2016 01:43 — forked from kristopherjohnson/dispatch_once.swift
Example of using dispatch_once() in 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()")
}
//: 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/
#coding: utf-8
import console
import keychain
import pickle
import requests
import json
from urllib import quote
import webbrowser
@dlo
dlo / gist:8042879
Last active December 31, 2015 20:49
//
// 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.