Skip to content

Instantly share code, notes, and snippets.

View michaelbiggs's full-sized avatar

Michael Biggs michaelbiggs

View GitHub Profile
@michaelbiggs
michaelbiggs / closure.swift
Created February 11, 2023 16:48
Swift Closure Syntax
import UIKit
func createView(_ closure: () -> Void) -> UIView {
closure()
return UIView()
}
let exampleClosure: () -> Void = { print("Hello, World!") }
let exampleView = createView(exampleClosure)
@michaelbiggs
michaelbiggs / Example.swift
Last active February 3, 2023 17:49 — forked from cliss/Example.swift
Decoding a heterogenous JSON array with unknown object types
// This is intended to be dropped in a Playground.
import Foundation
let json =
"""
{
"name": "Casey's Corner",
"menu": [
{
@michaelbiggs
michaelbiggs / 0_reuse_code.js
Last active August 29, 2015 14:16
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@michaelbiggs
michaelbiggs / gist:5503410
Created May 2, 2013 16:27
Convert NSString to NSData
<NSData *data> = [<NSString* string> str dataUsingEncoding: NSUTF8StringEncoding];
@michaelbiggs
michaelbiggs / gist:5396289
Created April 16, 2013 14:21
recursively remove subdirectory and files
rm -rf <subdir-name>
@michaelbiggs
michaelbiggs / gist:5396244
Created April 16, 2013 14:15
recursive list of files in current directory
find . -type f
@michaelbiggs
michaelbiggs / gist:5264009
Last active December 15, 2015 12:59
Run a case insensitive search for a NSString within a NSString
if ( [<NSString *stringToSearchThrough> rangeOfString: <NSString *stringToSearchFor>
options: NSCaseInsensitiveSearch].location != NSNotFound )
@michaelbiggs
michaelbiggs / gist:5247922
Last active December 15, 2015 10:48
Parse NSString with separator
[<NSString* string> componentsSeparatedByString: <NSString* separator>]
@michaelbiggs
michaelbiggs / gist:5216033
Last active December 15, 2015 06:28
Check if something is not equal to NSNull
if ( (NSNull*)<id something> != [NSNull null] )
@michaelbiggs
michaelbiggs / gist:5134795
Created March 11, 2013 14:55
translate CGPoint (or CGRect) from super view to other view
[<UIView* otherView> convertPoint: <CGPoint pointToTranslate> fromView: <UIView* pointSuperview>]
or
[<UIView* otherView> convertRect: <CGRect rectToTranslate> fromView: <UIView* rectSuperview> ]