vankuik.nl

Latest weblog entries

2015-07-09 Short list of VPS providers

Here's my 2015 short list of VPS providers:

  • TransIP Reasonable price, good CPU performance, but I've had storage reliability problems in 2013 (for which they compensated me)
  • DigitalOcean Good price, don't like their CPU performance -- starting a Grails instance took 90 seconds, as opposed to 60 seconds on a TransIP node in the AMS2 data center
  • Linode No experience with them, but good reviews from people I trust
  • Scaleway No experience with them; ARM cores
  • Vultr No experience with them; not a lot of disk space for my price range

2015-07-05 withUnsafeBufferPointer

I couldn't find a nice example for Array<T>.withUnsafeBufferPointer, so here's one which you can paste right into a Playground:

	//: Playground - noun: a place where people can play
	import UIKit
	var buf = [UInt8](count: 10, repeatedValue: 0)
	// Fill buffer with A to J
	for (var i = 0; i < buf.count; i++) {
		buf[i] = 65 + UInt8(i) // 65 = A
	}
	// Calculate pointer to print contents
	buf.withUnsafeBufferPointer { (pbuf: UnsafeBufferPointer<UInt8>) -> UnsafePointer<UInt8> in
		for (var j = 0; j < pbuf.count; j++) {
			let p = pbuf.baseAddress
			print(Character(UnicodeScalar((p+j).memory)))
			println(String(format:" = 0x%X", (p+j).memory))
		}
		return nil
	}

Output:

	A = 0x41
	B = 0x42
	C = 0x43
	D = 0x44
	E = 0x45
	F = 0x46
	G = 0x47
	H = 0x48
	I = 0x49
	J = 0x4A

2015-06-21 Swift 2.0 error handling

Here is a nice article by Erica Sadun on the error handling in Swift 2.0.

I really like how a try statement can be forced, i.e. try! will tell the compiler you ignore the error and this will cause a crash when the exception trips during runtime. From my Java experience, I remember that there were plenty of exceptions that basically couldn't be recovered from; you'd log them and then exit. I'm glad Apple recognized this.

The keyword defer is also interesting, delaying execution until the end of the scope. Notably, multiple statements after each other have a sequence, and these statements are executed in reverse order. On the Debug podcast, Don Melton (former Safari product manager) commented that he thought it was taken from the D programming langauge. A buddy of mine had been developing in D in the past, so I asked him what he thought about it. He remarked that he hadn't actually ever used that particular keyword in D... I wonder if I'll find much use of it.

2015-06-19 QuickLook for mobileprovision files

Craig Hockenberry wrote a Quick Look plug-in for .mobileprovision files (i.e. Provisioning Profiles). Hugely useful, because you can just select a provisioning profile and press space in Finder to see which UDIDs (devices) are included.

To debug provisioning profiles, don't let Xcode manage them. Instead when you need to run your app on a new device, take the following steps:

  • In the Member Center, go to Certificates, Identifiers & Profiles
  • Add the device for this particular App ID
  • Generate either a development or a distribution profile and download it manually
  • Use the above Quick Look plugin to verify that the downloaded profile does indeed contain the UDID of the new device
  • Double-click the new .mobileprovisioning file
  • Check with the terminal that it is now located in ~/Library/MobileDevice/Provisioning Profiles

Now go to Xcode. Since version 6, you can view provisioning profiles by going to menu Xcode -> Preferences. In the Accounts tab, select your Apple ID on the left, select your team on the right and click View Details. The new profile should be there, or else you can click the refresh button. The expiration column should show the date as exactly one year later.

If you want the .ipa file, check out this answer on StackOverflow.

2015-06-16 AutoLayout in WWDC 2015

Be sure to check out these videos on AutoLayout:

There's some stuff in there that you may already know, but they also explain new stuff. My highlights:

  • First use stackviews, then for the rest, use constraints
  • Don't add and remove constraints, activate and deactivate them
  • For text, you might want to use firstBaseline and lastBaseline
  • Use "alignment rects" if you need to ignore extra stuff in your views (like shadows)

And in part 2:

  • Use the .identifier property on views when debugging, it's a string that'll show up in the log
  • Use method in the debugger called constraintsForAxis or something
  • There's a trace method in the debugger: po [self.view _autolayoutTrace] (can show ambiguous layouts); then on the LLDB prompt: po [object exerciseAmbiguityLayout]
  • While your app is running, check the menu Debug, option View Debugging

More...

Weblog Archive

Weblog entries 2015

Weblog entries 2014

Weblog entries 2013

Weblog entries 2012

Weblog entries 2011

Weblog entries 2010

Weblog entries 2009

Weblog entries 2008

Weblog entries 2007

Weblog entries 2006

Weblog entries 2005

Weblog entries 2004

All weblog entries

Articles

Articles, chronologically (latest first). This is pretty old stuff.

Scribblings

Not yet finished. Maybe will never be finished. Maybe they'll get deleted. Who knows?

Programming:

System administration:

Others:

Files: