Skip to content

Instantly share code, notes, and snippets.

Always shipping.

Dan Loewenherz dlo

Always shipping.
View GitHub Profile
View upvote_comments_with_salaries.js
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 /
Last active Nov 7, 2017
Health Data Importer XML Splitter

Health Data Importer XML Splitter


chmod +x splitter


./splitter FILENAME
dlo /
Created Nov 1, 2017
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 | ./
import sys
import re
import json
r = re.compile(".*(AppStore|iPhone|iPad).*-([\d\.]+)(@\dx)?\.png")
dlo / StoreReviewPointsManager.swift
Last active Mar 9, 2018
Simple review prompt point system for iOS apps, with points and half-lives assigned to in-app actions
View StoreReviewPointsManager.swift
import UIKit
import StoreKit
enum StoreReviewValue: Int, Codable {
case high
case medium
case low
var value: NSDecimalNumber {
switch self {
dlo /
Last active Sep 26, 2017
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']
View leak.swift
let r = try! NSRegularExpression(pattern: ".", options: [])
while true {
r.stringByReplacingMatches(in: "", options: [], range: NSRange(), withTemplate: "")
dlo / JSONSerialization.swift
Last active Sep 19, 2016
JSONSerialization extension to hone in on which values are invalid in complex Swift arrays or dictionaries.
View JSONSerialization.swift
extension JSONSerialization {
static func invalidJSONValue(data: Any) -> AnyObject? {
if let elements = data as? [Any] {
if !isValidJSONObject(data) {
for element in elements {
if let value = invalidJSONValue(data: element) {
return value
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
dlo /
Last active Nov 6, 2016
For those of you who’ve run into the Xcode 8 / Swift migrator hanging issue, this script fixes it. It marks all targets in the project as migrated. For any targets that haven’t actually been migrated to Swift 2.3/3, the script outputs a one-liner that you can cut-and-paste to undo individual targets.
if [[ -z "$PROJ" ]]; then
echo "Please provide a path to an Xcode project file."
exit 1
ROOT=$(/usr/libexec/PlistBuddy -c "Print rootObject" $PROJ)
You can’t perform that action at this time.