Skip to content

Instantly share code, notes, and snippets.

@Ciechan
Ciechan / gist:8248521
Created January 3, 2014 23:11
this *sometimes* helps fixing the cell separator
@implementation UITableViewCell (SeparatoriOS7Fix)
- (void)fixSeparator
{
UIEdgeInsets insets = self.separatorInset;
self.separatorInset = UIEdgeInsetsMake(insets.top, insets.left + 1.0, insets.bottom, insets.right);
self.separatorInset = insets;
}
@end
@Ciechan
Ciechan / CFArray.c
Created February 27, 2014 19:58
A line-linkable mirror of CFArray.c. Taken from http://opensource.apple.com/source/CF/CF-855.11/CFArray.c
/*
* Copyright (c) 2013 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this
// fragment shader
precision lowp float;
struct FSInput {
vec2 _texcoord;
sampler2D _texture;
float _opacity;
};
struct FSOutput {vec4 _color1;};
@Ciechan
Ciechan / gist:11216080
Created April 23, 2014 13:55
NSSet trivia
NSMutableString *s = [NSMutableString stringWithString:@"Hello"];
NSSet *set = [NSSet setWithObjects:s, nil];
NSLog(@"%d", [set containsObject:s]);
[s appendString:@"BLA"];
NSLog(@"%d", [set containsObject:s]);
NSLog(@"%d", [set.allObjects containsObject:s]);
@Ciechan
Ciechan / CALayer_CAMeshTransform_CALight.h
Created May 14, 2014 19:08
Cleaned up headers for CAMeshTransform, CALight, and mesh&lights properties of CALayer
#ifndef CALayer_CAMeshTransform_CALight_h
#define CALayer_CAMeshTransform_CALight_h
typedef struct CAMeshFace {
unsigned int indices[4];
float w[4];
} CAMeshFace;
@Ciechan
Ciechan / gist:09cc466788fd99c7850a
Created May 22, 2014 14:54
BCMeshTransform left curtain
/*
BCMutableMeshTransform+DemoTransforms.m
*/
+ (instancetype)curtainMeshTransformAtPoint:(CGPoint)point boundsSize:(CGSize)boundsSize
{
const float Frills = 3;
point.x = MIN(point.x, boundsSize.width);
@Ciechan
Ciechan / gist:110cd5eea24222d9a80e
Created May 25, 2014 20:59
This seems to tail call correctly with jmp instead of call
+ (NSUInteger)lengthOfListWithHead:(ListNode *)node count:(NSUInteger)count {
if (!node)
return count;
else {
__unsafe_unretained id n = node.next;
return [self lengthOfListWithHead:n count:(count + 1)];
}
}
@Ciechan
Ciechan / private
Created June 11, 2014 12:09
Hacky private fields
class Counter {
let inc : () -> Int
let dec : () -> Int
init(inc : () -> Int, dec : () -> Int) {
self.inc = inc;
self.dec = dec;
}
}
func CounterCreator(initial :Int) -> Counter {