Skip to content

Instantly share code, notes, and snippets.

Brent Simmons brentsimmons

Block or report user

Report or block brentsimmons

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
brentsimmons / gist:5810992
Last active May 31, 2020
Detect a tap on a URL inside a UITextView. Note: the rs_links method isn't included -- you'll need something that takes text and returns an array of detected links. This gist just demonstrates walking through the UITextView characters.
View gist:5810992
@implementation UITextView (RSExtras)
static BOOL stringCharacterIsAllowedAsPartOfLink(NSString *s) {
/*[s length] is assumed to be 0 or 1. s may be nil.
Totally not a strict check.*/
if (s == nil || [s length] < 1)
return NO;
brentsimmons / JavaScript Indent.js
Last active May 16, 2020
This is a BBEdit text filter for indenting (and beautifying) JavaScript.
View JavaScript Indent.js
// PBS 12/5/13
// This is a BBEdit text filter for indenting (and beautifying) JavaScript.
// It goes in ~/Library/Application Support/BBEdit/Text Filters/
// On my machine I assigned it a keyboard shortcut: cmd-'
// It requires the js-beautify Node module:
View gist.swift
// This is the traditional version of the RxSwift-based gist posted here:
// This won’t compile and it surely has errors.
// (The same may be true as the original.)
// Some things are obviously omitted.
// It's meant as illustrative rather than as actual running code.
// The problem being solved:
// There is a text field. When you type in it, all changes are coalesced
// for 0.3 seconds, and then an HTTP call is made, and a table is updated
brentsimmons / SecretSanta.swift
Created Sep 25, 2015
My solution for the Omni Group’s Swift Bike Shedding Club week two question:
View SecretSanta.swift
//: Playground - noun: a place where people can play
import Cocoa
class Person: Hashable {
let firstName: String
let lastName: String
let email: String
View metaweblog.rb
#!/usr/bin/env ruby -wKU
# Comments added 6 March 2014.
# Implementation of the MetaWeblog API for my personal Ruby static blog generator.
# This is not even nearly idiomatic Ruby. There are all kinds of issues.
# (What's with the method interiors all being mushed-up together?)
# But -- it's also worked flawlessly for five years without my having to edit it.
# It won't work for anyone else as-is — but if it helps anyone
# to do a MetaWeblog API implementation, then cool.
brentsimmons / declarative_code.markdown
Last active Apr 30, 2019
A draft of a blog post that will never be published.
View declarative_code.markdown



The Objective-C Runtime and Declarative Programming

I write new code in Swift. It’s fun and I like it.

View protocolequatable.swift
//: Playground - noun: a place where people can play
import Cocoa
protocol Account: Equatable {
var accountID: String {get}
brentsimmons / headerview.m
Created Apr 26, 2014
UITableView header issues
View headerview.m
#pragma mark - Class Methods
+ (BOOL)requiresConstraintBasedLayout {
return YES;
#pragma mark - Init
- (id)initWithFrame:(CGRect)frame {
brentsimmons /
Created Aug 1, 2012
A script that generates a Google search URL and pastes it to the Mac OS X clipboard
import sys
import os
from urllib import urlencode
import subprocess
# setClipboardData is from <>*/
def setClipboardData(data):
View AddObserverTakeTwo.swift
//: Playground - noun: a place where people can play
import Cocoa
// I’m trying to figure out how to add a Notification observer in Swift code where the notification name is defined in a .m file.
// This playground won’t actually run, because it assumes an NSString named SomeNotification defined in a .m file. So it can’t actually be used to see the errors. It’s just for illustration.
// The errors are listed in the comments.
class MyClass {
You can’t perform that action at this time.