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
}

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:

@mflint
mflint / stripfatlibrary.sh
Created April 5, 2014 23:45
bash script to strip unwanted symbols from an Apple fat-binary library
#!/bin/sh
# this is the name of the problematic lib
FRAMEWORK=ActivityX.framework
LIB=ActivityX
# these are the duplicate symbols
SYMBOLS="AFURLRequestSerialization.o AFHTTPRequestOperationManager.o AFURLSessionManager.o"
# the architectures in the lib
@mflint
mflint / ThreadPool.java
Last active August 29, 2015 13:56
A simple thread pool in Java
package org.tthew.core;
import java.util.ArrayDeque;
import java.util.Queue;
public final class ThreadPool
{
public interface IThreadPool
{
void submitJob(final IJob job);
@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.
*/