Skip to content

Instantly share code, notes, and snippets.

View mindbrix's full-sized avatar

Nigel Timothy Barber mindbrix

View GitHub Profile
//
// UIImage+PDF.swift. Copyright © 2016 Nigel Timothy Barber (@mindbrix). All rights reserved.
//
import UIKit
extension UIImage {
static func PDFImageWith(_ url: URL, pageNumber: Int, width: CGFloat) -> UIImage? {
return PDFImageWith(url, pageNumber: pageNumber, constraints: CGSize(width: width, height: 0))
}
//
// UIImage+Decompression.swift
// Contis Protocol
//
// Created by Nigel Barber on 01/03/2017.
// Copyright © 2017 @mindbrix. All rights reserved.
//
import CoreGraphics
import ImageIO
@mindbrix
mindbrix / PDFImage.swift
Last active November 17, 2016 09:16
Swift replacement for UIImage+PDF
//
// PDFImage.swift. Copyright © 2016 Nigel Timothy Barber (@mindbrix). All rights reserved.
//
import UIKit
extension UIImage {
static func PDFImageWith(url: NSURL, pageNumber: Int, width: CGFloat) -> UIImage? {
return PDFImageWith(url, pageNumber: pageNumber, constraints: CGSizeMake(width, 0))
}
@mindbrix
mindbrix / gist:710707d3dec311196e5e
Last active August 29, 2015 14:03
Unicode char to NSString
NSString *hexString = @"1F0A7";
unsigned int character;
NSScanner* scanner = [NSScanner scannerWithString:hexString ];
[ scanner scanHexInt:&character ];
UTF32Char inputChar = NSSwapHostIntToLittle(character); // swap to little-endian if necessary
NSString *str = [[NSString alloc] initWithBytes:&inputChar length:4 encoding:NSUTF32LittleEndianStringEncoding];
@mindbrix
mindbrix / Matrix.hpp
Created April 6, 2014 18:22
Matrix and Vector C++ classes extended from the ones in this book: http://shop.oreilly.com/product/9780596804831.do
#pragma once
#include "Vector.hpp"
template <typename T>
struct Matrix2 {
Matrix2()
{
x.x = 1; x.y = 0;
y.x = 0; y.y = 1;
}
//
// NTBFifoOperationQueue.h
// Timeline
//
// Created by Nigel Barber on 19/11/2013.
// Copyright (c) 2013 Nigel Barber. All rights reserved.
//
#import <Foundation/Foundation.h>
//
// UILabel+MultiLineSupport.h
// giffgaffIOS
//
// Created by Nigel Barber on 23/10/2013.
// Copyright (c) 2013 confidence. All rights reserved.
//
#import <UIKit/UIKit.h>
@mindbrix
mindbrix / UILabel+MultiLineSupport.h
Created October 23, 2013 13:59
Support for creating a multi-line UILabel from NSAttributedStrings
//
// UILabel+MultiLineSupport.h
// giffgaffIOS
//
// Created by Nigel Barber on 23/10/2013.
// Copyright (c) 2013 confidence. All rights reserved.
//
#import <UIKit/UIKit.h>
@mindbrix
mindbrix / drawTimecodeUsingGCD.m
Created July 8, 2013 11:48
How to draw rapidly refreshed string labels performantly using GCD.
-(void)drawTimecodeUsingGCD
{
if( dispatch_semaphore_wait( _timecodeSemaphore, DISPATCH_TIME_NOW ) != 0 )
{
return;
}
dispatch_async( _timecodeQueue, ^()
{
float fontSize = ceilf( self.scrubberSize * 0.425f );
@mindbrix
mindbrix / NTBProxyImageView.h
Created June 21, 2013 17:07
NTBProxyImageView
//
// NTBProxyImageView.h
// Vectoria Squared
//
// Created by Nigel Barber on 22/04/2013.
// Copyright (c) 2013 Nigel Barber. All rights reserved.
//
#import <UIKit/UIKit.h>