Skip to content

Instantly share code, notes, and snippets.

@all12jus
all12jus / AspectRatioModifier.swift
Created February 22, 2024 16:34
AspectRatioModifier
public extension View {
func aspectRatioControlled(_ ratio: CGFloat) -> some View {
modifier(AspectRatioModifier(aspectRatio: ratio))
}
}
// https://gist.github.com/Priva28/53abcdef7de6633d776cb169c96ce014
struct AspectRatioModifier: ViewModifier {
var aspectRatio: CGFloat
@State private var setSize: CGSize?
@all12jus
all12jus / TestMoney
Last active October 11, 2022 02:37
Number only
//
// TestMoney.swift
// FormButtonTest
//
// Created by Justin Allen on 10/10/22.
//
import SwiftUI
extension String {
@all12jus
all12jus / SampleIconChanger
Created October 6, 2022 02:07
SampleIconChanger
//
// ContentView.swift
// SampleIconChanger
//
// Created by Justin Allen on 10/5/22.
//
import SwiftUI
@all12jus
all12jus / Vehicle.ts
Created August 13, 2022 22:07
Vehicle.ts
/// npx ts-node src/foo.ts
// npm install -g ts-node typescript '@types/node'
// ts-node typescript-file.ts
import express from 'express';
import bodyParser from 'body-parser';
import mongoose, {ConnectOptions} from 'mongoose';
const app = express();
@all12jus
all12jus / gist:1cad7c0828f5185afca546ad76a67985
Created September 5, 2021 12:21
getCartFromLocalStorage -- React
const LocalStorageCartKey = "CartList";
const getCartFromLocalStorage = () => {
try {
let items = JSON.parse(localStorage.getItem(LocalStorageCartKey));
if (items === null || items === undefined)
{
return [];
}
return items;
} catch (e) {
class ToggleSwitch extends HTMLElement {
currentR = 0;
currentG = 0;
currentB = 0;
lerp (start, end, amt){
return (1-amt)*start+amt*end;
}
createCapsule(ctx, point1, point2, radius){
@all12jus
all12jus / gist:964c7f205687764ce1b51f6ae2ed53c4
Created August 12, 2021 02:36
Rough Draft 1 of Toggle-Switch Custom Element
customElements.define('toggle-switch', class extends HTMLElement {
lerp (start, end, amt){
return (1-amt)*start+amt*end;
}
currentX = 0;
value = true;
//
// ConstraintUtils.swift
//
// Created by Justin Allen on 8/15/19.
// Updated on 1/30/20
// Copyright © 2019 Justin Allen. All rights reserved.
//
import UIKit
//
// AdView.swift
// pdfsRebooks
//
// Created by Justin Allen on 1/17/20.
// Copyright © 2020 Justin Allen. All rights reserved.
//
/*
const initApp = () => {
const print = () => {
console.log(num);
};
var num = 0;
const increament = () => {
num++;
};
return {
value: num,