Skip to content

Instantly share code, notes, and snippets.

Avatar
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
dlo / README.md
Last active Nov 7, 2017
Health Data Importer XML Splitter
View README.md

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 Nov 1, 2017
Automatically generate a Content.json file for an iOS icon set from a list of iOS icons in a folder.
View generate_iconset_contents.py
#!/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 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
dlo / MOVED.md
Last active Sep 26, 2017
A fastlane action that submits a processed iTunes Connect build to Beta App Review.
View generate_health_xml.py
#!/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
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
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 lhs.compare(rhs) == .orderedSame
}
public func <(lhs: NSDecimalNumber, rhs: NSDecimalNumber) -> Bool {
return lhs.compare(rhs) == .orderedAscending
}
@dlo
dlo / force_migration.sh
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.
View force_migration.sh
#!/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)
You can’t perform that action at this time.