Skip to content

Instantly share code, notes, and snippets.

View bynelus's full-sized avatar

Niels bynelus

View GitHub Profile
@humblehacker
humblehacker / make-opencv2-xcframework.md
Last active June 26, 2024 13:24
Make opencv2.xcframework for iOS arm64, and iOSSimulator arm64 & x86_64

I had some trouble attempting to build an XCFramework of OpenCV, but I finally got a successful build with the following steps:

  1. Clone the OpenCV repo:
    git clone git@github.com:opencv/opencv.git
    cd opencv
    
  2. Disable building with libjpeg-turbo[^1] by applying a patch:
    git apply path/to/opencv-5-28-50.patch
@CassiusPacheco
CassiusPacheco / WaitForCompletion.swift
Last active September 1, 2022 08:30
toBlocking equivalent for Combine's Publishers
extension Publisher {
func waitForCompletion(timeout: TimeInterval = 1.0, file: StaticString = #file, line: UInt = #line) throws -> [Output] {
let expectation = XCTestExpectation(description: "wait for completion")
var completion: Subscribers.Completion<Failure>?
var output = [Output]()
let subscription = self.collect()
.sink(receiveCompletion: { receiveCompletion in
completion = receiveCompletion
expectation.fulfill()
@vzsg
vzsg / 1_Fetch.swift
Last active June 25, 2021 10:37
A solution for the N+1 problem when fetching children for parents (Fluent 3)
import Fluent
func fetchChildren<Parent, ParentID, Child: Model, Result>(
of parents: [Parent],
idKey: KeyPath<Parent, ParentID?>,
via reference: KeyPath<Child, ParentID>,
on conn: DatabaseConnectable,
combining: @escaping (Parent, [Child]) -> Result) -> Future<[Result]> where ParentID: Hashable & Encodable {
let parentIDs = parents.compactMap { $0[keyPath: idKey] }
let children = Child.query(on: conn)
@macabeus
macabeus / listClasses.swift
Last active November 13, 2023 23:21
List all classes that subscribe a protocol
// Many thanks to Code Different: http://stackoverflow.com/a/42749141/3440266
import Foundation
struct ClassInfo : CustomStringConvertible, Equatable {
let classObject: AnyClass
let classNameFull: String
let className: String
init?(_ classObject: AnyClass?) {
guard classObject != nil else { return nil }
//
// CollectionIndexView.swift
// Created by Ben Kreeger on 9/26/16.
//
import UIKit
@objc(BDKCollectionIndexView)
class CollectionIndexView: UIControl {
enum Direction {
@kevin-smets
kevin-smets / iterm2-solarized.md
Last active June 29, 2024 03:40
iTerm2 + Oh My Zsh + Solarized color scheme + Source Code Pro Powerline + Font Awesome + [Powerlevel10k] - (macOS)

Default

Default

Powerlevel10k

Powerlevel10k