Skip to content

Instantly share code, notes, and snippets.

View joerick's full-sized avatar
🏥
Offline for a while, partner in hospital

Joe Rickerby joerick

🏥
Offline for a while, partner in hospital
View GitHub Profile
@joerick
joerick / bundleTest.zip
Created February 11, 2012 13:11
KVO/KVC crash on reloading unloaded bundles
@joerick
joerick / NSApplication+MXUtilities.h
Created September 15, 2014 11:51
Launch at login category on NSApplication
//
// NSApplication+MXUtilities.h
// Mixim
//
// Created by Joe Rickerby on 15/09/2014.
// Copyright (c) 2014 Mixim Technology Ltd. Released under BSD Licence.
//
#import <Cocoa/Cocoa.h>
@joerick
joerick / MXCheckedOperation.h
Last active August 29, 2015 14:17
MXSuperOperation
//
// MXCheckedOperation.h
// Mixim
//
// Created by Joe Rickerby on 25/03/2014.
// Copyright (c) 2014 Mixim Technology Ltd. All rights reserved.
//
#import <Foundation/Foundation.h>
@joerick
joerick / gist:d52f188b926835b1f655
Created April 28, 2015 10:35
-[NSWindow _cornerMask] implementation for hosting NSVisualEffectView
- (NSImage *)_cornerMask
{
CGFloat radius = 4.0;
CGFloat dimension = 2 * radius + 1;
NSSize size = NSMakeSize(dimension, dimension);
NSImage *image = [NSImage imageWithSize:size flipped:NO drawingHandler:^BOOL(NSRect dstRect) {
NSBezierPath *bezierPath = [NSBezierPath bezierPathWithRoundedRect:dstRect xRadius:radius yRadius:radius];
[[NSColor blackColor] set];
[bezierPath fill];
test_list = [1,2,5,2]
def for_loop(the_list):
result = 0
for number in the_list:
result += number
return result
#define MXCreate(create, ...) \
({ \
__typeof__(create) obj = create; \
metamacro_foreach(_MXCreate_set, ;, __VA_ARGS__); \
obj; \
})
#define _MXCreate_set(index, set_expr) obj . set_expr
// before
_rolloverLabel = [[NSTextField alloc] init];
@joerick
joerick / appcast.xml
Last active September 19, 2016 16:11
Tide appcast
<rss xmlns:sparkle="http://www.andymatuschak.org/xml-namespaces/sparkle" xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0">
<channel>
<title>Tide Changelog</title>
<link></link>
<description>Most recent changes with links to updates.</description>
<language>en</language>
<item>
<title>v0.2.11</title>
<pubDate>Sat, 31 Oct 2014 17:20:11 +0000</pubDate>
<enclosure
@joerick
joerick / main.py
Created November 16, 2015 18:54
IFTTT to display an SMS. See https://www.youtube.com/watch?v=yZg8OIzVByM&feature=youtu.be for more info!
import tingbot
from tingbot import *
screen.fill(color='black')
screen.text('Waiting...')
@webhook('demo_sms')
def on_webhook(data):
screen.fill(color='black')
screen.text(data, color='green')
@joerick
joerick / main.m
Last active December 19, 2018 09:35
Weak KVO example
#import <Foundation/Foundation.h>
#import <objc/runtime.h>
@interface Person : NSObject
@property (strong) NSString *name;
@end
@interface Observer : NSObject
@joerick
joerick / button_event_parse.py
Created May 28, 2016 17:38
Button state machine prototype
from collections import namedtuple
import Queue, unittest
ButtonEvent = namedtuple('ButtonEvent', ('state', 'timestamp',))
ButtonAction = namedtuple('ButtonAction', ('type', 'timestamp',))
class Button(object):
def __init__(self):
self.event_queue = Queue.Queue()