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 UIKit | |
enum Op { | |
case add, minus, multiply, divide | |
} | |
@_functionBuilder | |
class MathBuilder { | |
static func buildBlock(_ op: Op, _ items:Int...) -> Int { | |
switch op { |
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 UIKit | |
import CryptoKit | |
func jwt(header: String, payload: String, secret: String) -> String { | |
func base64URLencode(_ s: String) -> String { | |
return s.replacingOccurrences(of: "/", with: "_").replacingOccurrences(of: "+", with: "-") | |
} | |
let headerData = base64URLencode(header).data(using: .utf8)!.base64EncodedString() |
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 UIKit | |
import CryptoKit | |
import CommonCrypto | |
let str = "Boom boom boom boom boom boom" | |
// CryptoKit | |
func MD5CryptoKit(string: String) -> Data { | |
string.data(using:.utf8)!.withUnsafeBytes { ptr in | |
Data(Insecure.MD5.hash(bufferPointer: ptr).map { $0 }[0..<Insecure.MD5.byteCount]) |
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
class Range(object): | |
'An object with a start and a length.' | |
def __init__(self, start, length): | |
self.start = start | |
self.length = length | |
def contains(self, another): | |
'If the range contains another range.' |
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 | |
func solution(_ n: Int) -> Int { | |
func fac(_ n: Int) -> Int { | |
if n == 1 { | |
return 1 | |
} | |
return (1...n).reduce(1, *) | |
} |
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 | |
func solution(_ n:Int) -> Int { | |
let sorted_n = "\(n)".sorted() | |
let i = Int(pow(Double(10), Double("\(n)".count))) | |
return Array(0...i).filter { "\($0)".sorted() == sorted_n }.count | |
} | |
print(solution(0)) | |
print(solution(1)) |
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
def solution(n): | |
sorted_n = sorted(str(n)) | |
i = pow(10, len(str(n))) | |
return len([x for x in range(0, i) if sorted(str(x)) == sorted_n]) |
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 UIKit | |
import AVFoundation | |
class ViewController: UIViewController { | |
var audioEngine = AVAudioEngine() | |
var audioData = Data() | |
override func viewDidLoad() { | |
super.viewDidLoad() |
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 | |
enum ConverterError: Error { | |
case outOfBounds | |
} | |
func UTF8ToUTF16(_ data: Data) -> [unichar] { | |
func decode(index: Int, length: Int) throws -> unichar { | |
if index + length > data.count { | |
throw ConverterError.outOfBounds |
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
function upload_to_app_store() | |
{ | |
IPA_FILE="${JOB_NAME}_${BUILD_NUMBER}.ipa" | |
IPA_FILENAME=$(basename $IPA_FILE) | |
MD5=$(md5 -q $IPA_FILE) | |
BYTESIZE=$(stat -f "%z" $IPA_FILE) | |
ITMSP_DIR="itmsp_${AppTarget}" | |
rm -rf "${ITMSP_DIR}" | |
mkdir "${ITMSP_DIR}" |