Skip to content

Instantly share code, notes, and snippets.

View saiashirwad's full-sized avatar
🏠
Working from home

texoport saiashirwad

🏠
Working from home
View GitHub Profile
Objective: To collaboratively build an extensive and deep understanding of a topic, project, problem, or any subject you wish to explore, starting with minimal initial information.
Your Role (LLM): Act as an Expert Inquisitor and Context Synthesizer. Your primary function is not to provide answers initially, but to ask insightful, targeted questions to systematically elicit all necessary information from me (the user). You are building a comprehensive knowledge base about the subject, piece by piece, driven by your questions.
Process:

Let me try a completely different approach then. Let's bypass Conform and use Neovim's built-in functions to run a formatter directly on the TypeScript code:

vim.api.nvim_create_user_command('FormatTSMarkdown', function()
  -- Save cursor position
  local cursor_pos = vim.api.nvim_win_get_cursor(0)
  local bufnr = vim.api.nvim_get_current_buf()
  
  -- Find TypeScript code blocks
  local lines = vim.api.nvim_buf_get_lines(bufnr, 0, -1, false)
-- Function to collect all diagnostic errors and copy them to clipboard
local function copy_errors_to_clipboard()
-- Get the current buffer number
local current_buf = vim.api.nvim_get_current_buf()
-- Get all diagnostics for the current buffer
local diagnostics = vim.diagnostic.get(current_buf)
-- Format each diagnostic into readable lines
local lines = {}
#!/usr/bin/env bun
import { access, mkdir, readdir, stat } from "node:fs/promises";
import { basename, dirname, extname, join, relative } from "node:path";
// ========================================
// Global Configuration
// Edit these values instead of passing command line args
// ========================================
const DEFAULT_CONFIG: SiteConfig = {
contentDir: './content',
@saiashirwad
saiashirwad / signals.ts
Created February 14, 2025 20:56
ez signals in ts
let activeEffect: (() => void) | null = null;
export function signal<T>(initialValue: T) {
let value = initialValue;
const subscribers = new Set<() => void>();
return {
get(): T {
if (activeEffect) {
subscribers.add(activeEffect);
@saiashirwad
saiashirwad / example.ts
Created February 1, 2025 13:54
webstorm typescript tuple arithmetic
type buildTuple<
n extends number,
acc extends any[] = [],
> = acc["length"] extends n ? acc : buildTuple<n, [...acc, 0]>;
type add<a extends number, b extends number> = [
...buildTuple<a>,
...buildTuple<b>,
]["length"] &
number;
@saiashirwad
saiashirwad / finger_tree.ts
Created January 25, 2025 19:25
a finger tree in type level ts :)
type buildTuple<L extends number, T extends any[] = []> = T["length"] extends L
? T
: buildTuple<L, [...T, unknown]>;
type addTuple<A extends unknown[], B extends unknown[]> = [
...A,
...B,
]["length"] &
number;
type subTuple<A extends unknown[], B extends unknown[]> = A extends [
@saiashirwad
saiashirwad / prisma-codegen.ts
Created January 16, 2025 09:47
cursed prisma codegen
import ts from "typescript";
import {
Parser,
alphabet,
char,
digit,
many0,
many1,
optional,
or,
@saiashirwad
saiashirwad / hkt.ts
Last active January 9, 2025 10:30
minimal hkt in ts
export type Fn = (...x: never[]) => unknown
export declare const _: unique symbol
export type _ = typeof _
export declare abstract class Kind<F extends Fn = Fn> {
abstract readonly [_]: unknown
f: F
}
@saiashirwad
saiashirwad / prisma-to-effect-schema-complete.ts
Last active March 19, 2025 03:02
A prisma -> effect schema codegen script for a very opinionated setup using the parserator library
// this is incredibly hacky, but it works great for me
// for this to work, i have a file called json-types.ts that contains a bunch of exported interfaces, one for each of
// the tables i have that have any JSON fields. json-types.ts should only have Effect Schema imports, like so:
// import { Schema1 } from '../../somewhere'
// import ...
// %
// ^ that is essential lol. that tells the script that the imports section is over