Skip to content

Instantly share code, notes, and snippets.

View moinulmoin's full-sized avatar
:shipit:
building

Moinul Moin moinulmoin

:shipit:
building
View GitHub Profile
@moinulmoin
moinulmoin / AMP-FREE-TIER-GUIDE.md
Last active February 8, 2026 16:00
AMP Free Tier + Local OAuth Fallback Guide — Use AMP's free $10/day first, auto-fallback to your local OAuth subs (Claude, Gemini, Codex, Copilot, Kiro)

AMP Free Tier + Local OAuth Fallback Guide

Use AMP's free $10/day grant first. When exhausted, switch to your own subscriptions (Claude, Gemini, Codex, GitHub Copilot, Kiro, etc.) — all from within AMP CLI. No restart needed.

Prerequisites: Add Prefer-Upstream Feature

CLIProxyAPI / CLIProxyAPIPlus doesn't include the prefer-upstream feature out of the box. You need to add it first.

Drop IMPLEMENT-PREFER-UPSTREAM.md into your AI coding agent (Claude Code, AMP, Cursor, etc.) and ask it to implement the changes. It's 7 small edits that follow the existing ForceModelMappings pattern.

@moinulmoin
moinulmoin / config.json
Created December 12, 2025 14:17
Latest Factory CLI custom models config with CLIPROXYAPI, you can use with your Google AI, Claude, Chatgpt subscriptions
{
"custom_models": [
{
"model_display_name": "GPT 5.2 Medium",
"model": "gpt-5.2(medium)",
"base_url": "http://localhost:8317/v1",
"api_key": "dummy-not-used",
"provider": "openai"
},
{
@moinulmoin
moinulmoin / try-catch.ts
Created March 22, 2025 10:42
Go like error handling for promises in TS
/**
* Wraps a promise and returns a tuple where the first element is the data if successful,
* or null if an error occurred, and the second element is the error if any, or null if successful.
*
* @param promise The promise to wrap.
* @returns A promise that resolves to [data, null] on success or [null, error] on failure.
*/
export async function tryCatch<T, E = Error>(promise: Promise<T>): Promise<[T, null] | [null, E]> {
try {
const data = await promise;
@moinulmoin
moinulmoin / clean_code.md
Created October 22, 2024 15:40 — forked from wojteklu/clean_code.md
Summary of 'Clean code' by Robert C. Martin

Code is clean if it can be understood easily – by everyone on the team. Clean code can be read and enhanced by a developer other than its original author. With understandability comes readability, changeability, extensibility and maintainability.


General rules

  1. Follow standard conventions.
  2. Keep it simple stupid. Simpler is always better. Reduce complexity as much as possible.
  3. Boy scout rule. Leave the campground cleaner than you found it.
  4. Always find root cause. Always look for the root cause of a problem.

Design rules

@moinulmoin
moinulmoin / Dockerfile
Created June 26, 2024 09:47
Dockerfile for Next.js
FROM node:lts-alpine AS base
# Install dependencies only when needed
FROM base AS deps
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
RUN apk add --no-cache libc6-compat
WORKDIR /app
# Install dependencies based on the preferred package manager
COPY package.json pnpm-lock.yaml* ./
@moinulmoin
moinulmoin / easing.css
Created May 13, 2024 17:17 — forked from bendc/easing.css
Easing CSS variables
:root {
--ease-in-quad: cubic-bezier(.55, .085, .68, .53);
--ease-in-cubic: cubic-bezier(.550, .055, .675, .19);
--ease-in-quart: cubic-bezier(.895, .03, .685, .22);
--ease-in-quint: cubic-bezier(.755, .05, .855, .06);
--ease-in-expo: cubic-bezier(.95, .05, .795, .035);
--ease-in-circ: cubic-bezier(.6, .04, .98, .335);
--ease-out-quad: cubic-bezier(.25, .46, .45, .94);
--ease-out-cubic: cubic-bezier(.215, .61, .355, 1);
@moinulmoin
moinulmoin / grokking_to_leetcode.md
Created March 28, 2024 20:33 — forked from tykurtz/grokking_to_leetcode.md
Grokking the coding interview equivalent leetcode problems

GROKKING NOTES

I liked the way Grokking the coding interview organized problems into learnable patterns. However, the course is expensive and the majority of the time the problems are copy-pasted from leetcode. As the explanations on leetcode are usually just as good, the course really boils down to being a glorified curated list of leetcode problems.

So below I made a list of leetcode problems that are as close to grokking problems as possible.

Pattern: Sliding Window

@moinulmoin
moinulmoin / useCountdownTimer.tsx
Created January 11, 2024 16:11
Countdown timer hook
import { useState, useEffect, useRef } from 'react';
type CountdownTimer = {
remainingTime: number;
startTimer: () => void;
stopTimer: () => void;
isRunning: boolean;
};
const useCountdownTimer = (duration: number): CountdownTimer => {
@moinulmoin
moinulmoin / .env
Last active November 12, 2023 13:41
docker postgres service
DB_USER=postgres
DB_PASSWORD=postgres
DB_NAME=postgres
DATABASE_URL="postgres://${DB_USER}:${DB_PASSWORD}@localhost:5432/${DB_NAME}"
@moinulmoin
moinulmoin / env.mjs
Created September 16, 2023 16:12
Typesafe envs
// ref: https://github.com/webdevcody/online-marketplace/blob/main/src/env.mjs
import { z } from "zod";
/**
* Specify your server-side environment variables schema here. This way you can ensure the app isn't
* built with invalid env vars.
*/
const server = z.object({
DATABASE_URL: z.string().url(),