Skip to content

Instantly share code, notes, and snippets.

View klaaspieter's full-sized avatar
Working from home

Klaas Pieter Annema klaaspieter

Working from home
View GitHub Profile
klaaspieter / SFLinkTextField
Created January 13, 2010 14:06
A hackish subclass of CPTextField to show hyperlinks
View SFLinkTextField
@import "_CSLinkTextView.j"
@implementation CSLinkTextField : CPTextField
CPString _link;
+ (id)themeAttributes
return [CPDictionary dictionaryWithObjects:[nil]
View CPWindowController loadSheet
- (void)loadWindow
[super loadWindow];
// It's impossible to load a CPDocModalWindow from nib, we work around this by
// checking if the loaded window has the correct stylemask, if not we create a new window
// with the same size as the old one and set the content view reference to that of the old window
if ([_window styleMask] !== CPDocModalWindowMask)
var contentView = [_window contentView];
View gist:481288
[[CPDate dateWithTimeIntervalSince1970:seconds] isEqualToDate:[CPDate dateWithTimeIntervalSince1970:seconds]]
// initWithTimeIntervalSince1970 is defined as
- (id)initWithTimeIntervalSince1970:(CPTimeInterval)seconds
self = new Date(seconds * 1000);
return self;
// equalToDate was defined as (not working)
View CPUserDefaults.j
* CPUserDefaults.j
* AppKit
* Created by Nicholas Small.
* Copyright 2009, 280 North, Inc.
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
View gist:640489
- (BOOL)tableView:(NSTableView *)aTableView writeRowsWithIndexes:(NSIndexSet *)rowIndexes toPasteboard:(NSPasteboard *)pasteBoard
[pasteBoard declareTypes:[NSArray arrayWithObjects:
nil] owner:self];
NSData *data = [NSKeyedArchiver archivedDataWithRootObject:rowIndexes];
[pasteBoard setData:data forType:ESTemplateIndexesTableDragType];
klaaspieter / KPNumberFormatter.j
Created November 3, 2010 21:37
A Objective-J wrapper around the jQuery globalization library
View KPNumberFormatter.j
KPNumberFormatterNoStyle = 0;
KPNumberFormatterDecimalStyle = 1;
KPNumberFormatterCurrencyStyle = 2;
KPNumberFormatterPercentStyle = 3;
@implementation KPNumberFormatter : CPFormatter
KPNumberFormatterStyle _numberStyle @accessors(property=numberStyle);
BOOL _generatesDecimalNumbers @accessors(property=generatesDecimalNumbers);
klaaspieter /
Created January 27, 2011 20:30
Command line tool that runs nib2cib for changed nibs
#!/usr/bin/env python
# encoding: utf-8
import sys
import os
import commands
import hashlib
import getopt
from pyfsevents import registerpath, listen
View MixinTest.j
* Provide a simple mixin helper to extend classes without inheritence. At the same
* time, this demostrates various scenarios when using mixins.
* For more information, check out (branch URL - release 0.8.1 of cappuccino)
* Note: this code is base on version 0.8.1 of Cappuccino.
* Install OJTest framework ( and this class
* can be called:
klaaspieter / gist:908433
Last active November 14, 2020 14:13
Get a revision number from git by counting the number of commits
View gist:908433
git rev-list --count --all
View gist:955025
GLOBAL(objj_backtrace_decorator) = function(msgSend)
return function(aReceiverOrSuper, aSelector)
var aReceiver = aReceiverOrSuper && (aReceiverOrSuper.receiver || aReceiverOrSuper);
objj_backtrace.push({receiver: aReceiver, selector:aSelector});
var retVal = msgSend.apply(NULL, arguments);