Skip to content

Instantly share code, notes, and snippets.

View eviathan's full-sized avatar
🏠
Working from home

Brian Williams eviathan

🏠
Working from home
  • iko
  • Bristol, UK
View GitHub Profile
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
public static class IListExtensions {
public static void Shuffle<T>(this IList<T> ts) {
var count = ts.Count;
var last = count - 1;
@eviathan
eviathan / RelativeView.swift
Created June 18, 2019 20:35
Relative Sizing for views on iOS using UIKit
import Foundation
import UIKit
class RelativeView: UIView {
@IBInspectable var width: CGFloat = 1.0
@IBInspectable var height: CGFloat = 1.0
override var intrinsicContentSize: CGSize {
return CGSize(width: width, height: height)
}
//
// ContentView.swift
// LearningSwiftUI
//
// Created by Brian on 08/06/2019.
// Copyright © 2019 Eviathan. All rights reserved.
//
import SwiftUI
//
// ContentView.swift
// LearningSwiftUI
//
// Created by Brian on 08/06/2019.
// Copyright © 2019 Eviathan. All rights reserved.
//
import SwiftUI
//
// ConnectFourBoardView.swift
// TestForMeitar
//
// Created by Brian on 18/05/2019.
// Copyright © 2019 Eviathan. All rights reserved.
//
import Foundation
import UIKit
let next = { print($0) }
let error = { print($0) }
let completed = { print("Completed") }
let disposed = { print("Disposed") }
// Empty
let emptyObservable = Observable<Int>.empty()
emptyObservable.subscribe(onNext: next, onError: error, onCompleted: completed, onDisposed: disposed)
@eviathan
eviathan / .playground
Last active December 19, 2018 16:29
# [Subject](http://reactivex.io/documentation/subject.html) A Subject is a sort of bridge or proxy that is available in some implementations of ReactiveX that acts both as an observer and as an Observable. Because it is an observer, it can subscribe
// Publish Subjects
// Starts empty and only emits new elements to subscribers.
let publishSubject = PublishSubject<Int>()
publishSubject
.asObserver()
.subscribe(onNext: {
print("Publish Subject Sub 1: \($0)")
})
.disposed(by: disposeBag)