THIS IS A BLOG POST DRAFT THAT I WILL NEVER PUBLISH
INSTEAD I PLAN TO DO A SERIES OF SMALLER BLOG POSTS ON THE SUBJECT
I write new code in Swift. It’s fun and I like it.
#!/usr/local/bin/node | |
// 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: https://github.com/einars/js-beautify | |
// |
BOOL RSIsEmpty(id obj) { | |
return obj == nil || obj == [NSNull null] || ([obj respondsToSelector:@selector(length)] && [(NSData *)obj length] == 0) || ([obj respondsToSelector:@selector(count)] && [obj count] == 0); | |
} | |
BOOL RSStringIsEmpty(NSString *s) { | |
/*22 Feb. 2011: added NSNull check. JSON parser can put a null where we expect a string, and NSNull throws an exception when checking length. Since [NSNull null] is, arguably, emptiness, it makes sense to include it.*/ | |
return s == nil || (id)s == (id)[NSNull null] || [s length] == 0; | |
} |
// This is the traditional version of the RxSwift-based gist posted here: | |
// https://gist.github.com/cliss/51cb740b14f3cd56ba1d11f2a9a6ba02 | |
// 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 |
@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; |
//: Playground - noun: a place where people can play | |
import Cocoa | |
class Person: Hashable { | |
let firstName: String | |
let lastName: String | |
let email: String |
#!/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. |
//: Playground - noun: a place where people can play | |
import Cocoa | |
protocol Account: Equatable { | |
var accountID: String {get} | |
} | |
// https://twitter.com/optshiftk/status/628985834801336320 |
#pragma mark - Class Methods | |
+ (BOOL)requiresConstraintBasedLayout { | |
return YES; | |
} | |
#pragma mark - Init | |
- (id)initWithFrame:(CGRect)frame { |
#!/usr/bin/python | |
import sys | |
import os | |
from urllib import urlencode | |
import subprocess | |
# setClipboardData is from <http://www.macdrifter.com/2011/12/python-and-the-mac-clipboard/>*/ | |
def setClipboardData(data): |