Skip to content

Instantly share code, notes, and snippets.

View acefsm's full-sized avatar

acefsm acefsm

View GitHub Profile
@rsms
rsms / HUnorderedMap.hh
Created November 17, 2010 17:56
Testing (lookup) performance of different hash map algorithms for constant keys (pointer is hash)
#ifndef H_UNORDERED_MAP_
#define H_UNORDERED_MAP_
#import <tr1/unordered_map>
template<class K, class T>
class HUnorderedMap {
public:
typedef typename std::tr1::unordered_map<K, T > Map;
typedef typename Map::value_type ValueType;
@bignerdranch
bignerdranch / BNRTimeBlock.h
Created March 9, 2012 13:51
Timing Utility Post 20120308
CGFloat BNRTimeBlock (void (^block)(void));
@hollance
hollance / NSObject+MHOverride.h
Created July 18, 2012 21:01
Overriding methods without making a subclass
@interface NSObject (MHOverride)
/*
* Dynamically overrides the specified method on this particular instance.
*
* The block's parameters and return type must match those of the method you
* are overriding. However, the first parameter is always "id _self", which
* points to the object itself.
*
@nielsbot
nielsbot / gist:5155671
Last active January 16, 2025 12:46
A wrapper around kqueue to monitor changes to files. Works on iOS.
#import "FileChangeObserver.h"
#undef Assert
#define Assert(COND) { if (!(COND)) { raise( SIGINT ) ; } }
@interface FileChangeObserver ()
@property ( nonatomic, readonly ) int kqueue ;
@property ( nonatomic ) enum FileChangeNotificationType typeMask ;
@end
// FILED: rdar://17240493
// Type constraint ignored on function type parameter
//
protocol BoolT {}
class TrueT : BoolT {}
class FalseT : BoolT {}
protocol Nat {
typealias IsZero
@staltz
staltz / introrx.md
Last active April 24, 2025 06:10
The introduction to Reactive Programming you've been missing
@steipete
steipete / Defaults.xcconfig
Last active February 1, 2020 15:06
The prelude to the warnings configuration we use in the PSPDFKit iOS framework - http://pspdfkit.com
//
// Defaults.xcconfig
//
// Common customizations/sanitizations of the platform defaults for our projects.
//
// For compatibility reasons, the iOS platform has a couple of not–so–sensible defaults.
// This file collects, and annotates the deviations from these defaults.
//
// :NOTE: Some of the settings herein may be redundant for newly created projects/targets:
// Xcode’s project/target templates take several (but not all!) of these issues into account.
@steipete
steipete / PSPDFEnvironment.m
Last active March 5, 2024 09:15
Example for DISPATCH_SOURCE_TYPE_MEMORYPRESSURE (Mac only, since 10.9) ... Since we share code between iOS and mac, I'm trying to be a good system citizen and reimplement the equivalent of UIApplicationDidReceiveMemoryWarningNotification on the Mac.
NSString *const PSPDFApplicationDidReceiveMemoryWarningNotification = @"PSPDFApplicationDidReceiveMemoryWarningNotification";
// Test with sudo memory_pressure -l critical. Don't forget to re-set afterwards!
__attribute__((constructor)) static void PSPDFInstallLowMemoryNotificationWarningMac(void) {
static dispatch_source_t source;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
source = dispatch_source_create(DISPATCH_SOURCE_TYPE_MEMORYPRESSURE, 0, DISPATCH_MEMORYPRESSURE_WARN|DISPATCH_MEMORYPRESSURE_CRITICAL, dispatch_get_main_queue());
dispatch_source_set_event_handler(source, ^{
dispatch_source_memorypressure_flags_t pressureLevel = dispatch_source_get_data(source);
@clementgenzmer
clementgenzmer / FBAnimationPerformanceTracker.h
Last active November 13, 2024 05:38
FBAnimationPerformanceTracker
/*
* This is an example provided by Facebook are for non-commercial testing and
* evaluation purposes only.
*
* Facebook reserves all rights not expressly granted.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL
* FACEBOOK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
@inamiy
inamiy / SwiftElmFrameworkList.md
Last active March 11, 2024 10:20
React & Elm inspired frameworks in Swift