Skip to content

Instantly share code, notes, and snippets.

Michael Prenez-Isbell misbell

Block or report user

Report or block misbell

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View AutoC.swift
import Foundation
import UIKit
//1 create view with a title property
class TestView : UIView {
var title: String?
var rank: Int?
init(title: String, rank: Int) {
self.title = title
self.rank = rank
@misbell
misbell / gist:97ffc4aaa9c81f7e53ede3c28c95051e
Created Dec 3, 2016
The Map , Filter, Reduce code chapter from Fatih Nayebi, adapted for Swift 3.0.1 from Swift 2
View gist:97ffc4aaa9c81f7e53ede3c28c95051e
// This code runs in a playground in Swift 3.0.1
import Cocoa
var str = "Hello, playground"
/*
MPI
dec 2 2016
@misbell
misbell / gist:90a39719a45cf456398854627f672d09
Created Oct 23, 2016
Functions return [String:Any] and [AnyHashable:Any] , consumed in for-in loop, String conversions
View gist:90a39719a45cf456398854627f672d09
// Wrote this to test out how Arrays of Dictionaries are handled
// was surprised to see they become tuples in a for-in
// also some unintuitive string conversions
import Cocoa
func c() -> [String:Any] {
print ( "ok" )
@misbell
misbell / gist:fa7ecd562a9b0d9c1237eed5e1a6d89e
Created Oct 16, 2016
example Swift 3 withMemoryRebound
View gist:fa7ecd562a9b0d9c1237eed5e1a6d89e
so A and B are structurally identical
C reverses the order of the 8 and 32 bit Ints
and D substitutes a string for the Int8
then I try to read aaaa’s bits using B C and D overlays 😊
C is printing the 8 bits of the A integer j and then the first 8 bits of integer k but somehow that still works out to one
when I hit D it doesn’t find a string so prints a blank
but the important point is: it doesn’t check anything, and doesn’t crash
@misbell
misbell / gist:bae00230c42e9ff48d53e609618eb4a3
Created Oct 6, 2016
DispatchWorkItem barrier attribute
View gist:bae00230c42e9ff48d53e609618eb4a3
so this works as expected:
let conq = DispatchQueue(label: "ok", qos: .background, attributes: .concurrent )
// let conq = DispatchQueue.global(qos: .userInitiated)
let dw1 = DispatchWorkItem {
//sleep(2)
print("dw1")
}
@misbell
misbell / gist:2dc38c47ff56f91c6775dde2be1fceb4
Created Oct 5, 2016
os_unfair_lock, simple useage from wwdc 2016 concurrency talk by Pierre Habouzit, objective-c, bridging header and Swift 3
View gist:2dc38c47ff56f91c6775dde2be1fceb4
#import "FoundationLocks.h"
#import "os/lock.h"
@implementation LockableObject
os_unfair_lock _lock;
- (instancetype) init {
@misbell
misbell / gist:97f3c840a570598270fa8e406a7c60c8
Created Oct 4, 2016
Returning value from subsystem with DispatchQueue.sync - Swift 3.0 - October 4 2016
View gist:97f3c840a570598270fa8e406a7c60c8
// pretending this is a subsystem
let holdval = HoldAValue()
var avalue: Int {
var i: Int = 0
DispatchQueue.global(qos: .userInitiated).sync {
i = holdval.anIntValue
}
return i
}
@misbell
misbell / gist:c2f5aea998ba64174a23e538172243f1
Created Oct 4, 2016
DispatchQueue and DispatchGroup in Swift 3.0 as of Oct 4 2016
View gist:c2f5aea998ba64174a23e538172243f1
let dispatchGroup = DispatchGroup()
let dq = DispatchQueue.global(qos: .utility)
dq.async {
for i in 0...3{
dq.async {
print("\n i - \(i)")
View .gitignore
#########################
# .gitignore file for Xcode4 / OS X Source projects
#
# NB: if you are storing "built" products, this WILL NOT WORK,
# and you should use a different .gitignore (or none at all)
# This file is for SOURCE projects, where there are many extra
# files that we want to exclude
#
# For updates, see: http://stackoverflow.com/questions/49478/git-ignore-file-for-xcode-projects
#########################
You can’t perform that action at this time.