This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Declare this property in your header / private header | |
@property (nonatomic, strong) NSMutableArray *updatingConstraints; | |
- (void)updateConstraints { | |
if (self.updatingConstraints) { | |
[self removeConstraints:self.updatingConstraints]; | |
} | |
self.updatingConstraints = [NSMutableArray array]; | |
// Create and add all of your constraints here |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <Foundation/Foundation.h> | |
@interface NSObject (Swizzling) | |
- (void)swizzleMethod:(SEL)originalSelector toMethod:(SEL)newSelector; | |
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)animateConstraints { | |
[self setNeedsUpdateConstraints]; | |
[UIView animateWithDuration:0.4 animations:^{ | |
[self layoutIfNeeded]; | |
}]; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
long long ago; /* in a galaxy far far away */ | |
// Replaces with spaces the braces in cases where braces in places cause stasis | |
$str = str_replace(array("\{","\}")," ",$str); | |
#define TRUE FALSE //Happy debugging suckers | |
// sometimes I believe compiler ignores all my comments | |
// I am not sure if we need this, but too scared to delete. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)tapCellWithName:(NSString *)name inTableViewWithAccessibilityLabel:(NSString *)accessibilityLabel { | |
[tester runBlock:^KIFTestStepResult(NSError *__autoreleasing *error) { | |
UITableView *tableView = (UITableView *)[tester waitForViewWithAccessibilityLabel:accessibilityLabel]; | |
NSIndexPath *foundIndexPath = nil; | |
for (int section = 0; section < tableView.numberOfSections; section++) { | |
for (int row = 0; row < [tableView numberOfRowsInSection:section]; row++) { | |
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:row inSection:section]; | |
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath]; | |
if ([cell.textLabel.text isEqualToString:name]) { | |
foundIndexPath = indexPath; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CGPoint centroidOfPoints(const CGPoint* points, int pointCount) { | |
CGPoint centroid = CGPointMake(0, 0); | |
double x0, y0, x1, y1, partialArea; | |
double signedArea = 0.0; | |
for (int index = 0; index < pointCount; index++) { | |
int nextIndex = (index == pointCount-1) ? 0 : index+1; | |
x0 = points[index].x; | |
y0 = points[index].y; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule JSONMapBuilder do | |
def to_map(list) when is_list(list) and length(list) > 0 do | |
case list |> List.first do | |
{_, _} -> | |
Enum.reduce(list, %{}, fn(tuple, acc) -> | |
{key, value} = tuple | |
Map.put(acc, binary_to_atom(key), to_map(value)) | |
end) | |
_ -> | |
list |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Controller.Main do | |
use Weber.Controller | |
render_when_raise :unauthorized, {:text, 401, "Unauthorized.", []} | |
layout false | |
def action(_, conn) do | |
{:render, [project: "simpleTodo"], []} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
extension Int { | |
func timesMap(closure: (Int) -> AnyObject) -> Array<AnyObject> { | |
var array: AnyObject[] = [] | |
for x in 1...self { | |
array += closure(x) | |
} | |
return array; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule MacroExp do | |
defmacro attr_accessor(atom) do | |
getter = String.to_atom("get_#{atom}") | |
setter = String.to_atom("set_#{atom}") | |
quote do | |
def unquote(getter)(data) do | |
data |> Map.from_struct |> Map.get(unquote(atom)) | |
end | |
def unquote(setter)(data, value) do | |
data |> Map.put(unquote(atom), value) |