Skip to content

Instantly share code, notes, and snippets.

View turbotobias's full-sized avatar

Tobias Goulden Schultz turbotobias

View GitHub Profile
@turbotobias
turbotobias / .zshrc
Created June 7, 2023 23:03
Change directory to many parents shorthand
# change directory to any parent
# instead of writing "cd ../" you can write:
# $ u
# instead of writing "cd ../../" you can write:
# $ u 2
# instead of writing "cd ../../../../../../../../../../" you can write:
# $ u 10
@turbotobias
turbotobias / @result.ts
Last active March 23, 2023 01:48
Rust Result in Typescript
export type Result<T, E = undefined> = { ok: true; value: T } | { ok: false; error: E | undefined }
export const Ok = <T>(data: T): Result<T, never> => ({ ok: true, value: data })
export const Err = <E>(error?: E): Result<never, E> => ({ ok: false, error })
@turbotobias
turbotobias / kill-ports.sh
Created March 7, 2023 03:17
Command to kill multiple ports from the terminal
#!/bin/bash
# To kill http://localhost:3333, http://localhost:8080, http://localhost:5000, etc.
# Run `$ kill-ports.sh 3333 8080 5000`
for port in "$@"; do
lsof -ti tcp:"$port" | xargs kill
done
@turbotobias
turbotobias / delete_node_modules.sh
Created February 7, 2023 05:48
Delete all node_modules from sub-folders in a directory
#!/bin/bash
# Here is a shell script that deletes the node_modules folder from each folder found in the current working directory:
# Deletes one level down, no recursion
# Run this to allow deletion:
# $ chmod +x./delete_node_modules.sh
# Run this to delete:
# $ ./delete_node_modules.sh
@keyframes border-dance {
0% {
background-position: left top, right bottom, left bottom, right top;
}
100% {
background-position: left 15px top, right 15px bottom, left bottom 15px,
right top 15px;
}
}
// you might have to do something in webpack to enable wasm/photon
import initPhoton, {
resize as photon__resize,
open_image as photon__open_image,
putImageData as photon__put_image_data,
} from "photon-web"
const image = ref<HTMLImageElement>()
const imageUpload = ref<HTMLInputElement>()
const storageImageUrl = ref("")
import { round } from ".."
/**
* @example
*
* ```ts
* const fees = new PaymentAmount(1000)
* fees.getAmountToUser() // === 976.66
* fees.getAmountToStripe() // === 21
* ```
@turbotobias
turbotobias / App.vue
Created October 16, 2021 07:59
Pinia store handler for timing actions runtime
<script>
import { useStore } from './store'
import { storeActionTimer } from './helpers'
const store = useStore()
store.$onAction(storeActionTimer)
</script>
const arr = [8, 2, 5, 3, 0]
arr.sort((a, b) => {
// -1 sorts up
if (a > b) return -1
// 1 sorts down
else if (a < b) return 1
// use con.log("poop") to console.log "poop" in development
// or con.stagingLog("poop") to console.log "poop" in staging
// or con.prodLog("poop") to console.log "poop" in production
export default {
isDev() {
return process.env.NODE_ENV === "development"
},
isStaging() {
return process.env.NODE_ENV === "staging"