Skip to content

Instantly share code, notes, and snippets.

View hcrub's full-sized avatar

Neil Burchfield hcrub

View GitHub Profile
@hcrub
hcrub / ghub_issues.rb
Created November 6, 2013 19:56
Imports and Sorts Github issues into CSV File
###################################################
# Neil Burchfield
# Nov 6, 2013
# Imports and Sorts Github issues into CSV File
###################################################
require 'octokit'
require 'csv'
require 'date'
@hcrub
hcrub / appledoc_aggregate.sh
Created November 6, 2013 20:02
Aggregate Target for Xcode 5+ for creating clean AppleDoc documentation.
/usr/local/bin/appledoc \
--project-name "${PROJECT_NAME}" \
--project-company "HCRUB" \
--company-id "com.hcrub" \
--output "${PROJECT_DIR}/Documentation" \
--install-docset \
--logformat xcode \
--keep-undocumented-objects \
--keep-undocumented-members \
--keep-intermediate-files \
@hcrub
hcrub / HCSwizzle.m
Created November 7, 2013 16:57
Example of Objective-C's Runtime method_exchangeImplementations for method swizzling
+ (void)load
{
Method original, swizzled;
original = class_getInstanceMethod(self, @selector(original_method));
swizzled = class_getInstanceMethod(self, @selector(swizzled_method));
method_exchangeImplementations(original, swizzled);
}
@hcrub
hcrub / HCClassRuntime.m
Created November 7, 2013 17:06
Creating a NSClass during Objective C's Runtime
// Creating a class at runtime can be accomplished using the objc_allocateClassPair function in objc/runtime.h.
/**
* objc_allocateClassPair
*
* (Class superclass, const char *name, size_t extraBytes)
**/
Class runtimeClass = objc_allocateClassPair([NSObject class], "ThisRuntimeClass", 0);
@hcrub
hcrub / HCGetClassList.m
Created November 7, 2013 17:11
Objective C Runtime's objc_getClassList to obtain a list of registered class definitions
/**
* objc_getClassList
* Obtains the list of registered class definitions.
*
* int objc_getClassList(Class *buffer, int bufferLen)
*
* Parameters:
*
* buffer
* An array of Class values. On output, each Class value points to one class definition, up to either bufferLen or the total number of registered classes, whichever is less. You can pass NULL to obtain the total number of registered class definitions without actually retrieving any class definitions.
@hcrub
hcrub / ClassRespondsToSelector.m
Last active April 9, 2020 14:39
Objective C Runtime's class_respondsToSelector to detect if whether instances of a class respond to a particular selector.
/**
* class_respondsToSelector
* Returns a Boolean value that indicates whether instances of a class respond to a particular selector.
* Overall, class_respondsToSelector looks up the selector in the class's method table to see if it has an entry
*
* BOOL class_respondsToSelector(Class cls, SEL sel)
*
* Parameters
* cls
* The class you want to inspect.
@hcrub
hcrub / HCClassAddIvar.m
Created November 7, 2013 17:42
Objective C Runtime's class_addIvar adding a new instance variable to a class
/**
* class_addIvar
* Adds a new instance variable to a class.
*
* BOOL class_addIvar(Class cls, const char *name, size_t size, uint8_t alignment, const char *types)
*
* Return Value
* YES if the instance variable was added successfully, otherwise NO.
**/
@hcrub
hcrub / LocalizeStrings.sh
Last active December 28, 2015 13:39
Shell Script (Xcode 5 tested) for localizing Localizable.strings into other languages.
#!/bin/bash
# ##########################################################
# Author: Neil Burchfield
# Purpose: Localization Script
# Date: Nov 16, 2013
# ##########################################################
# ##########################################################
# Vars
@hcrub
hcrub / PackTextures.sh
Created November 17, 2013 05:35
Pack Sprite Sheet Textures
#!/bin/bash
# ##########################################################
# Author: Neil Burchfield
# Purpose: Pack Textures Script
# Date: Nov 16, 2013
# ##########################################################
TP="/usr/local/bin/TexturePacker"
@hcrub
hcrub / gist:7673617
Created November 27, 2013 10:30
Useful formatted git log output in bash
git log --graph --pretty=format:'%Cred%h%Creset -%C(white)%d%Creset %s'
// Output Example:
* fe14be7 - (HEAD, origin/development_v1.4.0, development_v1.4.0) Updated/Cleaned/Formatted Filter Controller
* dd5ac6e - Updated/Cleaned/Formatted Camera Controller
* 5fe469f - refs #3, CC Crash on Appending nil NSString
* 73b7655 - refs #5, Updated Sign-out route -> /venues/VENUE_ID/checkins/SESSION_ID
etc...