Skip to content

Instantly share code, notes, and snippets.

View OliverLetterer's full-sized avatar
👨‍💻
Happy coding :)

Oliver Letterer OliverLetterer

👨‍💻
Happy coding :)
View GitHub Profile
@danielctull
danielctull / dct_weak.h
Created December 29, 2011 02:21 — forked from rowanj/dct_weak.h
ARC macros for weak references
#ifndef _DCT_WEAK_H
#define _DCT_WEAK_H
// Macros for portable support of notionally weak properties with ARC
// Forked from https://gist.github.com/1354106
// Updated by Rowan James
// Available at https://gist.github.com/1530868
// Defines:
// dct_weak to be used as a replacement for the 'weak' keyword:
// @property (dct_weak) NSObject* propertyName;
@jocubeit
jocubeit / gist:1713910
Created January 31, 2012 23:45
Install Nokogiri on Mac OSX Lion including libiconv using Homebrew
# Install libxml2 using Homebrew
# If you don't have Homebrew, follow the instructions at:
# https://github.com/mxcl/homebrew/wiki/Installation
# -------------------------------------------------------
brew install libxml2
# Install libxslt from source code
# If you don't have wget, follow the instructions at:
# http://www.mactricksandtips.com/2008/07/installing-wget-on-your-mac-for-terminal.html
# Or use Homebrew:
@OliverLetterer
OliverLetterer / CCamera.m
Created November 28, 2012 08:10
Really simple Objective-C AVFoundation Camera class
//
// CCamera.h
// CCamera
//
// Created by Jonathan Wight on 7/12/12.
// Copyright (c) 2012 Jonathan Wight. All rights reserved.
//
#import <Foundation/Foundation.h>
desc "Create a new version tag and push a new podspec"
task :release do
require 'cocoapods'
require 'colored'
version = Pod::Specification.from_file(Pathname.pwd + 'MyLib.podspec').version
puts "Releasing version `#{version}'. Is that correct? (y/n)"
if $stdin.gets.strip.downcase == 'y'
sh "git tag -a #{version} -m 'Release #{version}'"
sh "git push --tags"
sh "pod lint"
// Defines a yet undocumented method to add a warning if super isn't called.
#ifndef NS_REQUIRES_SUPER
#if __has_attribute(objc_requires_super)
#define NS_REQUIRES_SUPER __attribute((objc_requires_super))
#else
#define NS_REQUIRES_SUPER
#endif
#endif
__block void(^block)(int) = ^(int i) {
printf("%d", i);
if (i > 0) {
block(i-1);
} else {
block = nil;
}
};
block(9);
@steveriggins
steveriggins / gist:6652508
Last active December 23, 2015 14:59
iOS 7 has a bug (or made a design decision which goes against the documentation) to set the cookie policy of NSURLConnections to whatever the user has set their cookie preferences to via Settings -> Safari. This simple method resets the cookie policy to accept always. Apple documentation for cookieAcceptPolicy: https://developer.apple.com/librar…
- (void)takeControlOfTheCookies
{
[[NSHTTPCookieStorage sharedHTTPCookieStorage] setCookieAcceptPolicy:NSHTTPCookieAcceptPolicyAlways];
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[self takeControlOfTheCookies];
@mayoff
mayoff / FormatOptions.swift
Last active February 10, 2017 05:16
Avoiding duplication of property names
// For https://twitter.com/nicklockwood/status/819938181483233285
protocol Withable {
init()
}
extension Withable {
func with(_ body: (inout Self) -> ()) -> Self {
var copy = self
body(&copy)
@steipete
steipete / NSData+PSPDFFoundation.m
Last active March 21, 2017 16:00
Haven't done much with dispatch_io yet so I'd appreciate a few more eyeballs on this. Am I closing things correctly in all error conditions? Are there other knobs I could change to make things even faster? (I know I've been lazy on the NSError's)
static NSData *PSPDFCalculateSHA256FromFileURL(NSURL *fileURL, CC_LONG dataLength, NSError **error) {
NSCParameterAssert(fileURL);
dispatch_queue_t shaQueue = dispatch_queue_create("com.pspdfkit.sha256-queue", DISPATCH_QUEUE_SERIAL);
__block dispatch_io_t readChannel;
void (^processIntError)(int intError) = ^(int intError) {
if (intError != 0) {
PSPDFLogWarning(@"Stream error: %d", intError);
if (error) *error = [NSError errorWithDomain:@"SHA256Error" code:100 userInfo:@{NSLocalizedDescriptionKey: @"failed to open file for calculating SHA256."}];
#import "Aspects.h"
#import "fishhook.h"
#import <dlfcn.h>
// UIAnimationDragCoefficient
// UISimulatedApplicationResizeGestureEnabled
// UIExternalTouchSloppinessFactor
// UIEnableParallaxEffects
// UIDeviceUsesLowQualityGraphics