Skip to content

Instantly share code, notes, and snippets.

@lmiller1990
lmiller1990 / ESM.md
Created July 11, 2022 11:23
ES Modules

React 18 Support

React 18 has changed their mounting API ever so slightly:

// Before
import { render } from 'react-dom';
const container = document.getElementById('app');
render(<App />, container);
@lmiller1990
lmiller1990 / README.md
Created April 22, 2022 04:23
VTU-2.0.0.md
# open new terminal in same pwd
preexec () {
local WD="$(pwd | sed "s/^\/home\/$USER/~/")"
export LASTDATE="`date +%T`"
if [[ "$TERM" == "rxvt-unicode" || "$TERM" == "rxvt-unicode-256color" ]]; then
export COMMAND="$(echo $1 | tr -d '\n')"
echo -ne "\e]0;$LOCALNAME $HOST:$WD$ $COMMAND ($LASTDATE)\a"
fi
}
@lmiller1990
lmiller1990 / remote.md
Created February 28, 2022 13:58
Remote

Hi! I have tons of experience here (working for EU/US companies from remotely, in my case Australia).

Regarding relocation, the US is basically impossible. I come from a fairly favourable country and even as an experienced developer with a willing sponsor it's still nearly impossible to get a working visa, there's a limited amount and no reliable way to get one, even for huge companies with tons of money.

My brother went through this a while ago (skilled employment visa to the US) and it cost tens of thousands of dollars and literally years. I've gotten a visa for another country and it was a similarly convoluted process, you generally can't apply for them until you have a sponsor lined up, which means you need the job first.

I am not sure about the EU, I'm guessing there is some countries who have more lax visa requirements, but I've heard it's equally hard. That said, unless you are exceptional (aka, better than local talent), it's incredibly hard to convince any employer to jump through all the hoo

@lmiller1990
lmiller1990 / file.ts
Created November 26, 2021 23:20
Composables
// not composable
// just a function or 'business logic'
function add (n1, n2) {
return n1 + n2
}
// composable
// "bridges" logic and Vue via reactivity
useAdd (_n1 = 0, _n2 = 0) {
const n1 = ref(n1)
@lmiller1990
lmiller1990 / README.md
Created November 5, 2021 12:16
Vite library mode
yarn create vite my-comp --template vue-ts
cd my-comp
yarn install
# add main.js and vite.config.ts below
yarn build vite
/** article: https://lachlan-miller.me/articles/patterns-for-testing-props */
props: {
variant: {
type: String,
required: true,
validator: (variant) => {
if (!['success', 'warning', 'error'].includes(variant)) {
throw Error(
`variant is required and must` +
@lmiller1990
lmiller1990 / store.ts
Last active September 27, 2023 08:08
typesafe-store.ts
import { reactive } from 'vue';
type Method = (...args: any[]) => any
type StoreWithState<S extends StateTree> = {
state: S
}
type StoreWithActions<A> = {
[k in keyof A]: A[k] extends (...args: infer P) => infer R
@lmiller1990
lmiller1990 / mount.js
Last active April 23, 2021 02:26
mount.js
// test utils v1
import { mount as testUtilsMount, createLocalVue } from '@vue/test-utils'
import Vuex from 'vuex'
// some function to create a new Vuex store with your state/mutations etc
// you want a fresh one for each test
import { createMyVuexStore } from './vuex-store'
export function mount(comp, options = {}, store) {
const localVue = createLocalVue()
@lmiller1990
lmiller1990 / index.html
Created April 15, 2021 15:36
Vanilla FLIP Sundae
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
<link href="https://unpkg.com/tailwindcss@^2/dist/tailwind.min.css" rel="stylesheet">
</head>
<body class="m-4">
<button class="bg-gray-300 my-2 px-4 py-2 rounded-md" onclick="flip()">Flip</button>