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
[RKRequestDescriptor requestDescriptorWithMapping:[mappingProvider.orderConfirmationMapping inverseMapping]
objectClass:[WTNOrderConfirmation class]
rootKeyPath:@"confirmation"
method:RKRequestMethodPOST];
// In the mapping provider
- (RKObjectMapping *)orderConfirmationMapping;
{
if (!_orderConfirmationMapping) {
_orderConfirmationMapping = [RKObjectMapping mappingForClass:[WTNOrderConfirmationResponse class]];
class MockURLSession : NSURLSession {
var request: NSURLRequest?
override func dataTaskWithRequest(request: NSURLRequest, completionHandler: ((NSData!, NSURLResponse!, NSError!) -> Void)?) -> NSURLSessionDataTask {
self.request = request
return super.dataTaskWithRequest(request, completionHandler: completionHandler)
}
}
@klaaspieter
klaaspieter / Karma.clr
Last active August 29, 2015 14:09
Karma colors. Place these files in ~/Library/Colors.
@klaaspieter
klaaspieter / SFLinkTextField
Created January 13, 2010 14:06
A hackish subclass of CPTextField to show hyperlinks
@import "_CSLinkTextView.j"
@implementation CSLinkTextField : CPTextField
{
CPString _link;
}
+ (id)themeAttributes
{
return [CPDictionary dictionaryWithObjects:[nil]
- (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];
[[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)
/*
* 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
- (BOOL)tableView:(NSTableView *)aTableView writeRowsWithIndexes:(NSIndexSet *)rowIndexes toPasteboard:(NSPasteboard *)pasteBoard
{
[pasteBoard declareTypes:[NSArray arrayWithObjects:
ESTemplateIndexesTableDragType,
NSFilenamesPboardType,
nil] owner:self];
NSData *data = [NSKeyedArchiver archivedDataWithRootObject:rowIndexes];
[pasteBoard setData:data forType:ESTemplateIndexesTableDragType];
@klaaspieter
klaaspieter / KPNumberFormatter.j
Created November 3, 2010 21:37
A Objective-J wrapper around the jQuery globalization library
KPNumberFormatterNoStyle = 0;
KPNumberFormatterDecimalStyle = 1;
KPNumberFormatterCurrencyStyle = 2;
KPNumberFormatterPercentStyle = 3;
@implementation KPNumberFormatter : CPFormatter
{
KPNumberFormatterStyle _numberStyle @accessors(property=numberStyle);
BOOL _generatesDecimalNumbers @accessors(property=generatesDecimalNumbers);
@klaaspieter
klaaspieter / autonib2cib.py
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