Skip to content

Instantly share code, notes, and snippets.

@ktustanowski
ktustanowski / SNClassifySoundRequest.knownClassifications.txt
Created November 6, 2021 10:52
List of supported classifications for SNClassifySoundRequest
0. speech
1. shout
2. yell
3. battle_cry
4. children_shouting
5. screaming
6. whispering
7. laughter
8. baby_laughter
9. giggling
@ktustanowski
ktustanowski / VNClassifyImageRequest.Supportedidentifiers.txt
Last active January 12, 2022 19:39
Contains a list of supported identifiers for VNClassifyImageRequest (VNClassifyImageRequestRevision1).
▿ 1303 elements
- 0 : "abacus"
- 1 : "accordion"
- 2 : "acorn"
- 3 : "acrobat"
- 4 : "adult"
- 5 : "adult_cat"
- 6 : "agriculture"
- 7 : "aircraft"
- 8 : "airplane"
struct Atbash: Cipher {
private let alphabet = Alphabet.letters
func encrypt(_ text: String) -> String {
var output = [Character]()
for character in text {
if character != " " {
guard let index = alphabet.index(of: character) else { continue }
output.append(alphabet[alphabet.count - index - 1])
@IBAction func encrypt() {
outputLabel.text = cipher?.encrypt(inputTextView.text)
}
@IBAction func selectCipher(_ sender: UISegmentedControl) {
guard let cipherName = CipherName(rawValue: sender.selectedSegmentIndex) else { return }
switch cipherName {
case .atbash:
encryptButton.isEnabled = true
decryptButton.isEnabled = true
default:
encryptButton.isEnabled = false
decryptButton.isEnabled = false
}
@IBAction func selectCipher(_ sender: UISegmentedControl) {
guard let cipherName = CipherName(rawValue: sender.selectedSegmentIndex) else { return }
switch cipherName {
case .atbash:
break
default:
break
}
}
class NumbersDecryptor: Decryptor {
fileprivate var cipherDictionary = [String : String]()
override func decrypt(_ input: String) -> String? {
cipherDictionary.removeAll()
// The most annoying part of this is to properly replace characters in message
// so when we do .separatedBy we just get strings we can change to numbers.
// This may break depending on what text you will use and whether you are using characters
// that are currently supported or not. I even noticed that – is not the same as -.
class AtbashDecryptor: Decryptor {
override func substitute(_ string: String) -> String {
guard let index = alphabet.index(of: string) else { return string }
return alphabet[alphabet.count - index - 1]
}
}
26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
let s01e01Encrypted = "ZHOFRPH WR JUDYLWB IDOOV"
let s01e01Decrypted = ShiftLettersDecryptor(shift: -3).decrypt(s01e01Encrypted)
print(s01e01Decrypted!) // welcome to gravity falls