Skip to content

Instantly share code, notes, and snippets.

View ethaizone's full-sized avatar
💭
I love AI.

Nimit Suwannagate ethaizone

💭
I love AI.
View GitHub Profile
@ethaizone
ethaizone / json-float-as-string.py
Last active October 21, 2024 10:05
Junior in team asked me if they don't want to see exponential notation in json, how to do in python?
import json
import re
class CustomJSONEncoder(json.JSONEncoder):
def encode_float(self, obj):
if isinstance(obj, float):
return format(obj, "f").rstrip('0').rstrip('.')
return super().encode(obj)
def encodeObj(self, obj):
@ethaizone
ethaizone / terminal-prompt-git-branch-status-zsh.md
Last active February 20, 2025 05:46 — forked from reinvanoyen/terminal-prompt-git-branch-zsh.md
Add Git Branch Name and Status to Terminal Prompt (MacOS zsh)

Add Git Branch Name and Status to Terminal Prompt (zsh)

image

Install

Open ~/.zshrc in your favorite editor and add the following content to the bottom.

git_status() {
    # Early return if not in a git repository
@ethaizone
ethaizone / react-context-usereducer-pattern-guide.md
Last active March 24, 2025 04:18
React Context + useReducer Pattern Guide

React Context + useReducer Pattern Guide

A clean and lightweight alternative to Redux using React's built-in Context + useReducer. Great for small to medium applications that need global state management without the overhead of additional libraries.

Example demonstrates a counter implementation but can be extended for more complex state management needs.

Overview

This guide shows a clean and type-safe approach to implementing global state management in React without external state management libraries. Perfect for small to medium-sized applications where Redux might be overkill.

Features

@ethaizone
ethaizone / Dockerfile.pi
Created April 14, 2026 14:40
Simple demo for PI inside docker compose as sandbox (No network filtering)
# Pi Agent Sandbox - Ubuntu-based development environment for pi agents
FROM ubuntu:24.04
# Avoid interactive prompts during package installation
ENV DEBIAN_FRONTEND=noninteractive
# Set environment variables (running as root for easier development)
ENV HOME=/root
ENV PATH="${HOME}/go/bin:/usr/local/go/bin:${HOME}/.local/bin:${PATH}"
ENV GOPATH="${HOME}/go"