Skip to content

Instantly share code, notes, and snippets.

🏠
Working from home

Klaas Pieter Annema klaaspieter

🏠
Working from home
Block or report user

Report or block klaaspieter

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View Set.playground
precedencegroup ForwardApplication {
associativity: left
}
infix operator |>: ForwardApplication
public func |> <A, B>(x: A, f: (A) -> B) -> B {
return f(x)
}
precedencegroup SingleTypeComposition {
associativity: right
@klaaspieter
klaaspieter / UILayoutPriority.swift
Created Mar 7, 2018
Convenience UILayoutPriority extension for more declarative content hugging (and compression resistance) definition
View UILayoutPriority.swift
import UIKit
import PlaygroundSupport
let view = UIView(frame: CGRect(x: 0, y: 0, width: 414, height: 100))
view.backgroundColor = .white
let titleLabel = UILabel()
titleLabel.text = "Hello"
titleLabel.backgroundColor = .purple
view.addSubview(titleLabel)
View keybase.md

Keybase proof

I hereby claim:

  • I am klaaspieter on github.
  • I am klaaspieter (https://keybase.io/klaaspieter) on keybase.
  • I have a public key ASCTKhdPDvJLhI4JoXgJEUEgM6PhrUepfEt-bWxhEBEvzgo

To claim this, I am signing this object:

@klaaspieter
klaaspieter / Calendar.swift
Last active Jul 10, 2017
Calendar extension to determine wether a date is after today
View Calendar.swift
import Foundation
extension Calendar {
/// Returns `true` if the given date is after today, as defined by the calendar and calendar's locale.
///
/// Because it's impossible to define the end of a day (there are an infinite number of
/// milliseconds between 23:59:59 and 00:00:00), this method instead ensures that
/// `date` >= `startOfTomorrow`.
///
/// - parameter date: The specified date.
@klaaspieter
klaaspieter / ASS.md
Created Jun 22, 2017 — forked from anonymous/ASS.md
Acronyms Seriously Suck - Elon Musk
View ASS.md

From time to time, Musk will send out an e-mail to the entire company to enforce a new policy or let them know about something that's bothering him. One of the more famous e-mails arrived in May 2010 with the subject line: Acronyms Seriously Suck:

There is a creeping tendency to use made up acronyms at SpaceX. Excessive use of made up acronyms is a significant impediment to communication and keeping communication good as we grow is incredibly important. Individually, a few acronyms here and there may not seem so bad, but if a thousand people are making these up, over time the result will be a huge glossary that we have to issue to new employees. No one can actually remember all these acronyms and people don't want to seem dumb in a meeting, so they just sit there in ignorance. This is particularly tough on new employees.

That needs to stop immediately or I will take drastic action - I have given enough warning over the years. Unless an acronym is approved by me, it should not enter the SpaceX glossary.

@klaaspieter
klaaspieter / Instabug.json
Created Mar 17, 2017
Instabug Carthage Binary Project Specification
View Instabug.json
{
"7.1": "https://github.com/Instabug/Instabug-iOS/releases/download/7.1/Instabug.zip"
}
@klaaspieter
klaaspieter / xcrecord
Last active Dec 13, 2016
Record video from the running (> Xcode 8.2) simulator and convert it to gif
View xcrecord
#!/bin/sh
output=$1
tmp_file=$(mktemp)
xcrun simctl io booted recordVideo "$tmp_file"
ffmpeg -i "$tmp_file" -pix_fmt rgb24 -r 10 -f gif - \
| gifsicle --optimize=3 > "$output"
rm -r "$tmp_file"
@klaaspieter
klaaspieter / p12 -> pem
Last active May 20, 2016
Convert from p12 to pem and copy contents
View p12 -> pem
openssl pkcs12 -in Certificates.p12 -nodes -clcerts | pbcopy
@klaaspieter
klaaspieter / tap.playground
Last active Mar 28, 2017
Ruby's tap method in a Swift playground (original blog post: http://www.annema.me/blog/post/edit/rubys-tap-method-in-swift)
View tap.playground
import Foundation
/*:
Ruby has a nice method called `tap`, which I wanted to try and port to Swift. To learn what it does, let’s take a look at [Ruby’s documentation](http://ruby-doc.org/core-2.2.0/Object.html#method-i-tap):
> Yields self to the block, and then returns self. The primary purpose of this method is to “tap into” a method chain, in order to perform operations on intermediate results within the chain.
Yeah, right. I don’t really know what that means. Googling yields (no pun intended) many contrived examples like these:
[1, 2, 3, 4].tap &:reverse! # [4, 3, 2, 1]
@klaaspieter
klaaspieter / Pizza.swift
Created Feb 2, 2015
An implementation of the Builder pattern in Swift
View Pizza.swift
import Foundation
enum Cheese : String {
case Mozzarella = "Mozzarella"
case Provolone = "Provolone"
case Pecorino = "Pecorino"
}
class PizzaBuilder {
var size: Int = 0
You can’t perform that action at this time.