Skip to content

Instantly share code, notes, and snippets.

View wookiee's full-sized avatar
🤗
Biting shoulders

Mikey Ward wookiee

🤗
Biting shoulders
View GitHub Profile
@wookiee
wookiee / main.dart
Created September 13, 2023 12:16
dis-dart-flutter-fun
import 'package:flutter/material.dart';
void main() => runApp(const SignUpApp());
class SignUpApp extends StatelessWidget {
const SignUpApp();
@override
Widget build(BuildContext context) {
return MaterialApp(
@wookiee
wookiee / StructuredConcurrencyProposals.md
Last active May 20, 2021 22:21
Swift Structured Concurrency Proposals
  • async/await and Structured Concurrency introduce the syntactical building blocks (including the Task type) for writing asynchronous code using Swift-native language features.
  • There is a WIP standalone proposal to add async let syntax to greatly reduce a pain point of filling values asynchronously for later use.
  • actor types introduce a new top-level reference type (like class) that require and statically enforce that access to any of their mutable state be done asynchronously (such as by using the async/await syntax), and exist to help model thread-safe mutable data structures. The idea of [global actors](https://github
“_wrappers.so” cannot be opened because the developer cannot be verified.
https://gist.github.com/70547c03a0df58b349eed8d600fced9b
import Foundation
@propertyWrapper public struct Percentage<Value: FloatingPoint> {
private var storage: Value
private let upperBound: Value
public init(wrappedValue: Value, upperBound: Value = (1.0 as! Value)) {
self.storage = wrappedValue
self.upperBound = upperBound
@wookiee
wookiee / PickWeighted.swift
Created February 14, 2020 18:01
Swift function to pseudorandomly choose an item from an Array, allowing for individual weighting of their likelihood of choice.
/// Pseudorandomly choose a value from an array of values, where each is weighted relative to the others in the collection.
///
/// The `weight` component of each tuple is a positive integer signalling how likely a value is to be chosen vs. other values with different weights. For example, a value with a weight of `4` is four times as likely as a value with a weight of `1` to be chosen.
///
/// - Parameter values: an array of `(value:Thing,weight:Int)` tuples.
///
/// - Returns: a single chosen value.
///
func pickWeighted<Thing>(from weightedValues: [(value: Thing, weight: Int)]) -> Thing {
// compute the sum of the weights of all of the value/weight pairs
Image augmentation option 'exposure' selected.
Image augmentation option 'shear' selected.
Automatically generating validation set from 10% of the data.
Extracting augmented image features from training data set.
Analyzing and extracting image features.
+----------------------+------------------+--------------+------------------+
| Raw Images Processed | Augmented Images | Elapsed Time | Percent Complete |
+----------------------+------------------+--------------+------------------+
| 1 | 16 | 2.31s | 2% |
| 2 | 32 | 2.98s | 4% |
@wookiee
wookiee / zip3.swift
Last active February 5, 2018 19:37 — forked from JRHeaton/zip3.swift
Implementing zip3 in Swift
struct Zip3Iterator
<
A: IteratorProtocol,
B: IteratorProtocol,
C: IteratorProtocol
>: IteratorProtocol {
private var first: A
private var second: B
@wookiee
wookiee / DragTableController.swift
Created August 19, 2017 20:31 — forked from sooop/DragTableController.swift
NSTableView reordering row with drag and drop
//
// ViewController.swift
// DragTable
//
// Created by Anna Kim on 2017. 2. 9..
// Copyright © 2017년 Anna Kim. All rights reserved.
//
import Cocoa
@wookiee
wookiee / UserDefault.swift
Last active May 29, 2017 16:05
Convenience wrapper for UserDefaults-bound computed properties
//
// UserDefault.swift
//
// Created by Michael L. Ward on 5/29/17.
// Copyright © Michael L. Ward. All rights reserved.
//
import Foundation
struct UserDefault<T> {