RSSAmplifier

Blog

Huijing Huang Tech Blogs

Recent content on Huijing Huang Tech Blogs

techblog.huijinghuang.comRSS feed ↗36 posts

Latest posts

Optimizing Claude Code for Limited Token Budgets

At Meta, I can use Claude Code with unlimited tokens. But for personal use, I only have the 20/month pro plan. The question: how do I optimize for the best? How do I squeeze every drop of the tokens? Token Charging Mechanism The rate limit is 45 messages per 5-hour rolling window plus a weekly cap, shared across both claude.ai chat and Claude Code. Usage Pattern My usage splits sharply:

Meta NHO and Bootcamp Live

Mission & Value CPO Chris Cox talked about Meta’s mission: Build the future of human connection and the technology that makes it possible This finally made it click for me why Mark Zuckerberg is investing so heavily in wearables. Chris also shared an “opportunity” chart showing data volume growing exponentially while human attention stays constant. The takeaway: there’s a…

Typescript

A Modern Guide to TypeScript: Modules, Tooling, and Configuration Understanding the TypeScript ecosystem and setting up your project for success If you’ve been working with TypeScript, you’ve probably encountered confusing choices about module systems, compilers, and configuration options. In this guide, I’ll break down the essential concepts and help you make informed decisions…

Prisma

Setting Up Prisma with Supabase for Next.js Intro Prisma, Supabase, Next.js are all great, but there’s work to glue them together. In this blog, I will share the lessons I learned along the way. For the official integration guide, check out Supabase’s Prisma documentation . Getting Started: Installation First, let’s install the necessary packages: npm i -D prisma # prisma dev…

Kafka Java Programming

Kafka Java Programming I’ve been learning Apache Kafka over the past week. I took the Udemy course Apache Kafka Series - Learn Apache Kafka for Beginners v3 . I’m using this blog to take notes, and this post focuses specifically on Java programming with Kafka. Producer Basics To configure a Kafka producer: Set the key and value serializer to, for example, StringSerializer flush() the…

Kafka CLI

Overview I’ve been learning Apache Kafka over the past week. I took the Udemy course Apache Kafka Series - Learn Apache Kafka for Beginners v3 . I’m using this blog to take notes, and this post focuses specifically on Kafka CLI commands. Installation and Setup Client Installing the Kafka client on macOS is very straightforward: brew install kafka Homebrew will install both JDK and…

Kafka Basics

Kafka Basics I’ve been learning Apache Kafka over the past week. I took the Udemy course Apache Kafka Series - Learn Apache Kafka for Beginners v3 . This blog covers the theory part of Kafka. Topics, Partitions and Offsets Here are some important notes: Kafka is append-only Data retention policy (one week by default) Order is guaranteed only within a partition Producers When a key is null,…

Redis Basics

Redis Basics Here are my notes on Redis. Installation, Start, and Shutdown I installed WSL and then installed Redis using sudo. To start Redis, cd to /usr/bin and run sudo ./redis-server To connect to Redis, cd to /usr/bin and run sudo ./redis-cli To shutdown Redis, run shutdown in the redis-cli, and Redis will save an RDB snapshot before exiting To check whether Redis is running, run ps -ef |…

Data Structure (in Python)

Recently, I have been re-learning Python in my spare time, and I want to write a blog (or blogs) to document something new to me. Stack Surprisingly, there’s no stack type in Python. There are three ways to implement a stack in Python. Check out How to Implement a Python Stack : list collections.deque queue.LifoQueue List List is built upon blocks of continous memory. To implement a stack:…

Integrating App Insights with Hugo

Tracking website usage is essential for understanding your audience and improving your content. For my Hugo website, I chose to use Azure Application Insights (App Insights) because I just like it. This guide is inspired by this tutorial . Setting Up Azure Resources To get started, search for Application Insights in the Azure Marketplace. Click Create and fill in the required details: Once done,…

Geneva

Geneva is an internal monitoring platform developed by Microsoft. While Geneva is widely used within Microsoft, it is not publicly available. However, Microsoft offers similar monitoring tools for external customers, such as Azure Monitor . Recently, I have been working on a feature to implement infrastructure for sending metrics using Geneva APIs. In this blog, I’ll share a high-level…

VSCode Extension Advanced Topics

In this blog, I want to document some useful apis, such as chat extension api and workspace api . Get the current workspace We can use the workspace API to create folders and files in vscode. To do that, we need to get the reference to the current workspace. You can read more about VSCode workspace from this doc . Basically, when you first open a vscode editor, the workspace is empty: You can open…

