Skip to content

Instantly share code, notes, and snippets.

View eoghain's full-sized avatar

Rob Booth eoghain

View GitHub Profile
@eoghain
eoghain / tvdb_favorites_clenup.py
Last active August 29, 2015 14:04
TVDB Favorites Cleanup - Remove favorites that are of canceled shows.
#!/usr/bin/env python
import requests # Requires install
import json
import random
import io
import itertools as IT
from xml.etree import ElementTree
from xml.etree.ElementTree import Element
from xml.etree.ElementTree import SubElement
@eoghain
eoghain / fontelloNSStringCategoryGenerator.py
Last active April 16, 2019 22:38
Fontello to NSString category
#!/usr/bin/env python
import sys
import json
import os
import argparse
from textwrap import dedent
def pascalCase(str):
@eoghain
eoghain / UICollectionViewFlowLayout+NoFade.m
Created March 5, 2014 00:16
When adding/removing/reloading cells in a UICollectionView using the FlowLayout the cells fade in/out. When doing things like updating a progress bar you get a lot of annoying flashing because of this, this category will prevent that. As an added benefit rotation animations will now show the cells moving into position.
//
// UICollectionViewFlowLayout+NoFade.m
//
// Created by Rob Booth on 3/4/14.
#import "UICollectionViewFlowLayout+NoFade.h"
#import <objc/runtime.h>
@implementation UICollectionViewFlowLayout (NoFade)
@eoghain
eoghain / CoreData SQLite date queries
Created February 19, 2014 01:26
Info regarding CoreData build SQLite tables for dates
In trying to debug and NSPredicate I typically find myself delving into the sqlite commandline interface to run the queries manually to see what happens. I just now ran into doing some queries dealing with timestamps which led to alot of frustration, so I hope this helps someone.
1. NSDate uses 01/01/2001 00:00:00 GMT as it's reference date, this is very important to know. This date converts to 978307200 as a unix timestamp, which is a number you will be using later.
2. CoreData, stores dates as timestamps from the above reference date.
3. SQLite has a couple of date functions that work off of the unix epoch, which is 1/1/1970 00:00:00 GMT. Using these functions you can effectively query your CoreData store.
4. The strftime('%s', 'now') function will return to you the current time as a timetamp from the unix epoch, unfortunately this is returned as a string so you'll need to cast it to use in comparison query.
@eoghain
eoghain / NSMutableURLRequest+MultipartBatch.h
Created January 22, 2014 22:41
NSMutableURLRequest category for sending multipart/mixed (i.e.batch) request to servers that can handle them (i.e. Google Cloud Storage, .NET Web API, UCWA, OData). To use, just create your request to the batch endpoint and add your batched requests to it using the addPart: method.
//
// NSMutableURLRequest+MultipartBatch.h
//
// Created by Rob Booth on 1/17/14.
//
#import <Foundation/Foundation.h>
@interface NSMutableURLRequest (MultipartBatch)
@eoghain
eoghain / acknowledgements.py
Last active August 25, 2018 02:16
Python script to generate plists into a Settings.bundle for all licenses of open source software you are using in your application.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Setup
#
# 1. Create a directory to hold your 3rd party code, each module in it's own named directory (i.e. 3rdParty/AFNetworking).
# 2. Make sure under the module directory there is the LICENSE file (file must have LICENSE all uppercase in the name)
# 3. In your Settings.bundle add a row to the Root.plist with: Type=PSChildPaneSpecifier, Filename=Acknowledgements, Name=Acknowledgements.
# 4. In the script below,
# - set the settingsDir to the directory where the Settings.bundle resides (if not source root),
@eoghain
eoghain / FaderView.m
Last active October 12, 2015 13:38
FaderView - A UIView to add an edge fade
//
// FaderView.h
//
// Created by Rob Booth on 11/6/12.
//
//
// Usage
// [[FaderView alloc] initWithFrame:CGRectZero color:[UIColor redColor] andDirection:FaderViewDirectionDown];
#import <UIKit/UIKit.h>
@eoghain
eoghain / MYJSONSerilization
Created July 17, 2012 23:19
NSJSONSerilization compatibility using SBJSON (json-framework) for < iOS5 compatibility kinda
#import "SBJson.h"
#import <Foundation/Foundation.h>
#import <objc/runtime.h>
@interface MYJSONSerialization : NSObject
+ (NSData *)dataWithJSONObject:(id)obj options:(NSJSONWritingOptions)opt error:(NSError **)error;
+ (id)JSONObjectWithData:(NSData *)data options:(NSJSONReadingOptions)opt error:(NSError **)error;
@end
@eoghain
eoghain / UITableView+FetchedResultsControllerDelegate.m
Created July 5, 2012 18:35
UITableView+FetchedResultsControllerDelegate
#import <UIKit/UIKit.h>
#import <CoreData/CoreData.h>
@interface UITableView (FetchedResultsControllerDelegate) <NSFetchedResultsControllerDelegate>
@end
@implementation UITableView (FetchedResultsControllerDelegate)
- (void)controllerWillChangeContent:(NSFetchedResultsController *)controller