Skip to content

Instantly share code, notes, and snippets.

@mikezs
mikezs / BoyerMoore.swift
Created November 24, 2015 13:53
Proper Boyer-Moore string searching in Swift 2.0
/**
* Implemention from here: http://www-igm.univ-mlv.fr/~lecroq/string/node14.html#SECTION00140
*/
extension String {
private func preBmBc(forString x: String) -> [Character: Int] {
let m = x.characters.count
var bmBc = [Character: Int](/*count: alphabetSize, repeatedValue: m*/)
for i in 0...m - 2 {
@mikezs
mikezs / AbusiveClass.m
Created April 16, 2015 10:42
Use of trigraphs in Objective-C to create weird syntax
@interface AbusiveClass : NSObject
@end
@implementation AbusiveClass
??=define U_FUKIN_WOT_M8 self == nil
%:define ILL_CUT_U_BRUV ??(self handleError:>;
- (BOOL)handleError??<return YES;%>
- (instancetype)init<%if (self = <:super init??))??<
U_FUKIN_WOT_M8 ??!??! ILL_CUT_U_BRUV
@mikezs
mikezs / UIImage+CustomColours.h
Created January 29, 2013 13:30
UIImage+CustomColours.h
@interface UIImage (CustomColours)
+ (UIImage *) imageWithLinearGradientOfSize:(CGSize)size start:(UIColor *)start end:(UIColor *)end;
+ (UIImage *) imageWithSolidColor:(UIColor *)color size:(CGSize)size;
@end
@mikezs
mikezs / UIDeviceHardware.h
Created December 17, 2012 13:09 — forked from Jaybles/UIDeviceHardware.h
Find the Apple model identifier and give a string representation of it
//
// UIDeviceHardware.h
//
// Used to determine EXACT version of device software is running on.
#import <Foundation/Foundation.h>
@interface UIDeviceHardware : NSObject
+ (NSString *) platform;