Skip to content

Instantly share code, notes, and snippets.

View carson-katri's full-sized avatar

Carson Katri carson-katri

View GitHub Profile
@carson-katri
carson-katri / tailwind_styles.ex
Last active March 7, 2024 14:31
Tailwind-style class names for LiveView Native
defmodule TailwindStyles do
use LiveViewNative.Stylesheet, :swiftui
@modifier_names ["accessibilityAction","accessibilityActions","accessibilityChildren","accessibilityIgnoresInvertColors","accessibilityRepresentation","accessibilityShowsLargeContentViewer","alert","allowsHitTesting","allowsTightening","animation","aspectRatio","autocorrectionDisabled","background","backgroundStyle","badge","baselineOffset","blendMode","blur","bold","border","brightness","buttonBorderShape","buttonStyle","clipShape","clipped","colorInvert","colorMultiply","compositingGroup","confirmationDialog","containerRelativeFrame","containerShape","contentShape","contentTransition","contextMenu","contrast","controlGroupStyle","controlSize","coordinateSpace","datePickerStyle","defaultScrollAnchor","defaultWheelPickerItemHeight","defersSystemGestures","deleteDisabled","dialogSuppressionToggle","digitalCrownAccessory","disabled","drawingGroup","dynamicTypeSize","fileDialogCustomizationID","fileDialogImportsUnresolvedAliases","findDisab
@carson-katri
carson-katri / modifier_schema_gen.exs
Last active April 6, 2023 20:24
Generates a LiveViewNative modifier schema
Mix.install([
{:req, "~> 0.3.6"},
{:inflex, "~> 2.0.0"}
])
defmodule EnumParser do
defstruct name: nil,
stack: []
def push(state, token, opts \\ []) do
CONVERTED_MODEL_PATH = "path to converted v2 depth model"
DEVICE = "cuda"
INIT_IMAGE = "path to init image or None"
DEPTH_IMAGE = "path to black and white depth map"
OUTPUT_PATH = "path to save the result"
import diffusers
from diffusers.pipelines.stable_diffusion import StableDiffusionPipelineOutput
import torch
@carson-katri
carson-katri / cloth.py
Created December 1, 2022 13:18
Verlet integration in Geometry Script
from geometry_script import *
# Constants
SAMPLES = 3
# Inputs
class ClothInputs(InputGroup):
gravity: Vector = (0, 0, -0.5)
friction: Vector = (0.999, 0.999, 0.999)
stick_length: Float = 0.1
@carson-katri
carson-katri / wrapper_types.ts
Last active August 16, 2021 20:09
Wrapper types experiment in Wren
import "mirror" for Mirror, ClassMirror, MethodMirror
import "meta" for Meta
class Wrapper {
static operators { ["-","!","~","*","/","+","..","...","<<",">>","&","^","|","<","<=",">",">=","is","==","!="] }
static generate(wrappedType, innerBody) {
var s = "class %(wrappedType)_ {\n"
s = s + " wrappedValue { _wrappedValue }\n"
s = s + " construct wrap(wrappedValue) {\n"
s = s + " _wrappedValue = wrappedValue\n"
@carson-katri
carson-katri / View+badge.swift
Created January 21, 2021 16:21
Adds an `overlay` to a `View` that aligns the middle of the overlay with the edge of the parent, like a badge.
extension View {
func badge<Badge: View>(_ badge: Badge, alignment: Alignment = .topTrailing) -> some View {
overlay(
badge
.alignmentGuide(.leading, computeValue: splitDimension(\.width))
.alignmentGuide(HorizontalAlignment.center, computeValue: splitDimension(\.width))
.alignmentGuide(.trailing, computeValue: splitDimension(\.width))
.alignmentGuide(.top, computeValue: splitDimension(\.height))
.alignmentGuide(VerticalAlignment.center, computeValue: splitDimension(\.height))
.alignmentGuide(.bottom, computeValue: splitDimension(\.height)),
import SwiftUI
import Combine
import PlaygroundSupport
struct SpringSolver {
let ƛ: CGFloat
let w0: CGFloat
let wd: CGFloat
/// Initial velocity
let v0: CGFloat

Copyright <YEAR> <COPYRIGHT HOLDER>

Permission is hereby granted, free of charge, to any person obtaining a copy of this bad software and associated poor documentation files (the "Bad Software"), to deal in the Bad Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Bad Software, and to permit persons to whom the Bad Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Bad Software.

THE BAD SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES, CODE QUALITY OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,

struct CardHeading: View {
@State private var touchZoom: Bool = false
var body: some View {
VStack(spacing: 0) {
Image("banner")
.resizable()
.aspectRatio(contentMode: ContentMode.fill)
.frame(minWidth: 0, maxWidth: .infinity, maxHeight: 400)
.clipped()
@carson-katri
carson-katri / playgrounds.json
Last active October 5, 2019 20:15
My Playground Book Subscription
{
"title": "Carson Katri's Blog",
"subtitle": "Playground Books based on the articles on \"carsonkatri.com\"",
"publisherName": "Carson Katri",
"feedIdentifier": "com.carsonkatri.playgrounds",
"contactURL": "mailto:carson.katri@gmail.com",
"formatVersion": "1.0",
"documents": [
{
"title": "Make a Function Builder",