Skip to content

Instantly share code, notes, and snippets.

View radex's full-sized avatar
🚀
Full reusability

Radek Pietruszewski radex

🚀
Full reusability
View GitHub Profile
// Dumb (and really slow)
import Foundation
func combinations(height: Int, _ level: Int) -> Int {
if (level == 1) {
return height + 1
} else {
var sum = 0
for i in 0...height {
@radex
radex / hard-reproductions.md
Last active January 30, 2016 11:57
Trouble reproducing a bug? Run this checklist.

Trouble reproducing a bug? Run this checklist to make sure you're reproducing user's environment as closely as possible:

Device

  • iOS version?
  • iPad/iPhone?
  • CPU architecture?
  • Screen size? Orientation? Slide-over/Split View?

iOS settings

// Option 1: if..elseif + optional unwrapping conditions
private func handleNotificationAction(id: String?, userInfo: [NSObject: AnyObject], responseInfo: [NSObject: AnyObject]?, completion: () -> Void) {
let taskId = userInfo["extra"]?["task_hash"] as? String
let projectId = userInfo["extra"]?["project_hash"] as? String
let comment = responseInfo?["UIUserNotificationActionResponseTypedTextKey"] as? String
if id == "comment", let task = taskId, comment = comment where !comment.isEmpty {
} else if id == "invitation_accept", let project = projectId {
@radex
radex / crash2.swift
Last active August 29, 2015 14:25
Swift crash: double subscript declaration
class Foo {
subscript(key: String) -> String {
get { a }
set { b }
}
subscript(key: String) -> String {
get { a }
set { b }
}
@radex
radex / crash1.swift
Last active August 29, 2015 14:25
Swift crash: badly typed subscript
class A {
subscript(key: B) -> C {
get { d }
set { e }
}
}
@radex
radex / wwdc2015.md
Last active August 29, 2015 14:22
WWDC (iOS 9, OS X 10.11, Swift 2.0, Xcode 7) hopes&wishes

iOS 9:

  1. Stability, stability, stability. Things should just work. Especially networking/cloud related stuff: AirDrop, Handoff, syncing, etc…
  2. Notification center that's actually useful. Instead of grouping them by apps, and failing to intelligently show the notifications I'm interested in, show the chronological stream/feed of all notifications. Don't remove anything from that feed, only gray out notifications you've tapped on/seen. So, just like Facebook notifications. Much better model.
  3. Presence awareness for more intelligent notifications. Don't give me the cacophony of notifications of all 4 devices. Devices within each other's BTLE range should have awareness of each other and know that if I'm actively using my Mac, I want notifications to only show up there.
  4. Better app folders. The 3x3 grid is bullshit design, and even worse on the iPad. Make the folder zoom in and expand into a scrolling list of apps, not a paged interface. Kinda like on the Mac
  5. Allow people to choose default a
class C {
let alias: Foo -> Void = f // error: Foo not a subtype of C
let alias2 = f // : C -> Foo -> Void
func f(arg: Foo) {
// ...
}
}
# this doesn't do what you think it does
if f = foo && b = bar; end
# this works:
if (f = foo) && (b = bar); end
# and this works:
if f = foo and b = bar; end
let data = error.userInfo![AFNetworkingOperationFailingURLResponseDataErrorKey] as NSData
consoleLog(NSString(data: data, encoding: NSUTF8StringEncoding))
@radex
radex / store-categories.txt
Created February 10, 2015 10:14
App Store and Play Store categories
Play Store
Books & Reference
Business
Comics
Communication
Education
Entertainment
Finance
Health & Fitness