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 python | |
# coding=utf-8 | |
# License: Public domain (CC0) | |
# Isaac Turner 2016/12/05 | |
# 1f604 2022/02/11 | |
from __future__ import print_function | |
import difflib | |
import re |
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
// The following code has been tested. It compiles and works. | |
// Swift code | |
func encrypt(input: [UInt8]) -> Data? { | |
let key = SymmetricKey(size: .bits256) | |
let key64 = key.withUnsafeBytes { | |
return Data(Array($0)).base64EncodedString() | |
} | |
print("key64:", key64) | |
var sealedBox: AES.GCM.SealedBox |
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 query(address: String) -> String { | |
let url = URL(string: address) | |
let semaphore = DispatchSemaphore(value: 0) | |
var result: String = "" | |
let task = URLSession.shared.dataTask(with: url!) {(data, response, error) in | |
result = String(data: data!, encoding: String.Encoding.utf8)! |
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 python | |
# coding=utf-8 | |
# License: Public domain (CC0) | |
# Isaac Turner 2016/12/05 | |
from __future__ import print_function | |
import difflib | |
import re |
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 python3 | |
''' | |
`@beartype` decorator, implementing a rudimentary subset of PEP 484-style type | |
checking based on Python 3.x function annotations. | |
See Also | |
---------- | |
https://stackoverflow.com/a/37961120/2809027 | |
Stackoverflow answer introducing the `@beartype` decorator. |
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
Below are the Big O performance of common functions of different Java Collections. | |
List | Add | Remove | Get | Contains | Next | Data Structure | |
---------------------|------|--------|------|----------|------|--------------- | |
ArrayList | O(1) | O(n) | O(1) | O(n) | O(1) | Array | |
LinkedList | O(1) | O(1) | O(n) | O(n) | O(1) | Linked List | |
CopyOnWriteArrayList | O(n) | O(n) | O(1) | O(n) | O(1) | Array |
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
""" | |
Computes the probability distribution of states created by | |
the shuffle2 algorithm. This should return results similar to | |
enumerate_shuffle.py. | |
A state is a 2-tuple: (swapped, deck) | |
The probability of transitioning from one state to another can be represented by | |
a Markov matrix M. |