Skip to content

Instantly share code, notes, and snippets.

View C-Sinclair's full-sized avatar
😎

Conor Sinclair C-Sinclair

😎
View GitHub Profile
defmodule LiveViewDynamicFormIssue do
@moduledoc """
Reproduction of a LiveView issue with dynamic nested forms
Try adding 2 items to the list, you aren't able to remove the first one
Try adding a 3rd item, you can remove the first one now. But then once again you can't remove the first one!
"""
use Phoenix.Component
def mount(_, _, socket) do
socket =
TypeScript 4 hrs 40 mins ███████████░░░░░░░░░░ 52.8%
Python 2 hrs 10 mins █████▏░░░░░░░░░░░░░░░ 24.5%
Lua 1 hr 4 mins ██▌░░░░░░░░░░░░░░░░░░ 12.2%
YAML 24 mins ▉░░░░░░░░░░░░░░░░░░░░ 4.6%
conf 6 mins ▎░░░░░░░░░░░░░░░░░░░░ 1.2%
@C-Sinclair
C-Sinclair / useZodls.ts
Created July 27, 2022 11:19
Zod typesafe localstorage hook
import { useCallback, useState } from "react";
import { z, ZodType } from "zod";
type Value<S extends ZodType> = z.infer<S>;
type ValueSetter<S extends ZodType> = (currentValue: Value<S>) => void;
type UseZodls<S extends ZodType> = [
/**
* The current value of the data from local storage
* Will default to the defaultValue if not found in local storage
@C-Sinclair
C-Sinclair / kitty.conf
Created March 21, 2021 22:07
My kitty config
# vim:fileencoding=utf-8:ft=conf:foldmethod=marker
#: Fonts {{{
#: kitty has very powerful font management. You can configure
#: individual font faces and even specify special fonts for particular
#: characters.
font_family FiraCode # monospace
bold_font auto
@C-Sinclair
C-Sinclair / init.vim
Last active February 16, 2021 13:49
My holy nvim config
let mapleader =";"
if ! filereadable(system('echo -n "${XDG_CONFIG_HOME:-$HOME/.config}/nvim/autoload/plug.vim"'))
echo "Downloading junegunn/vim-plug to manage plugins..."
silent !mkdir -p ${XDG_CONFIG_HOME:-$HOME/.config}/nvim/autoload/
silent !curl "https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim" > ${XDG_CONFIG_HOME:-$HOME/.config}/nvim/autoload/plug.vim
autocmd VimEnter * PlugInstall
endif
call plug#begin(system('echo -n "${XDG_CONFIG_HOME:-$HOME/.config}/nvim/plugged"'))
@C-Sinclair
C-Sinclair / main.js
Created February 11, 2021 14:30
Adding aliases to Storybook's webpack config
const path = require("path");
module.exports = {
stories: [
// "../stories/**/*.stories.mdx",
// "../**/**/*.stories.@(js|jsx|ts|tsx)",
"../components/**/*.stories.tsx",
],
addons: [
"@storybook/addon-links",
@C-Sinclair
C-Sinclair / shortcutrc
Created February 9, 2021 22:26
My Shortcutrc config
export NVIM_CONFIG=$HOME/.config/nvim/init.vim
export ZSH_CONFIG=$HOME/.config/zsh/zshrc
export TT=$HOME/Repos/TalentTicker
export CS=$HOME/Repos/C-Sinclair
@C-Sinclair
C-Sinclair / aliasrc
Created February 9, 2021 22:25
My Aliasrc config
alias v=nvim
alias nvimrc="v $NVIM_CONFIG"
alias zshrc="v $ZSH_CONFIG"
@C-Sinclair
C-Sinclair / zshrc
Created February 9, 2021 19:41
My Zsh config
autoload -U colors && colors
setopt autocd # Automatically cd into typed directory.
stty stop undef # Disable ctrl-s to freeze terminal.
# History in cache directory:
HISTSIZE=10000
SAVEHIST=10000
HISTFILE=~/.cache/zsh/history
setopt SHARE_HISTORY
@C-Sinclair
C-Sinclair / alacritty.yml
Created February 9, 2021 19:39
My Alacritty config
window:
padding:
x: 20
y: 10
decorations: "none"
live_config_reload: true