This is now available in a dedicated package: ActivityView
Alternatively my SwiftUI Backports now includes a more complete implementation of ShareLink
that's also more performant.
import Foundation | |
infix operator ??? | |
extension Optional where Wrapped: Collection { | |
/// Performs a nil-coalescing operation, returning the wrapped value of an `Optional` instance | |
/// only if the wrapped value is not empty, otherwise returns a default value. | |
/// | |
/// - Parameters: |
This is now available in a dedicated package: ActivityView
Alternatively my SwiftUI Backports now includes a more complete implementation of ShareLink
that's also more performant.
// Authoer: The SwiftUI Lab | |
// Full article: https://swiftui-lab.com/scrollview-pull-to-refresh/ | |
import SwiftUI | |
struct RefreshableScrollView<Content: View>: View { | |
@State private var previousScrollOffset: CGFloat = 0 | |
@State private var scrollOffset: CGFloat = 0 | |
@State private var frozen: Bool = false | |
@State private var rotation: Angle = .degrees(0) |
// hexdump.swift | |
// | |
// This file contains library functions for generating hex dumps. | |
// | |
// The functions intended for client use are | |
// | |
// - `printHexDumpForBytes(_:)` | |
// - `printHexDumpForStandardInput()` | |
// - `hexDumpStringForBytes(_:)` | |
// - `logHexDumpForBytes(_:)` |
# comments example for .dat or .ledger files | |
@smallexample | |
; This is a single line comment, | |
# and this, | |
% and this, | |
| and this, | |
* and this. | |
# If you have a deeply nested tree of accounts, | |
# it may be convenient to define an alias, for example: |
func jpegDataFrom(image:NSImage) -> Data { | |
let cgImage = image.cgImage(forProposedRect: nil, context: nil, hints: nil)! | |
let bitmapRep = NSBitmapImageRep(cgImage: cgImage) | |
let jpegData = bitmapRep.representation(using: NSBitmapImageRep.FileType.jpeg, properties: [:])! | |
return jpegData | |
} |
import Foundation | |
import IOKit | |
import IOKit.hid | |
import Quartz | |
let ioman = IOHIDManagerCreate(kCFAllocatorDefault, | |
IOOptionBits(kIOHIDOptionsTypeNone)) | |
let runloop : CFRunLoop = CFRunLoopGetCurrent() | |
let devices = [ | |
kIOHIDVendorIDKey: 0x0b33, |
// RationalNumber.swift | |
// | |
// A basic implementation of Rational numbers in Swift 3.0. | |
// (c) 2016 Hooman Mehr. Licensed under Apache License v2.0 with Runtime Library Exception | |
/// A data type to model rational numbers in Swift. | |
/// | |
/// It always uses fully-reduced representation for simplicity and clarity of comparisons and uses LCM |