Skip to content

Instantly share code, notes, and snippets.

View a2's full-sized avatar
🐼

Alex Akers a2

🐼
View GitHub Profile
@a2
a2 / .git_detach
Created September 5, 2011 23:08
Clones a subfolder into a new git repository.
git clone --no-hardlinks OLD_FLDR NEW_FLDR
cd NEW_FLDR
git filter-branch --prune-empty --subdirectory-filter ‘FLDR_TO_KEEP’ master
git remote rm origin
git update-ref -d refs/original/refs/heads/master
git reflog expire --expire=now --all
git repack -ad
git reset --hard
git gc --aggressive --prune=now
@a2
a2 / .git_delete
Created September 5, 2011 23:10
Deletes file/folder from all revisions (as if it never existed).
git filter-branch --index-filter 'git rm --cached --ignore-unmatch FILE' HEAD
git filter-branch --index-filter 'git rm -rf --cached --ignore-unmatch FLDR' HEAD
@a2
a2 / gist:1196145
Last active April 15, 2017 20:54
Look ( Ahead | Behind )
Name Pattern Description Example
Positive Lookahead q(?=u) q followed by u q in absquatulate
Negative Lookahead q(?!u) q not followed by u q in qwerty
Positive Lookbehind (?<=q)u u preceded by q u in question
Negative Lookbehind `(?
@a2
a2 / gist:1196496
Created September 6, 2011 03:15
ARC Singleton Boilerplates
#define SYNTHESIZE_SINGLETON_FOR_CLASS_WITH_CUSTOM_METHOD(className, methodName) \
\
+ (className *) methodName \
{ \
static className *shared ## className; \
static dispatch_once_t token; \
dispatch_once(&token, ^{ \
shared ## className = [[className alloc] init]; \
}); \
\
@a2
a2 / A2Casting.h
Created October 15, 2011 00:11
A2Common
//
// A2Casting.h
//
// Created by Alexsander Akers on 10/6/11.
// Copyright (c) 2011 Pandamonia LLC. All rights reserved.
//
// These are some basic macros for making down-casting safer in Objective C.
// They are loosely based on the same cast types with similar names in C++.
// A typical usage would look like this:
@a2
a2 / git-pull-r-uncompressed.sh
Created October 24, 2011 19:16
Git pull in all subdirectories if directory is repo
for f in *;
do
echo "$f";
if [ -d "$f" ];
then
cd "$f";
if [ -d ".git" ];
then
git pull --all;
else
@a2
a2 / gist:1335594
Created November 3, 2011 02:11
Private (i.e., non-public) `UIActivityIndicatorView` style constants
// NB: Using undefined constants can not only make the indicator appear blank,
// but it can also run a slew of nasty NSLog statements about missing image files.
// That being said, the following constants are guaranteed to work on the
// latest builds of iOS 4 and iOS 5 as indicated by the pragma directive.
enum {
UIActivityIndicatorViewStyleWhiteSmall = 3, // small network activity indicator glyph
UIActivityIndicatorViewStyleGraySmall = 4 // same as '3' but white color on black status bar
#ifdef __IPHONE_5_0
,
@a2
a2 / gist:1375724
Created November 18, 2011 05:53
Swizzle
// Don't forget to #import <objc/runtime.h>
void A2Swizzle(Class cls, SEL oldSel, SEL newSel, BOOL isClassMethod)
{
if (isClassMethod) cls = object_getClass(cls);
Method origMethod = class_getInstanceMethod(cls, oldSel);
Method newMethod = class_getInstanceMethod(cls, newSel);
if (class_addMethod(cls, oldSel, method_getImplementation(newMethod), method_getTypeEncoding(newMethod)))
class_replaceMethod(cls, newSel, method_getImplementation(origMethod), method_getTypeEncoding(origMethod));
Pod::Spec.new do |s|
s.name = "ChimpKit2"
s.version = "0.1.1"
s.homepage = "https://github.com/mailchimp/ChimpKit2"
s.summary = "MailChimp API Wrapper with support for API 1.3."
s.license = 'MIT'
s.author = { "Amro Mousa" => "amromousa@gmail.com" }
s.source = { :git => "https://github.com/mailchimp/ChimpKit2.git", :branch => "master" }
s.platform = :ios, '5.0'
s.source_files = 'Core/Classes/*.{h,m}'
@a2
a2 / StoreKit.h
Created November 24, 2013 14:14
SKHandleInvalidReceiptRequest & SKTerminateForInvalidReceipt
@import StoreKit;
@interface SKHandleInvalidReceiptRequest : SKRequest
- (void)_sendXPCMessage;
@end
extern void SKTerminateForInvalidReceipt(void);