Skip to content

Instantly share code, notes, and snippets.

View vibrazy's full-sized avatar

Daniel Hollis Tavares vibrazy

View GitHub Profile
@vibrazy
vibrazy / unusedImages.sh
Created January 23, 2012 10:50
How to find unused images in an XCode project?
#!/bin/sh
# -------
# Usage sh unusedImages.sh (jpg|png|gif)
# -------
# Caveat
# 1 -
# NSString *imageName = [NSString stringWithFormat:@"image_%d.png", 1];
# This script would incorrectly list these images as unreferenced. For example, you might have
# This script will incorrectly think image_1.png is unreferenced.
# 2 - If you have a method, or variable with the same name as the image it won't pick it up
@vibrazy
vibrazy / NSPredicateWithBlock
Created February 8, 2012 09:29
NSPredicate With Block
BOOL proVersion = YES;
if (proVersion) {
return;
}
//create predicate and filter the results
NSPredicate *freePredicate = [NSPredicate predicateWithBlock:^BOOL(id evaluatedObject, NSDictionary *binding) {
InAppGame *game = (InAppGame *)evaluatedObject;
return game.isFree;
}];
@vibrazy
vibrazy / NSArrayUtils
Created February 21, 2012 16:23
NSArray Category
//
// NSArray_NSArrayUtils.h
// GCDAndBlocks
//
// Created by Daniel Hollis on 21/02/2012.
// Copyright (c) 2012 Mobile Interactive Group. All rights reserved.
//
#import <Foundation/Foundation.h>
@vibrazy
vibrazy / remove_orig_files.sh
Created May 31, 2012 14:13 — forked from seanbehan/remove_orig_files.sh
Recursively Delete .Orig Files After Failed Git Merge
# recursively delete original files after a git merge failure
find . -name *.orig -delete
@vibrazy
vibrazy / gradient.m
Created October 24, 2012 21:36
Create a CAGradientLayer from a CSS string in the "background-image(linear-gradient(top, #cb60b3 0%,#c146a1 50%,#a80077 51%,#db36a4 100%));" format
+(CAGradientLayer *)layerFromArray:(NSArray *)gradientsArray
{
//create gradient from gradient
NSMutableArray *arrayOfColors = [NSMutableArray arrayWithCapacity:10];
NSMutableArray *arrayOfPositions = [NSMutableArray arrayWithCapacity:10];
for (NSString *string in gradientsArray)
{
NSArray *arr = [string componentsSeparatedByString:@","];
@vibrazy
vibrazy / CBTimer Usage
Created September 3, 2013 22:56
CBTimer is an simple Objective C timer object for count downs. You can set a limit and start Ascending or Descending. Using blocks for Callbacks and isFinished boolean. Using CADisplayLink
// Do any additional setup after loading the view.
[[CBTimer instance] startTimerWithMaxTime:5 mode:CBTimerModeDecrease timerDoneBlock:^ (CFTimeInterval elapsed, BOOL isFinished)
{
self.counterLabel.text = [NSString stringWithFormat:@"%.3f",elapsed];
if (isFinished)
{
UIAlertView *finished =[[UIAlertView alloc] initWithTitle:@"Finished" message:@"Finito" delegate:nil cancelButtonTitle:@"OKAY" otherButtonTitles:nil];
[finished show];
}
@vibrazy
vibrazy / gist:a59af0c6e55ca4b68b34
Created July 31, 2014 19:52
Facebook Pop Animating CGPath - CoreAnimation + Pop
CGFloat height = 100.f;
UIBezierPath *straightPath = [UIBezierPath bezierPath];
[straightPath moveToPoint:CGPointMake(0, 0)];
[straightPath addCurveToPoint:CGPointMake(0, height) controlPoint1:CGPointMake(0, height * 0.5) controlPoint2:CGPointMake(0, height * 0.5)];
UIBezierPath *bendiPath = [UIBezierPath bezierPath];
[bendiPath moveToPoint:CGPointMake(0, 0)];
@vibrazy
vibrazy / gist:008903e5c493637edb84
Created August 6, 2015 16:22
Vuforia Fix for Crash - QCAR::CameraDevice::getInstance().init(camera) - [AVCaptureVideoDataOutput setVideoSettings:] - b32a (1647522401) is not a supported pixel format type
- (void)vuforiaBugFix
{
[AVCaptureVideoDataOutput aspect_hookSelector:@selector(setVideoSettings:) withOptions:AspectPositionInstead usingBlock:^(id<AspectInfo> aspectInfo, NSMutableDictionary *settings) {
// lets check if the settings have a PixelFormatType as the key
NSString *key = (id)kCVPixelBufferPixelFormatTypeKey;
if([settings objectForKey:key])
{
@vibrazy
vibrazy / UILabel+Paragraph.swift
Last active February 9, 2016 23:48
Sweet UILabel extension for Line Height and Paragraph Height
//
// UILabel+Paragraph.swift
//
// Created by Daniel Tavares on 09/02/2016.
// Copyright © 2016 Daniel Tavares. All rights reserved.
//
import Foundation
//MARK: - Associated Value Struct
@vibrazy
vibrazy / UKPostcodeValidator.swift
Created March 20, 2016 11:30
Validate UK Postcodes in Swift 2.0
//
// UKPostcodeValidator.swift
// Medio
//
// Created by Daniel Tavares on 20/03/2016.
// Copyright © 2016 Daniel Tavares. All rights reserved.
// References: http://stackoverflow.com/questions/164979/uk-postcode-regex-comprehensive
// References: http://benscheirman.com/2014/06/regex-in-swift/
// Usage: UKPostcodeValidator.validate("W1D 5LH")
//