Skip to content

Instantly share code, notes, and snippets.

Mark Dalrymple markd2

Block or report user

Report or block markd2

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
markd2 / gist:755ec24bfaf22461fadc830685a1ec99
Last active Feb 24, 2020
custom keybindings for
View gist:755ec24bfaf22461fadc830685a1ec99
["f", "Show next/latest diffs", "setProposedDiffBounds()"],
["n", "Next unreviewed file", "nextUnreviewedFile()"],
["p", "Previous unreviewed file", "prevUnreviewedFile()"],
[null, "Next personally unreviewed file", "nextPersonallyUnreviewedFile()"],
[null, "Previous personally unreviewed file", "prevPersonallyUnreviewedFile()"],
["shift+n", "Next changed file", "nextChangedFile()"],
["shift+p", "Previous changed file", "prevChangedFile()"],
[null, "Next visible file", "nextVisibleFile()"],
View vararg.m
// vararg.m -- use varargs to sum a list of numbers
// clang -g -Wall -o vararg vararg.m
#import <stdio.h>
#import <stdarg.h>
// sum all the integers passed in. Stopping if it's zero
View malloc.c
#import <stdio.h>
#import <stdlib.h>
// clang -g -Wall -o malloc malloc.c
int main(void) {
int *blah = malloc(sizeof(int));
printf("blah on alloc: %x\n", *blah);
*blah = 23;
markd2 / mute.m
Created Dec 18, 2018
Does `copy` really strip off mutability?
View mute.m
#import <Foundation/Foundation.h>
// clang -g -framework Foundation -o mute mute.m
int main(void) {
NSMutableString *blarg =;
NSString *copy = blarg.copy;
NSLog(@"%@ | %@", blarg.class, copy.class);
return 0;
markd2 / typealias.swift
Created Jan 22, 2018
libsyntax typealias creation
View typealias.swift
import SwiftSyntax
@greeble(bork) typealias Element = Int
let typeAliasKeyword = SyntaxFactory.makeTypealiasKeyword(leadingTrivia: .spaces(1),
trailingTrivia: .spaces(1))
let elementID = SyntaxFactory.makeIdentifier("Element", leadingTrivia: .zero, trailingTrivia: .spaces(1))
let equal = SyntaxFactory.makeEqualToken(leadingTrivia:, trailingTrivia: .spaces(1))
let intType = SyntaxFactory.makeTypeIdentifier("Int", leadingTrivia: .zero, trailingTrivia: .zero)
let initializer = SyntaxFactory.makeTypeInitializerClause(equal: equal, value: intType)
View activity.m
#import "ViewController.h"
#import <os/activity.h>
#import <os/log.h>
@interface ViewController ()
@end // extension
static os_activity_t g_appActivity;
View cgpath dump extension.swift
import CoreGraphics
private typealias CGPathDumpUtility = CGPath
extension CGPathDumpUtility {
func dump() {
self.apply(info: nil) { info, unsafeElement in
let element = unsafeElement.pointee
switch element.type {
View iconToggle.swift
import Cocoa
class ViewController: NSViewController {
var timer : Timer?
override func viewDidLoad() {
timer = Timer.scheduledTimer(withTimeInterval: 2.0, repeats: true) { timer in
View maskstuff.m
- (CGImageRef) newMaskFromImage: (UIImage *) image {
// Prior to 10.2 SDK / Xcode 8 (dunno which it is), the mask creation worked
// for all of the bucket overflow images. It failed afterwards. Dunno if the
// pngcrushing changed the color space unexpectedly, or what. But trying one and
// then falling back to the other seems to work ok now.
CGColorSpaceRef cs = CGColorSpaceCreateDeviceRGB ();
CGImageRef maskRef = CGImageCreateCopyWithColorSpace (image.CGImage, cs);
markd2 / ImageStore.swift
Created Nov 29, 2016
ImageStore.swift for the advanced ios bootcamp pre-reading
View ImageStore.swift
// Copyright © 2015 Big Nerd Ranch
import UIKit
class ImageStore {
let cache = NSCache<NSString, UIImage>()
You can’t perform that action at this time.