Skip to content

Instantly share code, notes, and snippets.

View casademora's full-sized avatar

Saul Mora casademora

View GitHub Profile
@Rickyip
Rickyip / build-xcframework.sh
Created July 8, 2020 09:27 — forked from quangDecember/build-xcframework.sh
Build XCFramework (universal) framework, create new Aggregate target, add to New Run Script Phase
env > env.txt
instruments -s devices > devices.txt
#! /bin/sh -e
# This script demonstrates archive and create action on frameworks and libraries
# Based on script by @author Boris Bielik
# Release dir path
OUTPUT_DIR_PATH="${PROJECT_DIR}/XCFramework"
function archivePathSimulator {
@mecid
mecid / AnimatableVector.swift
Last active December 27, 2023 21:43
High-performance Animatable Vector for SwiftUI
import SwiftUI
import enum Accelerate.vDSP
struct AnimatableVector: VectorArithmetic {
static var zero = AnimatableVector(values: [0.0])
static func + (lhs: AnimatableVector, rhs: AnimatableVector) -> AnimatableVector {
let count = min(lhs.values.count, rhs.values.count)
return AnimatableVector(values: vDSP.add(lhs.values[0..<count], rhs.values[0..<count]))
}
@chriseidhof
chriseidhof / collectionview.swift
Last active January 31, 2024 19:00
SwiftUI Flow Layout
//
// ContentView.swift
// DeleteMe
//
// Created by Chris Eidhof on 02.02.21.
//
import SwiftUI
/*
@ole
ole / XCTExpectation.swift
Last active December 6, 2021 13:10
A variant of XCTKVOExpectation that works with native Swift key paths. To try it out, paste the code into an Xcode playground and observe the unit test output in the console. See my blog post at https://oleb.net/blog/2018/02/xctkvoexpectation-swift-keypaths/
import XCTest
/// An expectation that is fulfilled when a Key Value Observing (KVO) condition
/// is met. It's variant of `XCTKVOExpectation` with support for native Swift
/// key paths.
final class KVOExpectation: XCTestExpectation {
private var kvoToken: NSKeyValueObservation?
/// Creates an expectation that is fulfilled when a KVO change causes the
/// specified key path of the observed object to have an expected value.
@relaxdiego
relaxdiego / upload-github-release-asset.sh
Created July 4, 2017 18:22 — forked from stefanbuck/upload-github-release-asset.sh
Script to upload a release asset using the GitHub API v3.
#!/usr/bin/env bash
#
# Author: Stefan Buck
# https://gist.github.com/stefanbuck/ce788fee19ab6eb0b4447a85fc99f447
#
#
# This script accepts the following parameters:
#
# * owner
# * repo
@ChristianKienle
ChristianKienle / A_Promise.swift
Last active May 18, 2018 09:10
simplest Promise framework possible?
public struct Promise<T> {
typealias Fulfiller = (T) -> (Void)
typealias Rejecter = (Void) -> (Void)
typealias Resolver = (_ fulfill: @escaping Fulfiller, _ reject: @escaping Rejecter) -> (Void)
let resolver: Resolver
init(_ resolver: @escaping Resolver){
self.resolver = resolver
}
func then<U>(_ execute: @escaping ((T) -> U)) -> Promise<U> {
return Promise<U>({(fulfill, reject) in
@zwaldowski
zwaldowski / Activity.swift
Last active February 15, 2024 18:49
os_activity_t for Swift 3
//
// Activity.swift
//
// Created by Zachary Waldowski on 8/21/16.
// Copyright © 2016 Zachary Waldowski. Licensed under MIT.
//
import os.activity
private final class LegacyActivityContext {
@rnapier
rnapier / gist:b639da64d5890a0340d5
Last active October 26, 2015 20:50
Simple FFT example
import Accelerate
func spectrumForValues(signal: [Double]) -> [Double] {
// Find the largest power of two in our samples
let log2N = vDSP_Length(log2(Double(signal.count)))
let n = 1 << log2N
let fftLength = n / 2
// This is expensive; factor it out if you need to call this function a lot
let fftsetup = create_fftsetupD(log2N, FFTRadix(kFFTRadix2))
struct InputStreamGenerator : Generator {
var inputStream : NSInputStream
var chunkSize : Int
init(inputStream : NSInputStream, chunkSize : Int) {
self.inputStream = inputStream
self.chunkSize = chunkSize
}
#if DEBUG
/**
Toggles assertion of Core Data managed object contexts. Only available when DEBUG is defined.
When enabled, your application will throw an exception when accessing or modifying entities in a context other than their own.
*/
void TCBToggleAssertingContextQueues();
#endif