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
import SwiftUI | |
import Charts | |
import Combine | |
import Foundation | |
final class GameState: ObservableObject { | |
struct Player { | |
var position: Int | |
var halfSize: Int = 150 |
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
import Combine | |
@available(OSX 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *) | |
extension Publisher { | |
func removeDuplicates<Property>(by keyPath: KeyPath<Output, Property>) | |
-> Publishers.RemoveDuplicates<Self> where Property: Equatable | |
{ | |
return self.removeDuplicates { | |
$0[keyPath: keyPath] == $1[keyPath: keyPath] | |
} |
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
compile: | |
wat2wasm main.wat -o main.wasm | |
serve: | |
python -m SimpleHTTPServer |
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
import UIKit | |
extension UISegmentedControl { | |
func goVertical() { | |
self.transform = CGAffineTransformMakeRotation(CGFloat(M_PI_2)) | |
for segment in self.subviews { | |
for segmentSubview in segment.subviews { | |
if segmentSubview is UILabel { | |
(segmentSubview as UILabel).transform = CGAffineTransformMakeRotation(CGFloat(-M_PI_2)) | |
} |
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
import Foundation | |
func withCStrings(_ strings: [String], scoped: ([UnsafeMutablePointer<CChar>?]) throws -> Void) rethrows { | |
let cStrings = strings.map { strdup($0) } | |
try scoped(cStrings + [nil]) | |
cStrings.forEach { free($0) } | |
} | |
enum RunCommandError: Error { | |
case WaitPIDError |
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
#if canImport(Darwin) | |
import Darwin | |
#else | |
import Glibc | |
#endif | |
enum RawModeError: Error { | |
case notATerminal | |
case failedToGetTerminalSetting | |
case failedToSetTerminalSetting |
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
import XCTest | |
extension XCTestCase { | |
/// Simple helper for asynchronous testing. | |
/// Usage in XCTestCase method: | |
/// func testSomething() { | |
/// doAsyncThings() | |
/// eventually { | |
/// /* XCTAssert goes here... */ |
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
""" | |
Resize a SVG file to a new size. Coordinates of paths and gradient definitions get transposed to corresponding | |
values in the new canvas. Everything else remain unchanged. | |
""" | |
import re | |
from argparse import ArgumentParser | |
from xml.etree import ElementTree |
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
SHELL = /bin/bash | |
ifeq ($(shell uname),Darwin) | |
EXTRA_SWIFT_FLAGS = "--disable-sandbox" | |
else | |
SWIFT_TOOLCHAIN = "$(shell dirname $(shell swift -print-target-info | grep runtimeResourcePath | cut -f 2 -d ':' | cut -f 2 -d '"'))" | |
EXTRA_SWIFT_FLAGS = -Xcxx -I${SWIFT_TOOLCHAIN}/swift -Xcxx -I${SWIFT_TOOLCHAIN}/swift/Block | |
endif | |
.PHONY: test |
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
#!/usr/bin/env xcrun swift | |
/* | |
usage: | |
1. chmod +x QuickOutline.swift | |
2. ./QuickOutline.swift outline.json | |
this will generate BDD/[Quick](https://github.com/Quick/Quick) style test outlines according to outline.json | |
an example outline.json: |
NewerOlder