Skip to content

Instantly share code, notes, and snippets.

3lvis / .gitignore
Created June 22, 2013 11:15
Xcode .gitignore
View .gitignore
# Xcode
View nsincrementalstore.markdown

Accessing an API using CoreData's NSIncrementalStore

Note: the original location of this article is on my blog, however, it is posted here too for better readability.

In this article, we will see how to use Core Data for accessing your API. We will use the Bandcamp API as our running example. I've only been experimenting with this code for a few days, so there might be mistakes in there.

// SKShapeNode+Utility.m
// Dynamics
// Created by Jonathan Wight on 6/14/13.
// Copyright (c) 2013 toxicsoftware. All rights reserved.
#import "SKShapeNode+Utility.h"
3lvis / gist:6777799
Last active December 24, 2015 09:29
View gist:6777799
+ (UIImage *)screenshot
CGSize imageSize = CGSizeZero;
UIInterfaceOrientation orientation = [UIApplication sharedApplication].statusBarOrientation;
if (UIInterfaceOrientationIsPortrait(orientation)) {
imageSize = [UIScreen mainScreen].bounds.size;
} else {
imageSize = CGSizeMake([UIScreen mainScreen].bounds.size.height, [UIScreen mainScreen].bounds.size.width);
View PSPDFUIKitMainThreadGuard.m
// Taken from the commercial iOS PDF framework
// Copyright (c) 2013 Peter Steinberger. All rights reserved.
// Licensed under MIT (
// You should only use this in debug builds. It doesn't use private API, but I wouldn't ship it.
#import <objc/runtime.h>
#import <objc/message.h>
// Compile-time selector checks.
View gist:9524479
@interface UIView (MPAdditions)
@implementation UIView (MPAdditions)
- (id)debugQuickLookObject {
if (self.bounds.size.width < 0.0f || self.bounds.size.height < 0.0f) {
return nil;
3lvis / gist:9543997
Created March 14, 2014 08:25
Ruby gems hell
View gist:9543997
bundle config --with-pg-config=/Applications/
export PGHOST=localhost
ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future bundle install
#!/usr/bin/env bash
function openWorkspaceOrProjectWithApp()
if [[ -z "$1" || "$#" -ne 2 ]]; then
echo -e "Nothing found\n"
3lvis / keymap.cson
Last active November 8, 2020 11:18
Xcode keymap for Atom
View keymap.cson
# Your keymap
'ctrl-tab': 'pane:show-next-item'
'alt-cmd-up': 'pane:split-up'
'alt-cmd-down': 'pane:split-down'
'shift-cmd-L': 'application:open-dev'
'shift-cmd-0': 'window:reset-font-size'
3lvis / gist:a5c718bf4855343b899a
Last active August 29, 2015 14:00
Returns an array or dictionary from a .json file
View gist:a5c718bf4855343b899a
+ (id)JSONObjectWithContentsOfFile:(NSString*)fileName
NSString *filePath = [[NSBundle mainBundle] pathForResource:[fileName stringByDeletingPathExtension]
ofType:[fileName pathExtension]];
NSData *data = [NSData dataWithContentsOfFile:filePath];
NSError *error = nil;
id result = [NSJSONSerialization JSONObjectWithData:data