Skip to content

Instantly share code, notes, and snippets.

@ajitid
ajitid / Tabs.tsx
Created August 10, 2021 10:57
Tabs component by cloning children
import React, { useState, useMemo } from 'react'
import css from './tabs.module.scss'
/*
usage
<Tabs>
<Tab label="one">
<OneContent />
@ajitid
ajitid / pewpew.js
Last active August 3, 2021 21:28
🔫 pewpew — a quick and cheap fuzzy matcher
function pewpew(text, query) {
const textLen = text.length
const queryLen = query.length
if (queryLen > textLen) return false;
if(queryLen === textLen) return query === text
let textIdx = 0;
let queryIdx = 0;
@ajitid
ajitid / s.fish
Created July 25, 2021 15:06
automate vim using neovim-remote
function jqdoprocessoneach
# https://stackoverflow.com/a/965106/7683365
set -l old_file_path $argv[1]
set -l new_filename $argv[2]"."(echo $argv[1] | sed 's/.*\.//')
echo $old_file_path
# echo $new_filename
# sleep 1
nvr --remote-send '<cmd>e '$old_file_path'<cr>'
sleep 1
@ajitid
ajitid / parseMdLinks.ts
Last active September 1, 2021 04:39
Parse Markdown links (not safe as its usage might create XSS attack vector)
@ajitid
ajitid / butt.fish
Last active July 29, 2021 14:24
🍑 Butt - Target a dir in PWD
function butt
if [ "$argv[1]" = "" ]
echo "Please provide a dir name"
return 1
end
set -l up_times 0
set -l found 0
set -l path (string sub --start 2 $PWD)
@ajitid
ajitid / readme.md
Last active September 26, 2024 08:59
Collection

A collection of interesting and useful things

Other repositories I've created

  • An extension to invoke Sublime Merge commands in VS Code
  • Goparsify - A parser cominator library that lets you parse text and give meaning to the items in it
  • Lastly - Get song link for various music streaming platforms using Last.fm
  • Live server on Python
  • My dotfiles
@ajitid
ajitid / Default.sublime-commands
Last active June 15, 2022 02:34
Get notification on Git push when using Windows CLIs/Sublime Merge/Fork
[
{
"caption": "Create an Empty Commit...",
"command": "git",
"args": { "argv": ["commit", "--allow-empty", "-m", "$text"] }
},
{
"caption": "Delete Remote Tag (origin)...",
"command": "git",
"args": { "argv": ["push", "--delete", "origin", "$text"] }
@ajitid
ajitid / readme.md
Last active July 22, 2024 16:24
Up — Go up till you get to a directory that contains the folder name that you've specified

Up

Go up till you get to a directory that contains the folder name that you've specified.

Usage

Using just up results in cd ...

If you have a dir structure like:

@ajitid
ajitid / check-type.ts
Last active June 1, 2021 20:53
validate string, number and object
export function isNumber(input: unknown): input is number {
return Number.isFinite(input);
}
export function isString(input: unknown): input is string {
return typeof input === 'string';
}
export function isObject(input: unknown): input is object {
return input !== null && typeof input === 'object';