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 / userscript.js
Created February 19, 2018 19:59
Fluid.app GitHub badge icon with # of open issues
const $$ = (selector) => document.querySelectorAll(selector)
let items = $$("nav.reponav span.Counter");
if (items.length > 0) {
window.fluid.dockBadge = items[0].innerText;
} else {
window.fluid.dockBadge = "";
}
@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 / youtube_xml_to_srt.py
Last active January 25, 2018 17:37
YouTube XML Caption Format to SRT
#!/usr/bin/env python3
# -*- encoding:utf-8 -*-
# Install: pip install lxml
# Usage: python youtube_xml_to_srt.py INPUT_FILE.xml > OUTPUT_FILE.srt
import re
import sys
from decimal import Decimal
import html
var r1 = /(\$|£|€)\d+(k|K)/m
var r2 = /\d+-\d+(k|K)/m
var r3 = /\d+(k|K)\s?(€|EUR)/m
var candidates = [r1, r2, r3];
var linkQueue = []
var comments = document.getElementsByTagName("tr")
for (var i in comments) {
var comment = comments[i];
if (comment.className && comment.className.indexOf("athing comtr") != -1) {
@dlo
dlo / README.md
Last active November 7, 2017 14:35
Health Data Importer XML Splitter

Health Data Importer XML Splitter

Installation:

wget https://gist.github.com/dlo/64f7f2935a4e5c1c21e1e3f4bffed28c/raw/d19ad35d478bdc15396ec4b0c39826c52499224a/splitter
chmod +x splitter

Usage:

./splitter FILENAME

@dlo
dlo / generate_iconset_contents.py
Created November 1, 2017 01:01
Automatically generate a Content.json file for an iOS icon set from a list of iOS icons in a folder.
#!/usr/bin/env python
# Usage: ls *.png | ./generate_iconset_contents.py
import sys
import re
import json
r = re.compile(".*(AppStore|iPhone|iPad).*-([\d\.]+)(@\dx)?\.png")
@dlo
dlo / StoreReviewPointsManager.swift
Last active March 9, 2018 22:00
Simple review prompt point system for iOS apps, with points and half-lives assigned to in-app actions
import UIKit
import StoreKit
enum StoreReviewValue: Int, Codable {
case high
case medium
case low
var value: NSDecimalNumber {
switch self {
@dlo
dlo / MOVED.md
Last active September 26, 2017 20:15
A fastlane action that submits a processed iTunes Connect build to Beta App Review.
#!/usr/bin/env python
import json
import datetime
def date_from_row(row):
year = row['year']
month = row['month']
day = row['day']
hour = row['hour']
let r = try! NSRegularExpression(pattern: ".", options: [])
while true {
r.stringByReplacingMatches(in: "", options: [], range: NSRange(), withTemplate: "")
}