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
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: "")
}
@dlo
dlo / JSONSerialization.swift
Last active September 19, 2016 18:21
JSONSerialization extension to hone in on which values are invalid in complex Swift arrays or dictionaries.
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
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 / force_migration.sh
Last active November 6, 2016 14:14
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.
#!/bin/bash
PROJ=$1
if [[ -z "$PROJ" ]]; then
echo "Please provide a path to an Xcode project file."
exit 1
fi
ROOT=$(/usr/libexec/PlistBuddy -c "Print rootObject" $PROJ)