Skip to content

Instantly share code, notes, and snippets.

@ajitid
ajitid / load-script.js
Last active April 27, 2023 05:29
Load scripts in Chrome by putting this in DevTools > Sources > Snippets
'use script'
function loadScript(filePath, cacheBuster = `?bust=${new Date().getTime()}`) {
const scriptTag = document.createElement('script');
scriptTag.onload = () => console.log('loaded');
scriptTag.type = 'text/javascript';
scriptTag.src = `${filePath}${cacheBuster}`;
document.querySelector('head').appendChild(scriptTag);
}
@ajitid
ajitid / kitty-emoji-wsl2.md
Last active March 19, 2021 06:57
Emoji font for kitty in WSL2
sudo apt install fonts-noto-color-emoji

For themes, use https://github.com/adi1090x/kitty-cat. This modifies config a lot so do this first before applying any kitty config. Mostly it changes font properties and margin.

@ajitid
ajitid / .wslconfig
Last active April 28, 2025 07:29
Run GUI applications in WSL1
# C:/Users/zlksnk/.wslconfig
# [wsl2]
# kernel=<path> # An absolute Windows path to a custom Linux kernel.
# memory=<size> # How much memory to assign to the WSL2 VM.
# processors=<number> # How many processors to assign to the WSL2 VM.
# swap=<size> # How much swap space to add to the WSL2 VM. 0 for no swap file.
# swapFile=<path> # An absolute Windows path to the swap vhd.
# localhostForwarding=<bool> # Boolean specifying if ports bound to wildcard or localhost in the WSL2 VM should be connectable from the host via localhost:port (default true).
{
"React useState": {
"scope": "javascript,typescript,typescriptreact",
"prefix": "rus",
"body": "const [${1}, set${1/(.*)/${1:/capitalize}/}] = useState(${3})",
"description": "Create a React useState hook"
},
"React import": {
"scope": "javascript,typescript,typescriptreact",
"prefix": "imr",
type ValueType<
S extends string,
R extends Record<string, any>
> = S extends `${infer T}.${infer U}` ? ValueType<U, R[T]> : R[S];
export type Dotted<
S extends string,
R extends Record<string, any>
> = ValueType<S, R> extends infer A
? unknown extends A
@ajitid
ajitid / config.fish
Created October 17, 2020 12:38
fish config
export PATH="$PATH:/home/frefko/Downloads/platform-tools"
export PATH="/mnt/Media/proj/installed/jdk1.8.0_144/bin:$PATH"
export PATH="$HOME/.local/bin:$PATH"
export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
pyenv init - | source
@ajitid
ajitid / AliveAbleRoutes.tsx
Last active January 12, 2023 15:36
Keep alive routes
import React, { ReactElement, useState, useLayoutEffect } from 'react';
import { Routes, Route } from 'react-router-dom';
import type { RoutesProps, RouteProps } from 'react-router';
const AliveAbleRoutes = ({ children, ...props }: RoutesProps) => {
const routes = React.Children.toArray(children);
const keepAliveRoutes = routes.filter((route) => {
if (!React.isValidElement(route)) return false;
return route.type === KeepAliveRoute;
@ajitid
ajitid / README.md
Last active March 30, 2022 20:41
Restores scroll in React app

Uses a feature of React Router v6 internally to have more flexibility over naming of the keys.

Needs two params:

  • A key to uniquely identify the list in the page
  • A reference to list's HTML element

Inspired by a hook used in Remix. (Watch this video)

@ajitid
ajitid / README.md
Last active September 18, 2020 19:40
Scrollable content