This file contains 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
// Bigger iPhones = any Max, any Plus, iPhone XR, iPhone 11 | |
switch (UITraitCollection.current.horizontalSizeClass, UITraitCollection.current.verticalSizeClass) { | |
case (.compact, .compact): | |
// Smaller iPhones in landscape | |
case (.compact, .regular): | |
// iPhones in portrait | |
// iPads in portrait during any split screen, |
This file contains 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
Workaround for threads.js on Webpack5 |
This file contains 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 getTileFromLatLon(zoom, lat, lon) { | |
const width = Math.pow(2, zoom); | |
const height = Math.pow(2, zoom); | |
const latRad = (lat * Math.PI) / 180; | |
const x = ~~((width * (lon + 180)) / 360); | |
const y = ~~(((1 - Math.asinh(Math.tan(latRad)) / Math.PI) / 2.0) * height); | |
return {zoom, x, y}; | |
} |
This file contains 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
// A URLSession extension that fetches data from a URL and decodes to some Decodable type. | |
// Usage: let user = try await URLSession.shared.decode(UserData.self, from: someURL) | |
// Note: this requires Swift 5.5. | |
extension URLSession { | |
func decode<T: Decodable>( | |
_ type: T.Type = T.self, | |
from url: URL, | |
keyDecodingStrategy: JSONDecoder.KeyDecodingStrategy = .useDefaultKeys, | |
dataDecodingStrategy: JSONDecoder.DataDecodingStrategy = .deferredToData, | |
dateDecodingStrategy: JSONDecoder.DateDecodingStrategy = .deferredToDate |
This file contains 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 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])) | |
} |
This file contains 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
global.THREE = require("three"); | |
const canvasSketch = require('canvas-sketch'); | |
const Random = require('canvas-sketch-util/random'); | |
const gradientHeight = 512; | |
const settings = { | |
dimensions: [ 2048, gradientHeight * 2 ] | |
}; |
This file contains 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
int[][] result; | |
float t, c; | |
float ease(float p) { | |
return 3*p*p - 2*p*p*p; | |
} | |
float ease(float p, float g) { | |
if (p < 0.5) | |
return 0.5 * pow(2*p, g); |
This file contains 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 * as React from "react" | |
import { Override, Data, useTransform, motionValue } from "framer" | |
const x = motionValue(0) | |
export function Card(props): Override { | |
const rotate = useTransform(x, [-100, 100], [-20, 20]) | |
return { | |
rotate, | |
x, |
This file contains 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
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 { |
This file contains 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
// | |
// ContentView.swift | |
// SwiftTalkAnimationLoader | |
// | |
// Created by Chris Eidhof on 30.07.19. | |
// Copyright © 2019 Chris Eidhof. All rights reserved. | |
// | |
import SwiftUI |
NewerOlder