Skip to content

Instantly share code, notes, and snippets.

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

Tanishq Kancharla tanishqkancharla

🏠
Working from home
View GitHub Profile

description: | The Librarian - a specialized research agent for understanding external resources like GitHub repositories and documentation websites.

The Librarian has access to: bash (for gh CLI), read_web_page, and web_search. It is read-only and cannot modify local files.

Use the Librarian to study APIs, library implementations, and external documentation before implementing features or integrations.

WHEN TO USE:

@tanishqkancharla
tanishqkancharla / bash-preprocessor.ts
Created January 4, 2026 21:37
OpenCode plugin: Bash preprocessor that converts absolute paths to relative paths
import type { Plugin } from "@opencode-ai/plugin";
export const BashPreprocessor: Plugin = async ({ directory }) => {
const repoPath = directory;
return {
"tool.execute.before": async (input, output) => {
if (input.tool === "bash" && output.args?.command) {
let command = output.args.command as string;
@tanishqkancharla
tanishqkancharla / drizzle_rls.ts
Created December 3, 2025 18:56
Drizzle ORM Multi-Tenant RLS Wrapper
type DrizzleClient = NodePgDatabase<typeof schema>;
export type Transaction = Parameters<
Parameters<DrizzleClient["transaction"]>[0]
>[0];
type PathSegment =
| { type: "get"; prop: PropertyKey }
| { type: "call"; args: unknown[] };
@tanishqkancharla
tanishqkancharla / logger.ts
Created July 6, 2025 18:14
ORPC Logging Middleware
const loggerMiddleware = os
.$context<{ req: Request }>()
.middleware(async ({ context, next, path }) => {
const start = Date.now();
const method = context.req.method;
const pathname = `/${path.join("/")}`;
try {
const result = await next({});
const duration = Date.now() - start;
@tanishqkancharla
tanishqkancharla / IndexedDbAdapter.ts
Created July 2, 2025 22:04
IndexedDb storage adapter for tuple-db
import { Codec } from "@repo/utils/codec";
import { deleteDB, IDBPDatabase, openDB } from "idb";
import { KeyValuePair, ScanStorageArgs, WriteOps } from "tuple-database";
import { decodeTuple, encodeTuple } from "tuple-database/helpers/codec";
import { AnySchema, Json, StorageApi } from "../types";
const version = 1;
const storeName = "tupledb";
@tanishqkancharla
tanishqkancharla / logger.ts
Created July 1, 2025 01:02
ORPC Logging Plugin
import { Context, ORPCError } from "@orpc/server";
import type {
StandardHandlerOptions,
StandardHandlerPlugin,
} from "@orpc/server/standard";
function formatNow() {
return new Date().toLocaleDateString("en-US", {
month: "short",
day: "numeric",
class ExpoSqliteTupleStorageApi implements AsyncTupleStorageApi {
private db = SQLite.openDatabase("app.db");
constructor() {}
async prepare() {
await this.db.execAsync(
[
{
sql: `
@tanishqkancharla
tanishqkancharla / localDb.ts
Created March 12, 2024 04:20
Tuple-db ORM
import { isFunction, isSymbol } from "lodash-es";
import type {
KeyValuePair,
ReadOnlyTupleDatabaseClientApi,
TupleTransactionApi,
} from "tuple-database";
import {
InMemoryTupleStorage,
TupleDatabase,
TupleDatabaseClient,
@tanishqkancharla
tanishqkancharla / AnimatePresence.tsx
Last active January 16, 2024 04:01
AnimatePresence in React Native
import { unionBy } from "lodash-es";
import React, { ReactElement, useEffect, useState } from "react";
import { Animated, useAnimatedValue } from "react-native";
function diffBy<T>(a: T[], b: T[], key: keyof T) {
const aKeys = a.map((item) => item[key]);
const bKeys = b.map((item) => item[key]);
const added = b.filter((item) => !aKeys.includes(item[key]));
const removed = a.filter((item) => !bKeys.includes(item[key]));