Build a Manic Time alternative.
The application would be in two parts:
- a tracker agent that dumps data into some backend
- should be dumb and not do much processing of the data
- a reporting dashboard which will show various timelines, statistics etc.
| enum JSON: Decodable { | |
| case bool(Bool) | |
| case double(Double) | |
| case string(String) | |
| indirect case array([JSON]) | |
| indirect case dictionary([String: JSON]) | |
| init(from decoder: Decoder) throws { | |
| if let container = try? decoder.container(keyedBy: JSONCodingKeys.self) { | |
| self = JSON(from: container) |
| #!/usr/bin/env xcrun swift -O | |
| /* | |
| gen.swift is a direct port of cfdrake's helloevolve.py from Python 2.7 to Swift 3 | |
| -------------------- https://gist.github.com/cfdrake/973505 --------------------- | |
| gen.swift implements a genetic algorithm that starts with a base | |
| population of randomly generated strings, iterates over a certain number of | |
| generations while implementing 'natural selection', and prints out the most fit | |
| string. | |
| The parameters of the simulation can be changed by modifying one of the many |
Build a Manic Time alternative.
The application would be in two parts:
So... this is obviously totally, 100%, like for. real. not. supported. by. Apple. …yet?
But still... I thought it was pretty badass. And, seeing how there's already a Swift buildpack for Heroku you could move some slow code into Swift can call it as a library function. But, you know, not in production or anything. That would be silly, right?
Now, having said that, the actual Python/Swift interop may have bugs. I'll leave that as an exercise to the reader.
| extension String { | |
| func size(withAttributes attrs: [String:AnyObject], constrainedTo box: NSSize) -> NSRect { | |
| let storage = NSTextStorage(string: self) | |
| let container = NSTextContainer(containerSize: NSSize(width: box.width, height: box.height)) | |
| let layout = NSLayoutManager() | |
| layout.addTextContainer(container) | |
| storage.addLayoutManager(layout) | |
| storage.addAttributes(attrs, range: NSMakeRange(0, storage.length)) | |
| container.lineFragmentPadding = 0.0 | |
| let _ = layout.glyphRangeForTextContainer(container) |
#Every Single Option Under The Sun
| <?php | |
| // This is sample code to draw some of the charts I blogged about here: | |
| // https://medium.com/ios-os-x-development/keeping-your-wits-as-an-indie-app-developer-3b5b14428e1f | |
| // | |
| // A few disclaimers: | |
| // 1. This assumes you have at least 30 days of sales data in order to draw the Trailing 7 Days Chart | |
| // 2. This assumes you have over 52 consecutive weeks of data in order to draw the Trailing Year Chart | |
| // 3. I don't really know PHP. Everything this does, I had to look it up while writing it. If you actually know PHP, sorry. There are surely better ways. | |
| // | |
| // the results of this PHP script is intended to be drawn using the Flot library. |
If you've haven't seen it before, there is a cool accessibility feature in UITableView that allows the user to toggle between different actions. It's really very elegant and it's a powerful and convenient implementation for VoiceOver users on iOS. One could say that it's the VoiceOver version of the swipe-to-delete feature.
To try it out yourselves, open one of the built in apps like Mail or Notes and turn on VoiceOver. If you are afraid to accidentally delete some of your important notes or email, you can also create a new Master-Detail Application in Xcode and run it on your device. Navigate to one of the cells and use the "Rotor" (rotate with two fingers on the screen) to find the "Actions" item. Now you can swipe up and down do toggle between "Activate Item (default action)" and "Delete". If you now double tap, the cell gets deleted instead of selected.
This is the default behavior and you get this accessibility out of the box with UITableView.
| /** | |
| Provides the ability to verify key paths at compile time. | |
| If "keyPath" does not exist, a compile-time error will be generated. | |
| Example: | |
| // Verifies "isFinished" exists on "operation". | |
| NSString *key = SQKeyPath(operation, isFinished); | |
| // Verifies "isFinished" exists on self. |