Skip to content

Instantly share code, notes, and snippets.

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

Prasham Trivedi PrashamTrivedi

🏠
Working from home
View GitHub Profile
@PrashamTrivedi
PrashamTrivedi / .tmux.conf
Created July 18, 2025 18:01
Local Setup File
# easy reload config
bind-key r source-file ~/.tmux.conf \; display-message "~/.tmux.conf reloaded."
set -g default-terminal "screen-256color"
# set window split
bind-key v split-window -h
bind-key h split-window
bind-key q confirm-before -p "kill-session #S? (y/n)" kill-session
@PrashamTrivedi
PrashamTrivedi / file_agent_mcp_server.py
Last active July 13, 2025 10:38
Improved MCP File Agent Server - FastMCP implementation with structured output for AI assistant symlink management
#!/usr/bin/env -S uv run
# /// script
# requires-python = ">=3.11"
# dependencies = [
# "mcp>=1.0.0",
# "pydantic>=2.5.0",
# "typer>=0.9.0",
# ]
# ///
@PrashamTrivedi
PrashamTrivedi / workspaceManager.ts
Created March 13, 2025 08:26
Workspace Manager for VS Code - A web interface to manage workspace files
#!/usr/bin/env -S deno run -A
/*
Workspace Manager Web Interface
This script creates a web server that provides a UI for managing VS Code workspace files.
Features:
- Enable/disable workspace folders
- Add new folders with automatic TypeScript project detection
- Configure server port via environment variable or command line argument
@PrashamTrivedi
PrashamTrivedi / denoScriptGenerator.ts
Last active November 15, 2024 10:56
Deno script generator using anthropic
#!/usr/bin/env -S deno run -A
import { ensureFileSync } from "https://deno.land/[email protected]/fs/mod.ts";
import { parseArgs } from "jsr:@std/cli/parse-args";
import { Anthropic } from "npm:@anthropic-ai/sdk";
import * as log from "jsr:@std/log";
import { extname } from "jsr:@std/path";
import { TextBlock } from "npm:@anthropic-ai/sdk";
const aiPrompt = `
@PrashamTrivedi
PrashamTrivedi / React-Redux.md
Created July 3, 2018 06:10
My notes on React redux and it's usages

Redux

  • Redux is a library that manages states. Based on functional principals it solves a problem of data flow in an interesting way.
  • In an app your data should have a unidirectional flow. The data flows forward, it never comes back.
  • A data with changed properties is not same data (Autovalue), it can be a different copy object.
  • In redux, you pass an action, A reducer listens to action and changes store connects both acion and reducer
  • actoin: Must have a string, can optionaly have any type of payload.
  • reducer: Must return a state, it can never throw error or return undefined thing.
    • In any error case or un-recognized action, it should return previous state passed.
  • store: Allows to subscribe/unsubscribe updates, can read current state at any time and sends actions to reducers
import java.text.DateFormat
import java.text.SimpleDateFormat
import org.gradle.internal.os.OperatingSystem;
task(debugSomething) {
doLast {
println OperatingSystem.properties
}
@PrashamTrivedi
PrashamTrivedi / DbSchema.kt
Last active March 26, 2019 12:28
Some extension functions with room: Requires Export schema Read this section https://medium.com/google-developers/testing-room-migrations-be93cdb0d975#6872
import com.squareup.moshi.Json
data class DbSchema(@field:Json(name = "formatVersion") val formatVersion: Int? = 0, @field:Json(
name = "database") val database: Database? = Database())
data class Database(@field:Json(name = "version") val version: Int = 0, @field:Json(name = "identityHash") val identityHash: String? = "", @field:Json(
name = "entities") val entities: List<Entity?>? = listOf(), @field:Json(name = "setupQueries") val setupQueries: List<String?>? = listOf())
@PrashamTrivedi
PrashamTrivedi / CursorDelegate.kt
Created January 23, 2018 08:04
Handle cursor by delegates
inline fun <T> Cursor.delegate(key: String? = null,
crossinline getter: Cursor.(Int) -> T): ReadOnlyProperty<Any?, T> {
return object : ReadOnlyProperty<Any?, T> {
override fun getValue(thisRef: Any?, property: KProperty<*>): T {
val s = key ?: property.name
return getter(getColumnIndex(s))
}
}
@PrashamTrivedi
PrashamTrivedi / GlideDsl.kt
Created January 10, 2018 14:53
A rough Idea for using Glide as DSL....
import android.content.Context
import android.graphics.Bitmap
import android.graphics.drawable.Drawable
import android.support.annotation.DrawableRes
import android.support.v4.content.ContextCompat
import android.widget.ImageView
import com.bumptech.glide.DrawableTypeRequest
import com.bumptech.glide.RequestManager
import com.bumptech.glide.load.Transformation
import com.bumptech.glide.load.engine.DiskCacheStrategy
@PrashamTrivedi
PrashamTrivedi / DownloadRequest.kt
Last active May 28, 2024 10:50
Download File with progress indicator, written in Kotlin with Co-routines
suspend fun downloadFile(url: String,
downloadFile: File,
downloadProgressFun: (bytesRead: Long, contentLength: Long, isDone: Boolean) -> Unit) {
async(CommonPool) {
val request = with(Request.Builder()) {
url(url)
}.build()
val client = with(OkHttpClient.Builder()) {
addNetworkInterceptor { chain ->