Skip to content

Instantly share code, notes, and snippets.

View masonmark's full-sized avatar
🕺
totally

Mason masonmark

🕺
totally
View GitHub Profile
// ContextualMenuTableView.j Created by mason on 2010/07/26. This source code is in the public domain.
// NOTES: This subclass adds simple right-click contextual menu support to CPTableView.
// It does not work with Cappuccino 0.8.1, but it works with the latest master branch as of
// 2010-07-27. To use it, just have your table's delegate implement -tableView:contextualMenuForRows:.
// The table view handles updating the selection before invoking the delegate method. This doesn't
// support the cool modern Mac OS X 10.6 style of contextual menus that don't destructively change
// the user selection (discussed by me in this thread: http://groups.google.com/group/objectivej/browse_thread/thread/129dca07459d9325 ),
@masonmark
masonmark / gist:1020512
Created June 11, 2011 12:20 — forked from pmuellr/gist:1004413
BBEdit Language Module for CoffeeScript
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<!--
BBEdit Language Module for CoffeeScript
Put this file in
~/Library/Application Support/BBEdit/Language Modules
or equivalent.
Based off of the examples shipped in the BBEdit SDK.
@masonmark
masonmark / gdb backtrace
Created September 21, 2011 06:49
passenger phubar - various debuggery
mason@ubuntu:~$ sudo bash
[sudo] password for mason:
root@ubuntu:~#
root@ubuntu:~#
root@ubuntu:~#
root@ubuntu:~#
root@ubuntu:~#
root@ubuntu:~# sudo gdb
sudo: gdb: command not found
root@ubuntu:~# apt-get install gdb
@masonmark
masonmark / PhantomJS 1.3 binary results (bogus).txt
Created October 4, 2011 01:53
EUC-encoded Japanese issue debugging
[mason@IT-PC-MACPRO-01 dna2]$ echo 'First let us use the PhantomJS 1.3 binary download:'First let us use the PhantomJS 1.3 binary download:
[mason@IT-PC-MACPRO-01 dna2]$ phantomjs euc_test.coffee
☆ LOAD STATUS: success
☆ PAGE TITLE:ÆüËܸì - Japanese test
☆ PAGE CONTENT: <html><head>
<meta http-equiv="Content-Type" content="text/html; charset=euc-jp">
<title>ÆüËܸì - Japanese test</title>
</head><body>
<p>ÆüËܸì¤Î¥Æ¥­¥¹¥È¡£</p>
@masonmark
masonmark / phantomjs-sandbox-woes.coffee
Created October 5, 2011 07:07
phantomjs-sandbox-woes
find_elements = (tag_name, properties = {}, die_if_not_found = true) ->
# Find all elements of type tag_name that match properties. E.g.: find_elements "input", {type: "image", src: "my_img.jpg"}. Note that if you are looking for an element by its 'src' property (e.g. for an image), be aware that the if the HTML specifies something like /foo/bar that actual property value will be something like "http://192.168.155.100/foo/bar". There may be other element properties which aren't exactly identical to what is specified in the HTML(?).
result = null
all_elements = document.getElementsByTagName(tag_name)
filtered = filter_elements all_elements, properties
if filtered.length > 0
filtered
else
if die_if_not_found
die "unable to find required page element of type '#{tag_name}' matching #{JSON.stringify properties}'"
Anonymous UUID: 906F4C43-A62F-E5B8-42BA-0DF615FED023
Sat Oct 26 13:14:15 2013
panic(cpu 2 caller 0xffffff80058dc19e): Kernel trap at 0xffffff7f87107855, type 14=page fault, registers:
CR0: 0x000000008001003b, CR2: 0x0000000000000100, CR3: 0x00000002f31140f5, CR4: 0x00000000001606e0
RAX: 0x0000000020020200, RBX: 0xffffff81b5bd8000, RCX: 0x0000000105e20000, RDX: 0xffffff81b5bd926c
RSP: 0xffffff81ddf23930, RBP: 0xffffff81ddf23980, RSI: 0x0000000000000100, RDI: 0x0000000000000207
R8: 0xffffff829c847020, R9: 0x0000000000000000, R10: 0x0000000000000000, R11: 0x0000000000000001
R12: 0x0000000000000001, R13: 0xffffff81b5bd8178, R14: 0xffffff803995f501, R15: 0xffffff81b5bd9150
RFL: 0x0000000000010206, RIP: 0xffffff7f87107855, CS: 0x0000000000000008, SS: 0x0000000000000010
@masonmark
masonmark / gist:e5e607b894ab4fe4dce3
Created February 27, 2015 07:04
Xcode Shell Script Build Phase for compiling CoffeeScript code during build
export NODE_PATH=/usr/local/lib/node:/usr/local/lib/node_modules
export PATH=/usr/local/bin:$PATH
echo "Compiling .coffee assets..."
RESULT=`/usr/local/bin/coffee -c ${PROJECT_DIR}`
if [ $? -ne 0 ]
then
echo "The coffee command exited with non-zero exit status."
This is some example text.
And some more. AND SOME MORE.
@masonmark
masonmark / CatchObjCException.h
Created November 14, 2015 06:28
CatchObjCException can catch objc exception
// CatchObjCException.h Created by mason on 2015-10-30. Copyright © 2015 mason. All rights reserved.
#import <Foundation/Foundation.h>
/// An Objective-C function that executes `block` using `\@catch` to trap and return any thrown NSException.
///
/// WHY: Although "discouraged" for years, Apple's system frameworks nevertheless throw exceptions in many places. There
/// is no way in Swift code to handle these exceptions; the application will simply crash whenever Foundation or AppKit
/// throws an exception. (It seems inconceivable that Apple would not address this somehow, someday, but it's still true
/// as of Swift 2.1 in October 2015. (Also, I suspect they might address it by fixing the frameworks, not Swift.))
@masonmark
masonmark / build.rb
Created March 20, 2016 01:01
A build script in ruby, then rewritten in swift
#!/usr/bin/env ruby
# A script to clean-build all 3 targets in one step, and return success/failure (0/nonzero).
require 'pathname'
require 'fileutils'
require 'open3'
PATH_TO_ME = Pathname.new(File.expand_path(__FILE__))
PATH_TO_ROOT = PATH_TO_ME.parent.parent