Skip to content

Instantly share code, notes, and snippets.

@nrj
nrj / keybase.md
Created September 25, 2014 20:13

Keybase proof

I hereby claim:

  • I am nrj on github.
  • I am nrj (https://keybase.io/nrj) on keybase.
  • I have a public key whose fingerprint is 6A7F 1504 2711 128C C82E AAE9 99B2 C419 439F 62B9

To claim this, I am signing this object:

@nrj
nrj / gist:7568073
Created November 20, 2013 18:09
Force uppercase input in UITextField.
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
NSString *newString = [[textField text] stringByReplacingCharactersInRange:range withString:string];
[textField setText:[newString uppercaseString]];
return NO;
}
@nrj
nrj / gist:7534043
Last active December 28, 2015 17:09
- (NSArray *)layoutAttributesForElementsInRect:(CGRect)rect {
NSMutableArray *attributesToReturn = [NSMutableArray array];
NSInteger totalItems = [[self collectionView] numberOfItemsInSection:0];
for (NSInteger i = (totalItems - 1); i >= 0; i--) {
NSIndexPath *indexPath = [NSIndexPath indexPathForItem:i inSection:0];
CGRect itemRect = [[self layoutAttributesForItemAtIndexPath:indexPath] frame];
if (CGRectIntersectsRect(itemRect, rect)) {
(lldb) bt
* thread #5: tid = 0x2203, 0x3390c518 WebCore`WebCore::RenderArena::free(unsigned long, void*), stop reason = EXC_BAD_ACCESS (code=1, address=0x1ac)
frame #0: 0x3390c518 WebCore`WebCore::RenderArena::free(unsigned long, void*)
frame #1: 0x339f914a WebCore`WebCore::RenderWidget::deref(WebCore::RenderArena*) + 26
(lldb)
(lldb) bt
* thread #5: tid = 0x2203, 0x33a43cbc WebCore`WebCore::FrameLoader::cancelledError(WebCore::ResourceRequest const&) const + 4, stop reason = EXC_BAD_ACCESS (code=1, address=0x8)
frame #0: 0x33a43cbc WebCore`WebCore::FrameLoader::cancelledError(WebCore::ResourceRequest const&) const + 4
frame #1: 0x3396d334 WebCore`WebCore::ResourceLoader::init(WebCore::ResourceRequest const&) + 172
frame #2: 0x3396d1dc WebCore`WebCore::SubresourceLoader::startLoading() + 20
frame #3: 0x3396cfc4 WebCore`WebCore::ResourceLoadScheduler::servePendingRequests(WebCore::ResourceLoadScheduler::HostInformation*, WebCore::ResourceLoadPriority) + 52
frame #4: 0x33972980 WebCore`WebCore::ResourceLoadScheduler::servePendingRequests(WebCore::ResourceLoadPriority) + 300
frame #5: 0x338cfd22 WebCore`WebCore::ThreadTimers::sharedTimerFiredInternal() + 98
frame #6: 0x338cfc94 WebCore`_ZN7WebCoreL10timerFiredEP16__CFRunLoopTimerPv + 64
frame #7: 0x3589fa32 CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_
- (void)insertCell:(UIView *)cell atIndex:(NSInteger)index animated:(BOOL)animated {
CGFloat duration = animated ? kHorizontalTableViewAnimationDuration : 0;
CGRect contentRect = [contentView frame];
CGFloat colWidth = [dataSource horizontalTableView:self widthForCellAtIndex:index];
CGFloat colHeight = [dataSource respondsToSelector:@selector(horizontalTableViewCellHeight:)] ?
[dataSource horizontalTableViewCellHeight:self] : contentRect.size.height;
//
// NECacheObject.h
//
// Created by nrj on 4/28/11.
//
#import <Foundation/Foundation.h>
@interface NECacheObject : NSObject <NSCoding> {
//
// NECacheObject.m
//
// Created by nrj on 4/28/11.
//
#import "NECacheObject.h"
@implementation NECacheObject
NSArray *neighbors = [currentNode getWalkableNeighbors:[currentMap tiles]];
int newG = [AStarUtil distanceTraveled:currentNode] + 1;
for (id <AStarNode>neighbor in neighbors) {
if (neighbor == [ghost currentTile]) continue;
if ([closedList containsObject:neighbor] && newG < [neighbor g]) {
//
// BitmapImage.h
// GhostGuy
//
// Copyright 2010 Nick Jensen <http://goto11.net>
//
#import <Foundation/Foundation.h>
typedef unsigned char byte;