Skip to content

Instantly share code, notes, and snippets.

View mflint's full-sized avatar

Matthew Flint mflint

View GitHub Profile
@mflint
mflint / DeparturesViewController.swift
Created January 26, 2019 13:02
data-driven screen dispatching for iOS
class DeparturesViewController: UIViewController, ViewController {
private var viewModel: DeparturesViewModel!
func accept(_ viewModel: ViewModel) {
self.viewModel = viewModel as? DeparturesViewModel
}
}
@mflint
mflint / StringExtension.swift
Created August 29, 2018 19:15
A hacky String extension to convert html into NSAttributedString. Very Mastodon-specific. Very ugly.
import Foundation
extension String {
class HtmlComponent {
var parent: HtmlComponent?
var children = [HtmlComponent]()
init(parent: HtmlComponent? = nil) {
self.parent = parent
}
@mflint
mflint / QuickHelpMarkupExample.swift
Created April 7, 2018 10:25
Example of markup for Xcode "Quick Help"
//: Playground - noun: a place where people can play
import Foundation
/**
This func does the fnord.
- parameters:
- foo: The foo.
- bar: The bar.
- returns: A return value.
@mflint
mflint / .screenrc
Last active March 25, 2018 14:13
.screenrc
ignorecase on
defsilence on
defmonitor on
hardstatus on
hardstatus alwayslastline
hardstatus string "%{.bW} %H %-w%{.rW}%n %t%{-}%+w %=%{..Y} %d/%m %c "
startup_message off
@mflint
mflint / ApproximateColorComparison.swift
Created January 14, 2018 20:29
UIColor extension for getting approximate colors. I use this in unit tests sometimes.
//: Playground - noun: a place where people can play
import UIKit
import XCTest
extension UIColor {
private struct Best {
var color: (color: UIColor, name: String)
var distance: CGFloat
}
@mflint
mflint / SlidesToLeftOnDeleteTableViewCell.m
Last active December 20, 2015 17:58
A subclass of UITableViewCell which slides to the left when the 'swipe to delete' gesture happens
#import "SlidesToLeftOnDeleteTableViewCell.h"
@interface SlidesToLeftOnDeleteTableViewCell ()
@property(nonatomic, assign) CGFloat deleteConfirmationShift;
@end
@implementation SlidesToLeftOnDeleteTableViewCell
- (void)prepareForReuse {
[super prepareForReuse];
@mflint
mflint / kindle-wallpaper.php
Created February 4, 2013 22:37
This takes a folder of images and creates new images suitable for Kindle wallpapers. It'll add text to the image too.
<?php
/*
* This finds all jpegs in a directory ($sourcedirectory) and creates
* an advert for each one. It will:
* - resize
* - convert to greyscale
* - add a textbox at the bottom with a header and multiple lines of
* smaller texts, supplied as two arguments on the command line. The
* second argument may contain \n to create line breaks.
*/
@mflint
mflint / JournalList.lua
Created November 23, 2012 22:13
TrunkNotes script for showing lists of journal entries
--[[
# Introduction
This is a script for handling lists of journal entries, and will display
them in two ways:
* short mode, on just one line. This contains the latest five entries,
plus a link to an 'All' page
@mflint
mflint / LRRestyClient+FailureBlock.h
Created November 21, 2011 22:01
LRResty timeout workaround
//
// LRRestyClient+FailureBlock.h
//
#import <Foundation/Foundation.h>
#import <LRResty/LRResty.h>
#import "RVRestyClientBlockDelegate.h"
@interface LRRestyClient (FailureBlock)

Keybase proof

I hereby claim:

  • I am mflint on github.
  • I am flint (https://keybase.io/flint) on keybase.
  • I have a public key whose fingerprint is 7159 7967 0976 28FB 3958 0A2D A1FD 567C 2016 837D

To claim this, I am signing this object: