Skip to content

Instantly share code, notes, and snippets.

//
// NSObject+BlockObservation.h
// Version 1.0
//
// Andy Matuschak
// andy@andymatuschak.org
// Public domain because I love you. Let me know how you use it.
//
#import <Cocoa/Cocoa.h>
// Puncture a closure, absolute madness
Function.prototype.puncture = function(){
var wormhole = function(__cmd__){
return eval(__cmd__);
};
var source = ('' + this).match(/function.+?\{([\s\S]*)\}/)[1];
var fn = new Function('this.wormhole=' + wormhole + '\n' + source);
@subtleGradient
subtleGradient / Brilliance Black (Inverted).tmTheme
Created January 3, 2010 22:52
Brilliance Black, My Little Pony (Brilliance White), Brilliance Dull TextMate Themes in the `tmTheme` format. By Thomas Aylott (SubtleGradient). These themes were designed so that logically similar things will have similar colors. These are extremely rich
<?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">
<plist version="1.0">
<dict>
<key>author</key>
<string>Thomas Aylott</string>
<key>comment</key>
<string>Thomas Aylott ㊷ subtleGradient.com</string>
<key>name</key>
<string>Brilliance Black (Inverted)</string>
@xulapp
xulapp / class.js
Created March 12, 2010 14:08
Class
function Class(sup, pro) {
if (sup && typeof sup === 'object')
pro = sup, sup = Object;
var con = Object.getOwnPropertyDescriptor(pro, 'constructor');
if (!con)
con = {value: Function(), writable: true, configurable: true};
if (con.configurable) {
con.enumerable = false;
@isaacs
isaacs / comma-first-var.js
Created April 6, 2010 19:24
A better coding convention for lists and object literals in JavaScript
// See comments below.
// This code sample and justification brought to you by
// Isaac Z. Schlueter, aka isaacs
// standard style
var a = "ape",
b = "bat",
c = "cat",
d = "dog",
@subtleGradient
subtleGradient / global.jq.js
Created April 9, 2010 05:15
HTML5 Template with className states and browser detection
// Swap classes onload and domready
$(function(){ $('html').removeClass('not-ready').addClass('ready'); }); // jQuery
$(window).load(function(){ $('html').removeClass('loading').addClass('loaded'); });
// target a specific version
if (navigator.isIE == 6){
// do stuff for IE6
}
// Deliever different behaviour for a group of IE versions
@rjungemann
rjungemann / Communicator.h
Created June 21, 2010 00:45
How to open a TCP socket in Objective-C
#import <Foundation/Foundation.h>
@interface Communicator : NSObject <NSStreamDelegate> {
@public
NSString *host;
int port;
}
- (void)setup;
Titanium.UI.setBackgroundColor('#000');
//Main Tab Group
var tabGroup = Titanium.UI.createTabGroup();
//Photo Selection Window
var photosWindow = Titanium.UI.createWindow({
url:'photos.js',
title:'Photos',
backgroundColor:'#fff'
Titanium.UI.setBackgroundColor('#000');
//Main Tab Group
var tabGroup = Titanium.UI.createTabGroup();
//Photo Selection Window
var photosWindow = Titanium.UI.createWindow({
url:'photos.js',
title:'Photos',
backgroundColor:'#fff'
(function()
{
var _fnMap = {};
$.fn.addClass = function(classes)
{
var vs = this;
if(!(classes > '') || vs.length == 0)
return this;