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 / 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 / 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 / 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 / allpinboard.py
Last active September 5, 2019 15:26 — forked from ttscoff/allpinboard.rb
Python version of https://gist.github.com/3773519 that pulls all bookmarks on the first sync, and does incremental updates afterwards. Also uses the Mac OS X keychain to retrieve your password so it doesn't need to live in a file on your computer in plain text.
#!/usr/bin/env python
"""
This script is designed to generate a simple html file with _all_ of your
Pinboard.in bookmarks The HTML file can be added to Launchbar's index as a
custom bookmark file and you can search your entire Pinboard.in collection
instantly from Launchbar (by title only). It includes any applied tags as part
of the title to aid in searching.
You should edit the `username`, `bookmark_filename`, and `local_timezone`
@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]> {