Skip to content

Instantly share code, notes, and snippets.

View Ben-G's full-sized avatar
💭
💻

Benjamin Encz Ben-G

💭
💻
View GitHub Profile
@jquave
jquave / jamesonquave.com comment reply
Created June 3, 2014 01:05
jamesonquave.com comment reply
import UIKit
class AnotherClass {
var someVar = 1
let someConst = 2
func somePrivateFunc() -> Bool {
return true
}
@sgleadow
sgleadow / RunPlatformUnitTests.sh
Created April 18, 2012 03:11
Modified shell script to run OCUnit and Kiwi tests on the command line.
#!/bin/sh
##
# Copyright 2008 Apple Inc.
# All rights reserved.
#
# iPhoneSimulator platform
# This script runs all of the unit tests for the target test bundle specified by the passed-in environment.
# This script is generally intended to be invoked by ${DEVELOPER_TOOLS_DIR}/RunUnitTests. The interface or location of this script may change in future releases.
##
#
@stuartcarnie
stuartcarnie / main.m
Created September 16, 2012 04:30
tail call with fake msgSend in Objective C
#import <Foundation/Foundation.h>
#import <objc/message.h>
extern id fake_msgSend(id, SEL, int) __attribute__((noinline));
@interface Foo : NSObject
- (id)foo:(int)n;
@end
@mchambers
mchambers / serializer.swift
Created June 25, 2014 07:49
A simple, limited model-to-JSON serializer in Swift.
// Here we'll use Swift's IDE-supporting reflect()
// function to build a basic JSON serializer.
// Per the fine engineers at WWDC, Swift's reflection support
// exists purely to support the IDE and the Playground. But
// we can have some fun with it anyway. ;)
class SerializerBase {
}
@nsomar
nsomar / Lazy collection implementation
Created August 6, 2014 23:46
Implementation of lazy collection in swift
typealias Closure = (Int) -> (Bool)
class MyFilterArrayView: SequenceType, GeneratorType {
var _array: [Int]?
var _lazyFilter: MyFilterArrayView?
var _closure: Closure
var _currentIndex: Int = 0
var array: [Int] {
get {
@dankogai
dankogai / church.swift
Created June 15, 2014 09:44
Lambda Calculus in Swift
//
// main.swift
// church
//
// Created by Dan Kogai on 6/15/14.
// Copyright (c) 2014 Dan Kogai. All rights reserved.
//
/* Operators */
@MarcoSero
MarcoSero / gist:5787782
Created June 15, 2013 11:15
Class Dump iOS 7 Frameworks
# install class-dump
brew install class-dump
# dump the frameworks you're interested in
class-dump -H -o UIKit /Applications/Xcode5-DP.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk/System/Library/Frameworks/UIKit.framework
class-dump -H -o SpringBoardUI /Applications/Xcode5-DP.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk/System/Library/PrivateFrameworks/SpringBoardUI.framework
@armadsen
armadsen / MultipleClassExtensions.m
Last active January 4, 2016 11:59
Demonstration of multiple class extensions in Objective-C. For http://stackoverflow.com/a/21343983/344733
#import <Foundation/Foundation.h>
@interface TestClass : NSObject
@end
@interface TestClass ()
@property NSString *name;
@jspahrsummers
jspahrsummers / MultipleDispatch.cpp
Last active August 20, 2016 14:30
Example of using RTTI and template specialization for multiple dispatch in C++
template<typename Left, typename Right>
struct Intersect
{
// This will fail to compile if there's no specialization for Intersect<Right, Left>,
// thereby verifying that we've handled all combinations.
typename Intersect<Right, Left>::Result operator() (const Left &lhs, const Right &rhs) const
{
return Intersect<Right, Left>()(rhs, lhs);
}
};
@fnurl
fnurl / pygmentize-clipboard-highlighter.sh
Last active April 6, 2017 21:56
Highlight code in clipboard using pygmentize (Mac)
#!/bin/bash
pbpaste | pygmentize -O"style=tango, fontface=Menlo" -f rtf -l $1 | pbcopy