Skip to content

Instantly share code, notes, and snippets.

@lmiller1990
lmiller1990 / init.lua
Last active September 15, 2024 11:33
Neovim
vim.cmd("set expandtab")
vim.cmd("set number")
vim.cmd("set tabstop=2")
vim.cmd("set shiftwidth=2")
vim.cmd("set expandtab")
vim.g.mapleader = " "
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not (vim.uv or vim.loop).fs_stat(lazypath) then
local lazyrepo = "https://github.com/folke/lazy.nvim.git"
@lmiller1990
lmiller1990 / code.py
Last active August 12, 2024 11:24
Pandas / Python / R
import pandas as pd
import json
from camel_converter import to_snake
def read(jsonfile):
with open(jsonfile, "r") as f:
return json.loads(f.read())
@lmiller1990
lmiller1990 / week1.py
Created July 24, 2024 10:10
Binf7000
import random
standardTranslation = {
"TTT": "F",
"TCT": "S",
"TAT": "Y",
"TGT": "C",
"TTC": "F",
"TCC": "S",
"TAC": "Y",
@lmiller1990
lmiller1990 / content.md
Created January 30, 2024 21:39
Questions for Basarat

Congrats!

You had your 20K sub special 3 months ago. You are now at 141K. Holy smokes! The growth is exponential.

Congrats, well deserved. You are one of my favorite creators - I don't watch every video, only so many hours in a day, but I always have a good time when I do! I first found you via your TypeScript handbook, that was very useful, thanks!

On Content

Looking at your videos, some are hugely popular (50K+) and others are sub 1K. The algorithm is fickle. I do see many other creators getting much more consistent view counts. Any thoughts on this, what they might be doing different?

@lmiller1990
lmiller1990 / lib.es5.d.ts
Created January 29, 2024 10:58
awaited.ts
type Awaited<T> = T extends null | undefined ? T : // special case for `null | undefined` when not in `--strictNullChecks` mode
T extends object & { then(onfulfilled: infer F, ...args: infer _): any; } ? // `await` only unwraps object types with a callable `then`. Non-object types are not unwrapped
F extends ((value: infer V, ...args: infer _) => any) ? // if the argument to `then` is callable, extracts the first argument
Awaited<V> : // recursively unwrap the value
never : // the argument to `then` was not callable
T; // non-object or non-thenable
@lmiller1990
lmiller1990 / Form.vue
Created January 20, 2024 01:44
Vaildation
<template>
<input v-model="formData.name" />
<p v-if="!formStatus.name.valid">{{ formStatus.name.message }}</p>
</template>
<script setup lang="ts'>
const formData = reactive({
name
})
@lmiller1990
lmiller1990 / promise.js
Created November 24, 2023 20:51
Improved Solution
import pdefer from "https://unpkg.com/[email protected]/index.js";
/** @returns {Promise<Record<string, boolean>} */
async function fetchAllFeatures() {
console.log("Making network call...");
return new Promise((res, rej) => {
setTimeout(() => {
res({});
}, 500);
});
@lmiller1990
lmiller1990 / future.md
Created August 10, 2023 06:13
Integrate with the Stack

Component Testing Toolchain Mess

So for the last while (~10 years?) component tooling has been in a weird state, where it kind of "bolts on" to your app. Except once you start to do anything remotely complex (eg: in the real world, where you really want tools like Storybook, Jest, Cypress CT, whatever) things go off the rails, since "we integrate with your dev server and tooling" never seems to "just work".

Every year, a new layer of misdirection is added:

  • 2015: webpack, importing non JS assets (like import './style.css')
  • 2016: JSX, .vue file, babel, now we can live in the future RIGHT NOW
  • 2017: TypeScript, and of course, TSX
  • 2018: Jest gains popularity. It does NOT work with webpack, now you need *-jest-preprocessor
@lmiller1990
lmiller1990 / conditionalCypress.js
Created June 26, 2023 02:05
Cypress Conditional Runs
before(() => {
const isHeadless = Cypress.config('isTextTerminal')
if (isHeadless) {
// do something
}
})
// Or ...
@lmiller1990
lmiller1990 / README.md
Created December 20, 2022 01:01
What is the Composition API

What is an API?

An API, or Application Programming Interface, is how a programmer communicates their intent to a system.

Vue and React are systems. They take some data and produce an interstitate representation (a Virtual DOM, but this could change - it's an implementation detail).

When some data changes, the Virtual DOM is updated, and based on the changes, the real DOM is then updated to reflect the changed data.

Options API, Class Components