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 / sample.py
Last active August 25, 2016 15:24 — forked from afroisalreadyinu/sample.py
import operator
def build_book_inventory(book_ids, shops):
shop_labels = map(operator.itemgetter('label'), shops)
books = Persistency.books_table.read(shops=shop_labels, books=book_ids)
inventory = {}
for book in books:
shop_inventory = inventory.setdefault(book['shop_label'])
book_inventory = shop_inventory.setdefault(book['cell_label'], {})
Pod::Spec.new do |s|
s.name = "zxing"
s.version = "2.3.0"
s.summary = "Multi-format 1D/2D barcode image processing library."
s.homepage = "http://code.google.com/p/zxing/"
s.author = "ZXing team (http://code.google.com/p/zxing/people/list)"
s.source = { :git => "https://github.com/zxing/zxing.git", :revision => "00f634024ceeee591f54e6984ea7dd666fab22ae" }
s.requires_arc = false
# workaround for a missing import in objc/src/ZXing/ZXImage.mm
@dlo
dlo / README.md
Last active February 2, 2024 02:18
Xcode script that automatically uploads builds to iTunes Connect after archive

Summary

This script will automatically upload your app to iTunes Connect after a successful Xcode archive action.

After doing this about a million times by hand (i.e., opening the Organizer, clicking on "Upload to App Store", waiting for teams to load, etc.), I decided I'd had enough. Now, I just go to "Product" > "Archive", sip my margherita, and kick up my feet while the world marvels at my genius, while my app gets distributed to my testers without lifting but a finger. Or...I just take a bathroom break. Either way, it's pretty awesome.

Yes, yes, I know you can do this completely via fastlane, but I'm somewhat sadistic and prefer to do my archiving completely within Xcode.

Instructions

KEYWORDS="TODO|FIXME|\?\?\?:|\!\!\!:"
cd "${SRCROOT}"
find . ! \( -path ./Pods -prune \) -type f -name "*.swift" -print0 \
| xargs -0 egrep --with-filename --line-number --only-matching "($KEYWORDS).*\$" \
| perl -p -e "s/($KEYWORDS)/ warning: \$1/"
@dlo
dlo / REFUND.md
Last active May 22, 2017 03:39
Instant App Store refunds

Hi,

You can get a refund by following this process:

  1. Visit https://reportaproblem.apple.com logged in with the Apple ID you purchased the app with.
  2. Find the app in the list or search.
  3. Click "Report a Problem".
  4. In the dropdown, choose "Item opens but doesn't function as expected".
  5. Click "Submit".
func selectionSort(_ array: [Int]) -> [Int] {
guard let minValue = array.min(), let index = array.index(of: minValue) else {
return []
}
let ranges = [0..<index, index.advanced(by: 1)..<array.endIndex]
return [minValue] + selectionSort(ranges.lazy.flatMap { array[$0] })
}
@dlo
dlo / dispatch_once.swift
Created June 20, 2016 01:43 — forked from kristopherjohnson/dispatch_once.swift
Example of using dispatch_once() in Swift
import Foundation
var token: dispatch_once_t = 0
func test() {
dispatch_once(&token) {
println("This is printed only on the first call to test()")
}
println("This is printed for each call to test()")
}
@dlo
dlo / README.md
Last active June 19, 2016 16:26
Swift protocol for displaying popovers in UITableViewCells.
@dlo
dlo / no-magic.md
Last active February 19, 2016 16:43

All Lionheart Swift and Objective-C libraries are built with a "no magic" philosophy. This means absolutely no usage of:

  • Method swizzling.
  • Custom operators.
  • Associated Objects (objc_setAssociatedObject / objc_getAssociatedObject).
  • respondsToSelector(_:)

Our Swift libraries are all protocol-oriented. For more information on what this means, watch WWDC 2015, Session 408. Additionally, our Swift libraries:

  • Always unwrap optionals safely, and never define implicitly unwrapped optionals.
@dlo
dlo / Script.applescript
Last active March 15, 2017 04:06
Applescript / Keyboard Maestro Macro to switch to last tab in Safari.
tell application "Safari"
set tabCount to number of tabs in front window
end tell
tell front window of application "Safari"
set current tab to tab tabCount
end tell