Skip to content

Instantly share code, notes, and snippets.

View u10int's full-sized avatar

Nicholas Shipes u10int

View GitHub Profile
// 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,
@BenHeartfield
BenHeartfield / Workaround for threads.js on Webpack5
Last active February 12, 2022 21:50
Workaround for threads.js on Webpack5
Workaround for threads.js on Webpack5
@spite
spite / gist:051604efd1d971ab4b6ef1bc1ae2636e
Created June 15, 2021 23:47
zoom - lat -lon to mapzen/tilezen tile
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};
}
// 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
@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]))
}
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 ]
};
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);
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,
@quangDecember
quangDecember / build-xcframework.sh
Last active February 19, 2024 10:05
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 {
//
// ContentView.swift
// SwiftTalkAnimationLoader
//
// Created by Chris Eidhof on 30.07.19.
// Copyright © 2019 Chris Eidhof. All rights reserved.
//
import SwiftUI