This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Safely Modifying The View State (SwiftUI) | |
// https://swiftui-lab.com | |
// https://swiftui-lab.com/state-changes | |
import SwiftUI | |
struct CustomView: View { | |
var body: some View { | |
NavigationView { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Adapted from Stack Overflow answer by David Crow http://stackoverflow.com/a/43235 | |
// Question: Algorithm to randomly generate an aesthetically-pleasing color palette by Brian Gianforcaro | |
// Method randomly generates a pastel color, and optionally mixes it with another color | |
import UIKit | |
func randomPastelColor(mixedWith mixColor: UIColor? = nil) -> UIColor { | |
// Mix the color | |
let mixColor: UIColor = mixColor ?? .lightGray | |
var mixRed: CGFloat = 0, mixGreen: CGFloat = 0, mixBlue: CGFloat = 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Alex Walczak, 2017 | |
# Simple recursive merge sort implementation. | |
def merge(left, right): | |
if not (len(left) and len(right)): | |
return left or right | |
result = [] | |
i = j = 0 | |
while len(result) < len(left) + len(right): | |
if i == len(left) or j == len(right): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
Alex Walczak, 2017 | |
Example of barrier implementation using TensorFlow shared variables | |
across a multi-machine cluster. | |
All workers synchronize on the barrier, copy global parameters to local versions, | |
and increment the global parameter variable asynchronously. | |
On each worker run: |