Skip to content

Instantly share code, notes, and snippets.

View PsychoH13's full-sized avatar

Remy Demarest PsychoH13

  • Grasse, France / San Francisco, California
View GitHub Profile
import Cocoa
let concurrentQueue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0)
let serialQueue = dispatch_queue_create("queue", 0)
let array = [ "'0'", "'1'", "'2'", "'3'", "'4'", "'5'", "'6'", "'7'", "'8'", "'9'", "'10'" ]
for x in 1..10 {
let str = array[x];
dispatch_async(serialQueue) { println("serial: \(x) \(str)") }
// New Style.
// MyClass.h
@interface MyClass : NSObject
- (void)foo;
@end
// MyClass.m
@PsychoH13
PsychoH13 / block-invoke.m
Created August 5, 2013 17:57
Invoke a block using NSInvocation
#import <Foundation/Foundation.h>
int main(int argc, char **argv)
{
@autoreleasepool
{
void (^testBlock)(NSString *test) =
^(NSString *test)
{
NSLog(@"%@", test);
@PsychoH13
PsychoH13 / import.m
Created June 28, 2013 22:05
#import problem
//----------------------------------------
// A.h
#import "B.h"
@interface A : NSObject
@property B *obj;
@end
// ---------------------------------------
// A.m
@PsychoH13
PsychoH13 / UIStoryboard+PSYStoryboardDelegate.h
Last active December 18, 2015 05:59
UIStoryboard delegate additions
/*
UIStoryboard+PSYStoryboardDelegate.h
Created by Remy "Psy" Demarest on 08/06/2013.
Copyright (c) 2013. Remy "Psy" Demarest
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
@PsychoH13
PsychoH13 / test.mm
Last active December 17, 2015 19:19
#import <Foundation/Foundation.h>
class MyClass {
public:
MyClass() { NSLog(@"Hello there"); }
MyClass(NSString *str) { NSLog(@"Hello %@", str); }
};
static MyClass myStatic(@"Outsider");
@PsychoH13
PsychoH13 / Test.m
Created May 2, 2013 18:09
Message to super
#import <objc/runtime.h>
#import <Foundation/Foundation.h>
@interface Superclass1 : NSObject
- (void)testMethod;
@end
@interface Superclass2 : NSObject
- (void)testMethod;
@PsychoH13
PsychoH13 / NES USB GamePad.txt
Last active December 15, 2015 12:39
Xbox 360 IOHIDDevice elements tree converted to OEHIDEvents.
0x103067000 event: (null)
| 0x10305b560 event: <OEHIDEvent 0x1025612c0 pad=(null) type=Axis axis=Z direction=Nul value=0.000000 'Z=' cookie=5>
| | 0x103069b00 event: <OEHIDEvent 0x10326fd60 pad=(null) type=Button number=16 state=On 'Button 16' cookie=39>
| | 0x103069a80 event: <OEHIDEvent 0x103029d90 pad=(null) type=Button number=15 state=On 'Button 15' cookie=38>
| | 0x103069a00 event: <OEHIDEvent 0x102381850 pad=(null) type=Button number=14 state=On 'Button 14' cookie=37>
| | 0x103069980 event: <OEHIDEvent 0x102537fe0 pad=(null) type=Button number=13 state=On 'Button 13' cookie=36>
| | 0x103069900 event: <OEHIDEvent 0x1017392f0 pad=(null) type=Button number=12 state=On 'Button 12' cookie=35>
| | 0x103068a90 event: <OEHIDEvent 0x10237a910 pad=(null) type=Button number=8 state=On 'Button 8' cookie=31>
| | 0x103068a10 event: <OEHIDEvent 0x10255d000 pad=(null) type=Button number=7 state=On 'Button 7' cookie=30>
| | 0x103068990 event: <OEHIDEvent 0x10238ba00 pad=(null) type=Butt
#import <Foundation/Foundation.h>
@interface MYClass : NSObject
+ (void)errorMethod:(NSObject *(^)(NSObject *))block;
+ (void)method:(id(^)(id))block;
@end
int main(int argc, const char * argv[])
{
@autoreleasepool
@PsychoH13
PsychoH13 / syntax-abuse.m
Created November 27, 2012 22:42
Syntax abuse in ObjC
#import <objc/runtime.h>
#import <Foundation/Foundation.h>
@interface NSObject ()
- (id)objectForKeyedSubscript:(id)key;
@end