This file contains hidden or 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
| struct NumberComposition { | |
| var value: Int | |
| var numbers: [Int] | |
| var composition: [Int] { | |
| return generateComposition() | |
| } | |
| init(of value: Int, fromNumbers numbers: [Int]) { | |
| self.value = value | |
| self.numbers = numbers |
This file contains hidden or 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
| struct MediaItem { | |
| var duration: Int? | |
| var title: String? | |
| var urlString: String? | |
| static func parseM3U(contentsOfFile: String) -> [MediaItem]? { | |
| var mediaItems = [MediaItem]() | |
| contentsOfFile.enumerateLines({ line, stop in | |
| if line.hasPrefix("#EXTINF:") { | |
| let infoLine = line.stringByReplacingOccurrencesOfString("#EXTINF:", withString: "") |
This file contains hidden or 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
| devran@ubuntu:~/projects/Hello$ swift | |
| Welcome to Swift version 2.2-dev (LLVM 46be9ff861, Clang 4deb154edc, Swift 778f82939c). Type :help for assistance. | |
| 1> import Foundation | |
| 2> CG | |
| Available completions: | |
| CGFloat | |
| CGPoint | |
| CGRect | |
| CGRectEdge | |
| CGSize |
This file contains hidden or 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
| "platform": "cmdSwitch2", | |
| "name": "CMD Switch", | |
| "switches": [{ | |
| "name" : "Projector", | |
| "on_cmd": "sudo echo -ne \"* 0 IR 001\r\" > /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_AL00M6F3-if00-port0", | |
| "off_cmd": "sudo echo -ne \"* 0 IR 002\r\" > /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_AL00M6F3-if00-port0", | |
| "state_cmd": ": $(rm ~/.projector;timeout 2s cat < /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_AL00M6F3-if00-port0 > ~/.projector & sleep 0.5;sudo echo -ne \"* 0 Lamp ?\r\" > /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_AL00M6F3-if00-port0; sleep 1.5) && grep 'Lamp 1' ~/.projector", | |
| "polling": true, | |
| "interval": 5, | |
| "timeout": 4000, |
This file contains hidden or 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
| extension Data { | |
| /// Returns a new `Data` shifted by the number of given bits. | |
| /// | |
| /// - parameter bits: Number of bits the data to be shifted. | |
| /// - returns: The shifted data. | |
| func shifted(byBits bits: Int) -> Data { | |
| let bitWidth = UInt8.bitWidth | |
| var previousByte = UInt8() | |
| return Data(bytes: self.shifted(byBytes: bits / bitWidth).map { | |
| let result: UInt8 = ($0 >> (bits % bitWidth)) | (previousByte << (bits % bitWidth)) |
This file contains hidden or 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
| APP=TeamsFixer | |
| mkdir -vp ${APP}.app/Contents/MacOS ${APP}.app/Contents/Resources | |
| PATH="$PATH:/usr/libexec" | |
| printf '#!/usr/bin/env bash\nexec /Applications/Microsoft\ Teams.app/Contents/MacOS/Teams --disable-gpu' > ${APP}.app/Contents/MacOS/${APP} | |
| chmod +x ${APP}.app/Contents/MacOS/${APP} | |
| cp /Applications/Microsoft\ Teams.app/Contents/Resources/icon.icns ${APP}.app/Contents/Resources/icon.icns | |
| PlistBuddy ${APP}.app/Contents/Info.plist -c "add CFBundleDisplayName string ${APP}" | |
| PlistBuddy ${APP}.app/Contents/Info.plist -c "add CFBundleIconFile string icon.icns" | |
| PlistBuddy ${APP}.app/Contents/version.plist -c "add ProjectName string ${APP}" | |
| find ${APP}.app |
This file contains hidden or 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 | |
| // July 1, 2019 | |
| print([109, 111, 105, 110].map { String(UnicodeScalar($0)) }.joined()) | |
| // July 2, 2019 | |
| var hex: UInt32 = 0x6E696F6D | |
| let data = Data(bytes: &hex, count: MemoryLayout<UInt32>.size) | |
| String(data: data, encoding: String.Encoding.ascii) |
This file contains hidden or 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
| # July 16, 2019 | |
| "bdic".tr("a-e", "l-p") | |
| # July 17, 2019 | |
| require 'zlib' | |
| Zlib.inflate("x\x9C\xCB\xCD\xCF\xCC\x03\x00\x04E\x01\xB4") | |
| # July 18, 2019 | |
| "$;6]I;@``\n".unpack1("u") |
This file contains hidden or 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 | |
| import CoreData | |
| import CoreFoundation | |
| import CoreGraphics | |
| import CoreText | |
| import Darwin | |
| import Foundation | |
| import SwiftUI | |
| import UIKit | |
| import os.log |
This file contains hidden or 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
| (extension in :Animatable< where A.AnimatableData == EmptyAnimatableData>.animatableData.getter : EmptyAnimatableData | |
| (extension in :Animatable< where A.AnimatableData == EmptyAnimatableData>.animatableData.modify : EmptyAnimatableData | |
| (extension in :Animatable< where A.AnimatableData == EmptyAnimatableData>.animatableData.setter : EmptyAnimatableData | |
| (extension in :Animatable< where A: VectorArithmetic>.animatableData.getter : A | |
| (extension in :Animatable< where A: VectorArithmetic>.animatableData.modify : A | |
| (extension in :Animatable< where A: VectorArithmetic>.animatableData.setter : A | |
| (extension in :Button< where A == PrimitiveButtonStyleConfiguration.Label>.init(PrimitiveButtonStyleConfiguration) -> Button<PrimitiveButtonStyleConfiguration.Label> | |
| (extension in :Button< where A == Text>.init(_: LocalizedStringKey, action: () -> ()) -> Button<Text> | |
| (extension in :Button< where A == Text>.init<A where A1: StringProtocol>(_: A1, action: () -> ()) -> Button<Text> | |
| (extension in :CoreGraphics.CGFloat.magnitudeSqu |