Skip to content

Instantly share code, notes, and snippets.

set(CPM_DOWNLOAD_VERSION 0.40.2)
set(CPM_DOWNLOAD_LOCATION "${CMAKE_BINARY_DIR}/cmake/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
if(NOT (EXISTS ${CPM_DOWNLOAD_LOCATION}))
message(STATUS "Downloading CPM.cmake...")
file(DOWNLOAD https://github.com/cpm-cmake/CPM.cmake/releases/download/v${CPM_DOWNLOAD_VERSION}/CPM.cmake ${CPM_DOWNLOAD_LOCATION})
endif()
include(${CPM_DOWNLOAD_LOCATION})
CPMAddPackage(
NAME volk
@geor-kasapidi
geor-kasapidi / mangalib_images.js
Last active May 12, 2024 12:43
mangalib script to download images and open next chapter
// ==UserScript==
// @name MangaLib - Auto Download and Navigate
// @namespace http://tampermonkey.net/
// @version 1.0
// @description Automatically download content and navigate to the next page
// @author Geor Kasapidi
// @match https://mangalib.org/*
// @grant none
// ==/UserScript==
static func _compile(data: Data, configuration: MLModelConfiguration = .init()) async throws -> MLModel {
let tmp = FileManager.default.temporaryDirectory.appendingPathComponent(UUID().uuidString)
try data.write(to: tmp, options: .atomic)
let url = try await MLModel.compileModel(at: tmp)
try FileManager.default.removeItem(at: tmp)
let model = try MLModel(contentsOf: url, configuration: configuration)
try FileManager.default.removeItem(at: url)
return model
}
@geor-kasapidi
geor-kasapidi / metal.py
Created November 16, 2021 10:30
Metal AST
import sys
import os
import clang.cindex
shaders_file = sys.argv[1]
assert(shaders_file.endswith(“.metal”))
ast_file = shaders_file.rstrip(“.metal”) + “.ast
os.system(fxcrun metal -emit-ast {shaders_file}“)
xcode_path = os.popen(“xcode-select -p”).read().rstrip()
@geor-kasapidi
geor-kasapidi / swf.sh
Last active September 17, 2021 10:15
swiftformat shell script
swiftformat \
--self insert \
--wrapcollections before-first \
--wraparguments before-first \
--wrapparameters before-first \
--header strip \
--ifdef no-indent \
--enable wrapSwitchCases \
--enable organizeDeclarations \
--swiftversion 5.3 .
struct EnumSet<T: RawRepresentable & CaseIterable>: OptionSet where T.RawValue == Int {
let rawValue: T.RawValue
init(rawValue: T.RawValue) {
self.rawValue = rawValue
}
init(_ value: T) {
self.rawValue = 1 << value.rawValue
}
@geor-kasapidi
geor-kasapidi / swiftformat
Created August 16, 2021 14:34
Swiftformat rules
--self insert
--wrapcollections after-first
--wraparguments after-first
--wrapparameters after-first
--header strip
--enable wrapSwitchCases
--enable organizeDeclarations
import STS
final class Registry {
// MARK: Internal
func register<T: AnyObject>(_ value: T) {
self.lock.execute {
let key = ObjectIdentifier(T.self)
assert(self.objects[key] == nil)
assert(self.factories[key] == nil)
@geor-kasapidi
geor-kasapidi / MetalCVPixelBuffer.swift
Created July 23, 2021 18:18
MetalCVPixelBuffer.swift
import CoreVideo
import Alloy
import Foundation
import Accelerate
enum MetalCVPixelBuffer {
static func transform(texture input: MTLTexture,
transformer: @escaping (CVPixelBuffer) throws -> CVPixelBuffer,
cache: CVMetalTextureCache) throws -> MTLTexture {
guard let inputPixelBuffer = input.pixelBuffer else {
@geor-kasapidi
geor-kasapidi / lock.swift
Created July 22, 2021 09:19
_modfiy lock
@propertyWrapper
public final class ThreadSafe<Root> {
private let lock = OSUnfairLock()
private var value: Root
public init(wrappedValue: Root) {
self.value = wrappedValue
}