Skip to content

Instantly share code, notes, and snippets.

View wilmarvh's full-sized avatar
💻

Wilmar van Heerden wilmarvh

💻
View GitHub Profile
#ifdef TESTING
/*
Disable deprecated-declarations warning.
See http://clang.llvm.org/docs/UsersManual.html#diagnostics_pragmas
Basic workflow:
1. push current warnings onto stack
2. ignore warning we know will get thrown
3. do dodgy thing that causes warning
#ifdef TESTING
/*
Disable deprecated-declarations warning.
See http://clang.llvm.org/docs/UsersManual.html#diagnostics_pragmas
Basic workflow:
1. push current warnings onto stack
2. ignore warning we know will get thrown
3. do dodgy thing that causes warning
@wilmarvh
wilmarvh / iterm2-solarized.md
Created April 6, 2016 13:00 — forked from kevin-smets/iterm2-solarized.md
iTerm2 + oh my zsh + solarized + Meslo powerline font (OSX)

Solarized

Ordinarily I would go into Keyboard Preferences, Modifier Keys; I would select the name of the external keyboard
and I would tell it to turn Command into Option, Option into Command, and Caps Lock into Control.
But the Varmilo VB87M Mechanical Bluetooth Tenkeyless doesn't show up as an external keyboard. Weird, right?
You can't just swap command and option globally or your local keyboard will be affected.
When I added it, I had to "add Bluetooth device" under Bluetooth preferences,
rather than "add Bluetooth keyboard" under Keyboard preferences.
(That was true, at least, as of 2016-08-24, on OS X El Capital 10.11.6.)
@wilmarvh
wilmarvh / TextSize.swift
Created April 8, 2017 20:08 — forked from gnou/TextSize.swift
Calculate height of some text when width is fixed
public struct TextSize {
fileprivate struct CacheEntry: Hashable {
let text: String
let font: UIFont
let width: CGFloat
let insets: UIEdgeInsets
fileprivate var hashValue: Int {
return text.hashValue ^ Int(width) ^ Int(insets.top) ^ Int(insets.left) ^ Int(insets.bottom) ^ Int(insets.right)

Principles of Adult Behavior

  1. Be patient. No matter what.
  2. Don’t badmouth: Assign responsibility, not blame. Say nothing of another you wouldn’t say to him.
  3. Never assume the motives of others are, to them, less noble than yours are to you.
  4. Expand your sense of the possible.
  5. Don’t trouble yourself with matters you truly cannot change.
  6. Expect no more of anyone than you can deliver yourself.
  7. Tolerate ambiguity.
  8. Laugh at yourself frequently.
@wilmarvh
wilmarvh / git checkout-all-branches.sh
Created April 22, 2019 20:11
git checkout-all-branches
#!/bin/bash
#Whenever you clone a repo, you do not clone all of its branches by default.
#If you wish to do so, use the following script:
for branch in `git branch -a | grep remotes | grep -v HEAD | grep -v master `; do
git branch --track ${branch#remotes/origin/} $branch
done
@wilmarvh
wilmarvh / keybase.md
Created May 3, 2019 09:45 — forked from webframp/keybase.md
Signing git commits on github using keybase.io gpg key

Probably one of the easiest things you'll ever do with gpg

Install Keybase: https://keybase.io/download and Ensure the keybase cli is in your PATH

First get the public key

keybase pgp export | gpg --import

Next get the private key

private func with<T: NSView>(_ value: T, _ builder: (T) -> Void) {
builder(value)
}
private func with<T: NSView>(_ value: T, _ builder: (T) throws -> Void) rethrows {
try builder(value)
}
// Use
with(self.collectionView) {
@wilmarvh
wilmarvh / ExtensionURLRequest.swift
Created July 31, 2020 21:09 — forked from abhi21git/ExtensionURLRequest.swift
Ever wanted to generate cURL from URLRequest for faster debugging? Simply convert URLRequest in cURL format (Swift)
//
// ExtensionURLRequest.swift
//
// Created by Abhishek Maurya on 16/07/20.
// Copyright © 2020. All rights reserved.
//
import Foundation
extension URLRequest {