Skip to content

Instantly share code, notes, and snippets.

View protocool's full-sized avatar

Trevor Squires protocool

  • Comox Valley, BC, Canada
View GitHub Profile
public final class UnfairLockPointer {
deinit {
pointer.deinitialize(count: 1)
pointer.deallocate()
}
private let pointer: os_unfair_lock_t
public init() {
import Foundation
protocol P {
typealias PT: NSObject = Self
static func vendSpecific() -> PT?
}
extension P where Self: NSObject, PT == Self {
static func vendSpecific() -> PT? {
return nil
@protocool
protocool / And the results are...
Created May 7, 2012 16:45
A question of taste, style, and naming
Had some great suggestions.
'set' came up a few times. It makes sense, "set the error ptrptr with your
last error". Unfortunately there's too much baggage with property setters
for that to work.
'propagate' was a good one too, but it also has a little bit of baggage,
at least for me, because propagate is often a word I use to describe the
larger concept of errors propagating up the stack. That's not the job of
this one little method.
@protocool
protocool / gist:2048775
Created March 16, 2012 06:25
Propane caveatPatchor.js snippet to display Instagram images inline
var displayInstagramImages = true;
if (displayInstagramImages) {
Campfire.InstagramExpander = Class.create({
initialize: function(chat) {
this.chat = chat;
var messages = this.chat.transcript.messages;
for (var i = 0; i < messages.length; i++) {
this.detectInstagramURL(messages[i]);
@protocool
protocool / gist:1535541
Created December 29, 2011 18:46
Propane caveatPatchor.js snippet for a /clear command
/*
Add a /clear command to clear out the chat transcript in Propane.
Place this snippet into:
~Library/Application Support/Propane/unsupported/caveatPatchor.js
*/
Campfire.Speaker.Filters.push(
function(message) {
var match;
if (match = message.match(/^\/clear\s*$/)) {
@protocool
protocool / displayDataURLImages_fragment.js
Created May 26, 2011 19:17
Propane caveatPatchor.js hack to display data:image urls inline as images
if (displayDataURLImages) {
Campfire.DataImageURLExpander = Class.create({
initialize: function(chat) {
this.chat = chat;
var messages = this.chat.transcript.messages;
for (var i = 0; i < messages.length; i++) {
this.detectDataURLImage(messages[i]);
}
},
@protocool
protocool / gist:948666
Created April 29, 2011 17:34
A gist that shows how I'm embedding gists into Propane. Probably crappy but at least it feels a bit meta...
if (displayExpandedGists) {
Campfire.GistExpander = Class.create({
initialize: function(chat) {
this.chat = chat;
var messages = this.chat.transcript.messages;
for (var i = 0; i < messages.length; i++) {
this.detectGistURL(messages[i]);
}
},
@protocool
protocool / caveatPatchor.js
Created February 14, 2011 02:29
Sample caveatPatchor.js file for use in Propane 1.1.2 and above
/*
As of version 1.1.2, Propane will load and execute the contents of
~Library/Application Support/Propane/unsupported/caveatPatchor.js
immediately following the execution of its own enhancer.js file.
You can use this mechanism to add your own customizations to Campfire
in Propane.
Below you'll find two customization examples.
@protocool
protocool / caveatPatchor.js
Created February 11, 2011 01:00
Sample Propane caveatPatchor.js file
/**
Sample Propane caveatPatchor.js file based on tmm1's avatar hack.
You'll need at least version 1.1.1 to experiment with this:
http://propaneapp.com/appcast/Propane.1.1.1.zip
Once I'm sure exposing this hack-injection point doesn't cause problems
I'll do an official auto-updating version.
As of version 1.1.1, Propane will load and execute the contents of