Skip to content

Instantly share code, notes, and snippets.

David Wagner mnem

Block or report user

Report or block mnem

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 recursive-locks.md

Recursive mutexes are a hack

Recursive mutexes are a hack. There's nothing wrong with using them, but they're a crutch. Got a broken leg or library? Fine, use the crutch. But at least be aware that you're using a crutch, and why; and once in a while check out the leg (or library) to be sure you still need the crutch. And if it's not healing up, go see a doctor, because that's just not OK. When you have no choice, there's no shame in using a crutch... but you can't run very well on a crutch, and you'll also be slowing down anyone who depends on you.

View mojave-ios-support.txt
/System/iOSSupport
├── System
│   └── Library
│   ├── AccessibilityBundles
│   │   ├── AVFoundation.axbundle
│   │   ├── AVKit.axbundle
│   │   ├── AccessibilitySettingsLoader.bundle
│   │   ├── AdSheet.axbundle
│   │   ├── AddressBook-Assistant.axbundle
│   │   ├── AddressBookUIFramework.axbundle
View man xccov
xccov(1) xccov(1)
NAME
xccov - view Xcode coverage data in human-readable or machine-parseable format.
SYNOPSIS
xccov view [--only-targets | --files-for-target target_name | --functions-for-file name_or_path]
@mnem
mnem / 00-setting-up-a-scaleway-ghost-server.md
Last active May 23, 2019
Setting up ghost on scaleway because the app image they have is really rather old.
View 00-setting-up-a-scaleway-ghost-server.md

Server image

I use Ubuntu 16.04/Ubuntu Xenial.

Setup server

Add a new user who isn't root, but who can sudo:

  1. Update all the things: apt-get update && apt-get dist-upgrade && apt-get autoremove
  2. Reboot, just in case: shutdown -r now
@mnem
mnem / heterogenous.swift
Created Aug 30, 2017
Decoding values from silly heterogenous JSON arrays.
View heterogenous.swift
//: Playground - noun: a place where people can play
import Foundation
let json = """
[
{"person":{"name":"foo", "age":20}},
{"house":{"size":"large"}}
]
""".data(using: .utf8)!
View foo.cpp
//
// main.cpp
// jpm-code-dojo-2015-05-cpp
//
// Created by David Wagner on 18/05/2015.
// Copyright (c) 2015 David Wagner. All rights reserved.
//
#include <iostream>
#include <set>
View dojo_01.swift
import Cocoa
//: Types to make my typing life simpler
typealias Cell = Int
typealias Board = [Cell]
typealias CellPosition = Int
typealias PackedBoard = Int64
typealias AddNeighbours = (Board, CellPosition) -> Cell
typealias SwapNeighbours = (Board, CellPosition) -> Board
typealias Mutator = (add:AddNeighbours, swap:SwapNeighbours)
@mnem
mnem / NAHMainTable.h
Created May 4, 2015
An opaque navigation bar with an arbitrary background color and single pixel divider color on iOS 7+. This is more faff than it should be.
View NAHMainTable.h
#import <UIKit/UIKit.h>
@interface NAHMainTable : UITableViewController
@end
View DemonstratesUITableViewRowActionUITableViewController.m
- (NSArray *)tableView:(UITableView *)tableView editActionsForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewRowAction *moreAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDefault title:@"More" handler:^(UITableViewRowAction *action, NSIndexPath *indexPath){
// maybe show an action sheet with more options
[self.tableView setEditing:NO];
}];
moreAction.backgroundColor = [UIColor lightGrayColor];
UITableViewRowAction *blurAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDefault title:@"Blur" handler:^(UITableViewRowAction *action, NSIndexPath *indexPath){
[self.tableView setEditing:NO];
}];
View gist:eab8e687b2495c4a5676
### Keybase proof
I hereby claim:
* I am mnem on github.
* I am mnem (https://keybase.io/mnem) on keybase.
* I have a public key whose fingerprint is 1D88 0A68 B233 8A02 1B92 393A 17C9 EF8D 13F7 7DC2
To claim this, I am signing this object:
You can’t perform that action at this time.