Skip to content

Instantly share code, notes, and snippets.

View klaaspieter's full-sized avatar
🏠
Working from home

Klaas Pieter Annema klaaspieter

🏠
Working from home
View GitHub Profile
@klaaspieter
klaaspieter / find-pr-reference.js
Created July 23, 2019 05:54
It makes me sad that this is the best way to find the associated pull request of a GitHub issue
document.querySelector("h3[id^='ref-pullrequest']").scrollIntoView()
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 March 7, 2018 09:06
Convenience UILayoutPriority extension for more declarative content hugging (and compression resistance) definition
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)

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 July 10, 2017 09:21
Calendar extension to determine wether a date is after today
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 June 22, 2017 07:59 — forked from anonymous/ASS.md
Acronyms Seriously Suck - Elon Musk

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 March 17, 2017 13:28
Instabug Carthage Binary Project Specification
{
"7.1": "https://github.com/Instabug/Instabug-iOS/releases/download/7.1/Instabug.zip"
}
@klaaspieter
klaaspieter / xcrecord
Last active December 13, 2016 15:26
Record video from the running (> Xcode 8.2) simulator and convert it to gif
#!/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 05:41
Convert from p12 to pem and copy contents
openssl pkcs12 -in Certificates.p12 -nodes -clcerts | pbcopy
@klaaspieter
klaaspieter / tap.playground
Last active March 28, 2017 02:59
Ruby's tap method in a Swift playground (original blog post: http://www.annema.me/blog/post/edit/rubys-tap-method-in-swift)
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]