Skip to content

Instantly share code, notes, and snippets.

View InfiniteFalltrough's full-sized avatar
:octocat:

_vik InfiniteFalltrough

:octocat:
  • FullDomePro Ltd
  • Bangkok
  • 16:17 (UTC +07:00)
View GitHub Profile
#!/usr/bin/env xcrun --sdk macosx swift
/// Run: swift answer\[1\].swift
var tokens: [String] = []
// O(1)
func ingest(_ input: String) {
tokens.append(input)
}
#!/usr/bin/env xcrun --sdk macosx swift
/// Run: swift answer\[2\].swift
import Foundation
class Cacher {
private let capacity: Int
private var cache: [String: (value: Int, weight: Double, timestamp: TimeInterval)] = [:]
private var scoreHeap: [(score: Double, counter: Int, key: String)] = []
#!/usr/bin/env xcrun --sdk macosx swift
/// Run: swift answer\[3\].swift
import Foundation
enum CustomError: Error {
case msg(String)
}
@InfiniteFalltrough
InfiniteFalltrough / answer[1].swift
Last active September 15, 2023 12:34
answer[1]
#!/usr/bin/env xcrun --sdk macosx swift
/// Run: swift answer\[1\].swift
var tokens: [String] = []
// O(1)
func ingest(_ input: String) {
tokens.append(input)
}
#import <MachOKit/MachOKit.h>
#import "BinaryHashUtils.h"
@implementation BinaryHashUtils
+(nullable NSString*) coreAppHashOfFileAtPath:(NSString*)path hasherAlg:(HasherAlg)hasherAlg {
NSURL* url = [NSURL fileURLWithPath:path];
if (url == nil) return nil;
MKMemoryMap* memoryMap = [MKMemoryMap memoryMapWithContentsOfFile:url error:nil];
import SwiftUI
import Combine
struct MVVMView: View {
@StateObject var viewModel: MVVMViewModel = MVVMViewModel()
var body: some View {
ZStack {
Color.green.opacity(0.5)
go mod edit -module {NEW_MODULE_NAME}
-- rename all imported module
find . -type f -name '*.go' \
-exec sed -i -e 's,{OLD_MODULE},{NEW_MODULE},g' {} \;
struct ContentView: View {
@State private var text: String = "Test"
@State private var tempText: String = "Last message"
var body: some View {
VStack {
Text(tempText)
.frame(width: 300, height: 50, alignment: .topLeading)
import UIKit
import CryptoKit
let data = "KEK! LOL!"
func generatePrivateKey() -> P256.KeyAgreement.PrivateKey {
let privateKey = P256.KeyAgreement.PrivateKey()
return privateKey
}