Skip to content

Instantly share code, notes, and snippets.

[color]
ui = true
branch = auto
diff = auto
status = auto
interactive = auto
[color "branch"]
current = yellow bold
local = green bold
remote = red bold
@ajjames
ajjames / string.rb
Created September 10, 2012 17:52
Simple extension of ruby string class to add coloring.
CLEAR = "\033[0m"
BOLD = "\033[1m"
BLACK = "\033[30m"
GREEN = "\033[32m"
RED = "\033[31m"
YELLOW = "\033[33m"
BLUE = "\033[34m"
MAGENTA = "\033[35m"
CYAN = "\033[36m"
WHITE = "\033[37m"
@ajjames
ajjames / RetryManager.cs
Created November 28, 2012 01:39
Simple retry class
using System;
using System.Threading;
using NUnit.Framework;
namespace Tests
{
class RetryManager
{
public void AttemptToRetryUntilTrue(Func<bool> condition, int timeoutMilliseconds = 5000, int delayMiliseconds = 100)
{
//
// UIView+Parallax.h
//
#import <Foundation/Foundation.h>
@interface UIView (Parallax)
-(void)addBackgroundParallax:(CGFloat)strength;
-(void)addForegroundParallax:(CGFloat)strength;
-(void)removeParallax;
/*
File: UIImage+ImageEffects.h
Abstract: This is a category of UIImage that adds methods to apply blur and tint effects to an image. This is the code you’ll want to look out to find out how to use vImage to efficiently calculate a blur.
Version: 1.0
Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple
Inc. ("Apple") in consideration of your agreement to the following
terms, and your use, installation, modification or redistribution of
this Apple software constitutes acceptance of these terms. If you do
not agree with these terms, please do not use, install, modify or
@ajjames
ajjames / Macros.h
Last active August 29, 2015 13:56
DLog: Obj-C Logging Macros
#ifdef DEBUG
#define DLog(fmt, ...) NSLog((@"%s [Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__);
#else
#define DLog(...)
#define NSLog(...)
#endif
#define IS_PAD (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad ? YES : NO)
#define IS_PHONE !IS_PAD
@ajjames
ajjames / DictionaryExtension.swift
Last active August 29, 2015 14:11
DictionaryExtension to get implicit type
internal extension Dictionary
{
internal func get<V>(key:Key) -> V? {
return self.indexForKey(key) as? V
}
}
//.h
@interface TabBarHidingCollectionViewController : UICollectionViewController
@end
//.m
@interface TabBarHidingCollectionViewController ()
@property (nonatomic) CGFloat lastOffsetY;
@end
@implementation TabBarHidingCollectionViewController
@ajjames
ajjames / UpgradeHelper.m
Last active August 29, 2015 14:13
UpgradeHelper
//Objective-c
//HEADER
#import <Foundation/Foundation.h>
@interface UpgradeHelper : NSObject
+(BOOL)isUpgradeAvailable:(NSString*)localVersion releasedVersion:(NSString*)releasedVersion;
@end
//IMPLEMENTATION
#import "UpgradeHelper.h"
@ajjames
ajjames / find4Largest.swift
Created January 19, 2015 03:21
Find 4 Largest
import UIKit
func find4Largest(numbers:[Int]) -> [Int]
{
let count = 4
assert(count < numbers.count, "Error: numbers must have at least \(count) elements")
if numbers.count < 2
{
return numbers
}