Skip to content

Instantly share code, notes, and snippets.

View irace's full-sized avatar

Bryan Irace irace

View GitHub Profile
@irace
irace / gist:69aba0dd94e6c87ba71d
Created July 18, 2015 17:32
Producitivity.app feedback
  • In the “Times of day” settings, the start time for morning tasks (which ends up also serving as the end time for evening tasks) should be configurable. Currently it always starts at midnight which doesn’t work great for those of us who often stay up past midnight.

  • Would be cool if there was a “snooze” option. Say I have my evening configured to start at 7PM because that's when I normally get home from work. If I work late one night, I would want to “snooze” the tasks until say, 9PM, such that my icon is not badged with the remaining task number until I actually get home. Alternatively, this could use geolocation to determine when I’m home and not start my evening until then.

4:48 PM] heathborders: You can do this in swift
[4:50 PM] heathborders: You need to make a Request protocol:
```protocol RequestProtocol {
typealias ResourceType
var resource: ResourceType { get }
}
```
(edited)
@irace
irace / wwdc.swift
Created April 21, 2015 17:55
Randomly pick a deserving team member to give your WWDC ticket too. Allows for weighting in case you like some more than others.
#!/usr/bin/env xcrun swift
import Foundation
struct Teammate {
let name: String
let weighting: Int
}
let teammates = [
@irace
irace / gist:902cb9a66f65d4373f68
Last active August 29, 2015 14:19
Questions about Russ Bishop’s “Swift: Associated Type” article

Swift associated types are a bit confusing, and Russ Bishop’s article on the subject is top notch, the best I’ve seen. I do have a couple of questions after reading it, though:

Why exactly would parameterized types need to be excessively repeated?

Type parameters force everyone to know the types involved and specify them repeatedly (when you compose with them it can also lead to an explosion in the number of type parameters).

Why would this need to be the case, necessarily? In Java, a language that does allow for parameterized protocols (Java calls them “interfaces”) you can create concrete classes that conform to generic interfaces without specifying the parameterized type each time the concrete class name is referred to.

interface Food {
@irace
irace / gist:54d25f854a5a883bbc0e
Created April 8, 2015 20:09
Really wish protocols could be generic, but this seems to work?
protocol Options {
}
class ConcreteOptions: Options {
func hi() -> String {
return "Hi"
}
}
protocol ResponseParser {
@irace
irace / BiMultiDictionary.swift
Last active August 29, 2015 14:16
Multi-dictionaries in Swift
struct BiMultiDictionary<A: Hashable, B: Hashable> {
private var keysToValues = MultiDictionary<A, B>()
private var valuesToKeys = MultiDictionary<B, A>()
func allValues() -> [B] {
return keysToValues.allValues()
}
func valuesForKey(key: A) -> [B]? {
return keysToValues.valueForKey(key)
@irace
irace / gist:9f3fe5ab1d6fa6630552
Created February 24, 2015 18:32
Highlight GitHub pull requests with merge conflicts
$('li.list-group-item').each(function() {
var $pr = $(this);
$.get(window.location.origin + $pr.find('.list-group-item-name a').first().attr('href'), function (html) {
var message = $(html).find('.merge-branch-heading').text()
, mergeable = message.indexOf("can be") > -1;
if (!mergeable) {
$pr.css('backgroundColor', '#fbc0c0');
}
@irace
irace / gist:c20a8ae52c3bdb99692c
Last active August 29, 2015 14:13
Custom git commands that allow you to easily stash your work and switch branches, and then switch back and apply your stash: `pushb` and `popb`

Say you’re in the middle of working on something and need to switch branches in order to look at something else, but then want to go right back to what you were working on. This kind of flow reminds me of using pushd and popd so I made some very simple custom git commands to do this.

Usage

First, add the following files to your PATH (on OS X, just create them under /usr/local/bin and make them executable). Then use the commands like this:

bryan-MacBookPro-2a5158:project bryan$ git status
On branch some-new-feature
Changes to be committed:
12:54 You have joined the channel
12:54 irace has joined (~irace@66.6.34.254)
12:54 Topic: TileMill and the Mapbox family -- https://www.mapbox.com/ and https://www.mapbox.com/help/ -- Logs: https://botbot.me/freenode/mapbox/
12:54 kkaefer set the topic at: Dec 2, 2014, 10:47 AM
12:54 Mode: +cnt
12:54 Created at: Apr 6, 2010, 5:15 PM
12:54 [irace] hey incanus77
13:01 [incanus77] hey irace
13:01 [irace] thanks for offering to help out
13:02 [irace] so how exactly do SHP and geoJSON differ?