Skip to content

Instantly share code, notes, and snippets.

View nuthatch's full-sized avatar

Stephen Ryner Jr. nuthatch

View GitHub Profile
@mattdonnelly
mattdonnelly / UIImage+vImageScaling.h
Last active November 8, 2019 17:20
An Objective-C UIImage category for better resizing using vImage
//
// UIImage+vImageScaling.h
// UIImage+vImageScaling
//
// Created by Matt Donnelly on 03/07/2013.
// Copyright (c) 2013 Matt Donnelly. All rights reserved.
//
#import <UIKit/UIKit.h>
@steipete
steipete / PSPDFViewController.h
Last active June 6, 2017 03:56
This method will help to prevent a lot of emails about "weird bugs".
// Defines a yet undocumented method to add a warning if super isn't called.
#ifndef NS_REQUIRES_SUPER
#if __has_attribute(objc_requires_super)
#define NS_REQUIRES_SUPER __attribute((objc_requires_super))
#else
#define NS_REQUIRES_SUPER
#endif
#endif
@interface UIViewController (SubclassingWarnings)
@ccstone
ccstone / BBEdit-TextWrangler_RegEx_Cheat_Sheet.txt
Last active May 10, 2024 15:41
BBEdit-TextWrangler Regular Expression Cheat-Sheet
————————————————————————————————————————————————————————————————————————————————————————————————————
BBEdit / BBEdit-Lite / TextWrangler Regular Expression Guide Modified: 2018/08/10 01:19
————————————————————————————————————————————————————————————————————————————————————————————————————
NOTES:
The PCRE engine (Perl Compatible Regular Expressions) is what BBEdit and TextWrangler use.
Items I'm unsure of are marked '# PCRE?'. The list while fairly comprehensive is not complete.
@darkliquid
darkliquid / beautified.js
Last active August 22, 2019 02:28
Bookmarklet to estimate reading time of a page
javascript:(function () {
function getTextNodesIn(element) {
var wordcount = 0,
whitespace = /^\s*$/;
function getTextNode(node) {
// type 3 is a textnode
if (node.nodeType == 3) {
// We skip text nodes that are only whitespace
if (!whitespace.test(node.nodeValue)) {
@Reefaq
Reefaq / Common.h
Created March 4, 2013 07:21
Useful Macro for almost every project - Gather from many sources and also included of own.
//
// Common.h
// Userful Macro
//
// Created by Reefaq on 06/12/12.
// Copyright (c) 2012 Reefaq. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
@interface NSManagedObject (Serialization)
- (NSDictionary*) toDictionary;
- (void) populateFromDictionary:(NSDictionary*)dict;
+ (NSManagedObject*) createManagedObjectFromDictionary:(NSDictionary*)dict
inContext:(NSManagedObjectContext*)context;
@end
@drance
drance / gist:4546014
Created January 16, 2013 09:57
Workaround to vanilla UICollectionView+UICollectionViewFlowLayout using non-integral origins, leading to blurry cells.
@implementation BHSCollectionViewFlowLayout
- (NSArray *)layoutAttributesForElementsInRect:(CGRect)rect {
NSArray *allAttrs = [super layoutAttributesForElementsInRect:rect];
for (UICollectionViewLayoutAttributes *attributes in allAttrs) {
attributes.frame = CGRectIntegral(attributes.frame);
}
return allAttrs;
}
@dhoerl
dhoerl / AppDelegate(category).m
Created July 26, 2012 23:19
Keychain Wrapper for dictionary (NSData) not a single NSString
static NSString *kcIdentifier = @"MyApp";
@implementation LTAppDelegate (KeyChain)
- (void)keychainInit
{
self.keychainDict = [NSMutableDictionary dictionaryWithCapacity:7];
KeychainItemWrapper *item = [[KeychainItemWrapper alloc] initWithIdentifier:kcIdentifier accessGroup:nil];
[self.keychainDict setObject:@"" forKey:kcEmailAddress];
@cbarrett
cbarrett / gist:1642401
Created January 19, 2012 20:31
Had this laying around for quite a while -- really useful and kind of dumb it's not built in...
// stringByAddingPercentEscapesUsingEncoding is pretty conservative about escaping characters, which is fine most of the time. This method however escapes *all special characters*, allowing any arbitrary string to be used when building any part of a URL.
// (c) 2011 Springs & Struts. Released under MIT-style license. See: http://www.opensource.org/licenses/mit-license.php
@interface NSString (SSURLEscaping)
- (NSString *)ss_stringByEscapingAllURLCharactersForRealWithEncoding:(NSStringEncoding)encoding;
@end
@implementation NSString (SSURLEscaping)
- (NSString *)ss_stringByEscapingAllURLCharactersForRealWithEncoding:(NSStringEncoding)encoding
@justin
justin / gist:1586083
Created January 10, 2012 00:56
UIAccessibilityTraits Example
- (UIAccessibilityTraits)accessibilityTraits
{
UIAccessibilityTraits traits = UIAccessibilityTraitButton | UIAccessibilityTraitAllowsDirectInteraction | UIAccessibilityTraitStaticText;
if (self.disabled == YES)
{
traits = traits | UIAccessibilityTraitNotEnabled;
}
return traits;