VSCode Chat Extension Basics

Introduction A VSCode Chat Extension is an extension uses the Chat extension API by contributing a chat participant - a domain expert that can answer user queries within a specific domain. The reason why I am looking into the VSCode Chat Extension is that I want to build a domain expert on Threat Modeling. In this blog, I will talk about the basic usage of a chat extension. Here are the…

Vibe Coding Like a Pro

Introduction Vibe coding is a term introduced by Andrej Karpathy . While some perceive vibe coding as using AI for merely writing code, I see it as: a method to learn new concepts a way to write higher-quality code leveraging AI to handle boilerplate code, allowing me to focus on more critical aspects, such as: product vision tech stack decisions architectural design design patterns test cases At…

Conv1D Layer

Here’s a pretty cool article on understanding PyTorch conv1d shapes for text classification. In this article, the shape of the example is: n = 1 : number of batches d = 3 : dimension of the word embedding l = 5 : length of the sentence import torch.nn as nn import torch # Example represents one sentence here example = torch . rand(n = 1 , l = 3 , d = 5 ) example . shape # torch.Size([1, 5,…

XCS330 PS4 In-Context Learning & Fine-Tuning

Introduction In the XCS330 Problem Set 4, we will explore methods for performing few-shot learning with pre-trained LMs. Datasets from HuggingFace: Amazon Reviews : five-way classification problem. Given a review, predict the start rating, from 1 to 5. XSum : news articles from BBC. Given a news, return a one sentence summary. Use n-gram overlap to measure the score bAbI : question-answering tasks…

XCS330 PS3 MAML

Introduction In traditional machine learning, we have a lot of dataset for a specific tasks, while in meta-learning, we have many tasks with small datasets, and the hope is that we can train a model that can learn some fundamental idea from other tasks. Put it this way: the goal of traditional ML is to optimize the performance of a single task, while the goal of meta-learning is to optimize for…

Functions

Softmax The softmax function is widely used in machine learning. It is used to convert a vector of raw values into a probability distribution. Given a vector $\mathbf{z} = [z_1, z_2, \ldots, z_n]$, the softmax function is defined as: $$ \sigma(\mathbf{z_i}) = \frac{e^{z_i}}{\sum_{j=1}^{n} e^{z_j}} $$ Here’s an example in PyTorch: import torch import torch.nn.functional as F logits = logits =…

XCS330 Environment Setup

Install Conda Since I am a mac user and I want to leverage the Apple Silicon CPU architecture, I installed Miniforge . During installation, I chose not to have conda to control my shell environment, and therefore after installation, I need to run the following command to activate the base environment. source ~/miniforge3/bin/activate Windows Users For windows users, use this link . After…

Latex

Latex tutorial Greek numbers, for instance \textlambda . https://www.overleaf.com/learn/latex/List_of_Greek_letters_and_math_symbols Superscript: ^ and subscript: _ , example: $a_i$ Basic bold text: https://www.overleaf.com/learn/latex/Bold%2C_italics_and_underlining \textbf{} Greek Letters Greek Letters and Math Symbols . Table How to write a table in Latex:…

XCS330 ProtoNet

In the 3rd assignment of XCS330, we will implement prototypical neworks ( protonets ) for few-shots image classification on the Omniglot dataset. Protonets Algorithm This is the protonet in a nutshell, and the example comes from the assignment: In this example, we compute three class prototypes c1, c2, c3 from the support features. The decision boundaries are computed using Euclidean distance.…

Threat Model Field Research

In this blog post, I will share the findings of my research in the field of threat modeling . What Is Threat Modeling Threat modeling is a process used to identify, assess, and address potential security threats and vulnerabilities in a system. The STRIDE Model There are numerous threat modeling methodologies, and the one I am interested in is the STRIDE model: Category Description Spoofing…

Azure Resources Visualization

Introduction In this blog, I want to talk about how to leverage az cli to visualize a graph in Python. Note that Azure portal has a tab that shows the visualization of the resources. The reason why I am still interested in this topic is that I want to turn azure resource definition into a data structure, which can then be leveraged to generate different form of diagrams: dependency graph of azure…

SQLAlchemy

Intro SQLAlchemy is a very popular ORM Python library. Key Concepts Engine See Engine Configuration . The engine is the starting point for SQLAlchemy application. The very basic usage is to create an engine from a postgresql url: from sqlalchemy import create_engine engine = create_engine( "postgresql+psycopg2://scott:tiger@localhost:5432/mydatabase" ) Session See Session Basics . A session is a…

