Skip to content

Instantly share code, notes, and snippets.

@3lvis
3lvis / .gitignore
Created June 22, 2013 11:15
Xcode .gitignore
# Xcode
.DS_Store
*/build/*
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3

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
3lvis / gist:6777799
Last active December 24, 2015 09:29
Screenshot
+ (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);
}
// Taken from the commercial iOS PDF framework http://pspdfkit.com.
// Copyright (c) 2013 Peter Steinberger. All rights reserved.
// Licensed under MIT (http://opensource.org/licenses/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.
@interface UIView (MPAdditions)
@end
@implementation UIView (MPAdditions)
- (id)debugQuickLookObject {
if (self.bounds.size.width < 0.0f || self.bounds.size.height < 0.0f) {
return nil;
}
@3lvis
3lvis / gist:9543997
Created March 14, 2014 08:25
Ruby gems hell
bundle config build.pg --with-pg-config=/Applications/Postgres.app/Contents/MacOS/bin/pg_config
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"
return
fi
IDEFileName=${2##*/}
@3lvis
3lvis / keymap.cson
Last active November 8, 2020 11:18
Xcode keymap for Atom
# Your keymap
#
'body':
'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'
'.platform-darwin':
@3lvis
3lvis / gist:a5c718bf4855343b899a
Last active August 29, 2015 14:00
Returns an array or dictionary from a .json file
+ (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