Skip to content

Instantly share code, notes, and snippets.

View josephlord's full-sized avatar

Joseph Lord josephlord

View GitHub Profile
@josephlord
josephlord / CSVParser.swift
Created October 1, 2021 13:12 — forked from mukeshthawani/CSVParser.swift
A simple CSV parser in Swift
/// Parses a csv string and returns a 2d array.
///
/// Size of the array will be equal to the number of rows.
/// And Size of the subarray will be equal to the
/// number of fields.
///
/// Note: Delimiter can be changed to a different character
/// like semicolon.
func parse(string: String, delimiter: Character = ",") -> [[String]]{
let rows = string.split(separator: "\n")
@josephlord
josephlord / pointless swift benchmarks
Last active November 20, 2015 18:47 — forked from Catfish-Man/pointless swift benchmarks
Faster by removing variables - Original and optimised Swift (optimised is 30-40% faster
import Foundation
private let testSize = 100_000_000
private var testTime:CFAbsoluteTime = 0
private var optimisedTestTime:CFAbsoluteTime = 0
class Test
{
func testing2(var x : Int) -> Int
{
private var privateGlobalFoo = 42
class Foo {
class var foo: Int {
get { return privateGlobalFoo }
set(newVal) { privateGlobalFoo = newVal }
}
}
println(Foo.foo)
@interface UILabel (dynamicSizeMe)
-(float)resizeToFit;
-(float)expectedHeight;
-(void)resizeToStretch;
-(float)expectedWidth;
@end