Pydantic

Pydantic Why do we have multiple classes for the same model? For example: from pydantic import BaseModel class UserBase (BaseModel): name: str email: str class UserCreate (UserBase): password: str class User (UserBase): id: int class Config : orm_mode = True Here’s the response from copilot: In Pydantic, we often define multiple schemas like UserBase , UserCreate , and User to handle…

Precommit Hook

pre-commit hooks are a way to add hooks that run before the commit process. They are a great way to make sure your code is ready to be committed. Installation Follow platform-specific instructions for installing pre-commit . Or if you have pip installed in your machine. Run: pip install pre-commit Initialization Run the following command to initialize the git hook: pre-commit install Configuration…

Format

There are many tools for linting and formatting Python codes: package usage isort sort imports black format code pylint lint code pep8 lint code autoflake lint code ruff lint and format code Ruff Basic configuration: [ tool . ruff ] line-length = 120 [ tool . ruff . lint ] select = [ "E501" , "I" ] [ tool . ruff . format ] docstring-code-format = true docstring-code-line-length = 88 Since Ruff…

FastAPI

Overview FastAPI is a modern, fast web framework for building APIs with Python. It can provide high performance on par with Node.js and Go. Starlette & Uvicorn Both Starlette and Uvicorn are essential components in the FastAPI ecosystem. Starlette starlette is a lightweight ASGI (Async Server Gateway Interface) framework for building web apps FastAPI is built on top of starlette and pydantic, and…

Poetry

Overview Poetry is a dependency management and packaging tool for Python. I have been using it for a while and I really love it since it help simplify the process of managing dependencies and virtual environments. Installation If you have pip installed in your machine. Run the following command to install Poetry. Otherwise, follow this guide . pip install poetry Check if Poetry is installed…

Hugo Infopage

Info Page To customize the info page for PaperMod based website: params : homeInfoParams : Title : "👋Hello World!" Content : >- Welcome to Huijing Huang's tech blogs! Social Icons To add social icons: params : socialIcons : - name : "github" url : "https://github.com/rewrlution" - name : "linkedin" url : "https://www.linkedin.com/in/huijing-huang/" - name : "email" url :…

XCS330 PS2 Part 1 - Data Processing

Introduction In this blog, I will talk about some tricks that I learned when I worked on the data processing part for assignment 2 of XCS300. Here’s the link to the assignment . This is how the data looks like: Understand Dataset In this assignment, we use the Omniglot dataset that has 1623 hand-written characters from 50 different languages. Each character has 20 (28 x 28) images. Running…

XCS330 PS2 Part 2 - MANN Architecture

Introduction In this blog, I will talk about the model part for assignment 2 of XCS300. Here’s the link to the assignment . This is the MANN (memory-augmented neural network) architecture: LSTM Here are some useful reading materials for understanding LSTM and RNN : What is LSTM (Long Short Term Memory)? PyTorch Tutorial - RNN & LSTM & GRU PyTorch Tutorial - Name Classification Using A RNN…

Hugo Math Typsesetting

Display Math Equations To display math equations in Hugo, we need to add math typesettings. I followed the PaperMod - Math Typesetting tutorial since I use it as the template. The tutorial uses KaTex as the library. Step 1: Math.html Create a partial under /layouts/partials/math.html . I use the Auto-render Extension to render the math inside it, and I include the reference to the script: < link…

Cross Entropy

Cross Entropy In machine learning, the cross-entropy loss is a very popular loss function. Here&rsquo;s the math definiton of it: $$ H(P^* | P) = - \sum_{i} P^*(i) log P(i) $$ I have been using cross entropy for decades without truly understanding this loss function. Recently, I watched a few YouTube videos and want to share my most recent understanding of it. Essentially, cross entropy is very…

Null Parent Window Handler Issue for AzureAuth Library

Null Parent Window Handler Issue for AzureAuth Library Background AzureAuth-Lib is a thin wrapper on top of microsoft-authentication-cli , which is a CLI wrapper of MSAL . These CLI tools are heavily used by developers. Starting from September 2024, users reported an issue with the tool, stating that AzureAuth-Lib failed to acquire an access token due to a null reference exception. Here&rsquo;s…

Hugo Basics

Hugo Basics What is Hugo? Hugo is a popular open-source static site generators. It takes your content written in Markdown format, applies templates, and generates a static HTML website. It is written in Go and has great performance. Comment: I have used other static site generators before, including Gatsby and Docusaurus . I prefer Hugo because it is very easy to use, and good for lightweight…