Skip to content

Instantly share code, notes, and snippets.

View dzenbot's full-sized avatar

Ignacio Romero Zurbuchen dzenbot

  • DZN Technologies
  • Canada
View GitHub Profile
@codelynx
codelynx / ZCache.swift
Last active February 3, 2018 06:22
Make NSCache more generics with Swift.
import Foundation
class ZCache<T: AnyObject> {
private var cache = NSCache()
var delegate: NSCacheDelegate? {
get { return self.delegate }
set { self.cache.delegate = newValue }
@cgoldsby
cgoldsby / XCTestCase+Expectation.swift
Last active June 4, 2021 13:58
XCTestCase extension with boilerplate code for unit testing async functions (waiting for expectations)
//
// AsyncTests.swift
//
import XCTest
// MARK: Async Helper Extension
extension XCTestCase {
internal let DEFAULT_MIME_TYPE = "application/octet-stream"
internal let mimeTypes = [
"html": "text/html",
"htm": "text/html",
"shtml": "text/html",
"css": "text/css",
"xml": "text/xml",
"gif": "image/gif",
"jpeg": "image/jpeg",
@clementgenzmer
clementgenzmer / FBAnimationPerformanceTracker.h
Last active September 18, 2023 23:02
FBAnimationPerformanceTracker
/*
* This is an example provided by Facebook are for non-commercial testing and
* evaluation purposes only.
*
* Facebook reserves all rights not expressly granted.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL
* FACEBOOK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
@bradya
bradya / gist:0f17bb779efd92c3f7b5
Created January 28, 2015 02:38
Core Data queue abstraction
#pragma mark - Block Methods
/*
When we team switch, we want to completely stop in-progress data changes
E.g. if we're dumping the cache on Team A and you switch teams, we use
[SLKTeam currentTeam] throughout the app, and when that code executes, it'll
do stuff for the wrong team.
Core Data doesn't provide direct access to the MOC queues, so we implement
our own queues on top of the MOC queues which gives us the ability to
@jaredsinclair
jaredsinclair / set-build-number.sh
Last active January 1, 2020 15:41
Git-friendly run script for automated build numbering in Xcode
# Set the build number to the current git commit count.
#
# Permanent home:
# https://gist.github.com/jaredsinclair/af6898f93674ee5923f3
#
# Based on: http://w3facility.info/question/how-do-i-force-xcode-to-rebuild-the-info-plist-file-in-my-project-every-time-i-build-the-project/
# Updated with dSYM handling from http://yellowfeather.co.uk/blog/auto-incrementing-build-number-in-xcode-revisited/
git=`sh /etc/profile; which git`
appBuild=`"$git" rev-list HEAD --count`
@yannickl
yannickl / YLColor.swift
Last active September 16, 2023 03:55
Hex string <=> UIColor conversion in Swift
import Foundation
import UIKit
extension UIColor {
convenience init(hexString:String) {
let hexString:NSString = hexString.stringByTrimmingCharactersInSet(NSCharacterSet.whitespaceAndNewlineCharacterSet())
let scanner = NSScanner(string: hexString)
if (hexString.hasPrefix("#")) {
scanner.scanLocation = 1
extension CGPoint {
mutating func move(x:Int? = nil, y:Int? = nil) -> CGPoint {
if let i = x {
self.x += CGFloat(i)
}
if let i = y {
self.y += CGFloat(i)
}
@rcabaco
rcabaco / gist:6765778
Created September 30, 2013 15:45
UITextView subclass to handle up/down cursor movement
// Code to handle up/down cursor motion in a UITextView.
//
// Based on code from OmniGroup's OUITextView
// https://github.com/omnigroup/OmniGroup/blob/master/Frameworks/OmniUI/iPad/OUITextView.m
//
#import "TextView.h"
@interface TextView ()
@kylefox
kylefox / color.m
Created January 27, 2012 17:45
Generate a random color (UIColor) in Objective-C
/*
Distributed under The MIT License:
http://opensource.org/licenses/mit-license.php
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to