Saturday, August 8, 2026

Streamlining Your Python Projects with common-util-py: A Handy Toolkit

As Python developers, we often find ourselves reinventing the wheel, writing the same helper functions for file handling, data processing, or logging across different projects. This is where a utility package like **common-util-py** comes to the rescue. Designed as a "library including all the common functionalities used in Python projects" , it aims to provide a standardized set of tools to speed up development and keep your codebase clean.


In this blog post, we'll explore what this project offers and how you can use it to make your Python development more efficient.


## What is common-util-py?


At its core, `common-util-py` is a Python package that serves as a collection of frequently used utilities. While the official PyPI page  is quite minimal, other sources describe it as a "๐Ÿณ Library including all the common functionalities used in Python projects" . This suggests it's designed to be a go-to resource for common programming tasks.


The package is licensed under the Apache 2.0 License  and supports modern Python versions (3.11 through 3.14) , making it suitable for a wide range of projects. Its latest version, 1.0.4, was released in July 2022  and has no known security vulnerabilities according to safety analyses .


## Getting Started


### Installation


Installing `common-util-py` is straightforward using pip, Python's package installer. Open your terminal or command prompt and run:


```bash

pip install common-util-py

```


This command will download and install the latest version of the package from the Python Package Index (PyPI) .


### Basic Usage


After installation, you can start using the utilities by importing the package into your Python scripts. Based on similar utility packages (like `py-common-util`), you might use it like this:


```python

import common_util_py


# Or, to use specific modules (assuming a structure similar to other common util packages):

# from common_util_py.common import date_utils, file_utils, etc.

```


**Note:** The specific module structure isn't detailed in the available resources, but the goal is to provide a cohesive set of tools. For more complex examples, such as those involving database operations or workflow management, you might look at similar packages like `at-common-util` .


## Potential Use Cases


While the exact functions of `common-util-py` are not exhaustively listed, we can infer its typical use cases from similar utility libraries:


1.  **Simplifying Common Tasks:** It likely provides helper functions for tasks like:

    - **File I/O:** Reading and writing files in various formats.

    - **Data Manipulation:** Working with lists, dictionaries, and strings.

    - **Date and Time:** Formatting and calculating dates and times.

    - **Logging:** Setting up and managing log files for debugging and monitoring.


2.  **Reducing Code Duplication:** Instead of writing the same functions repeatedly, you can rely on a well-tested library to handle these for you. This makes your code cleaner and easier to maintain.


3.  **Providing a Consistent Foundation:** By using a standard utility library across your projects, you ensure a consistent approach to common operations, making it easier for new team members to understand the codebase.


## Important Considerations


- **Check the Documentation:** Since the official PyPI page is sparse, you'll need to dig deeper to find comprehensive documentation. A good starting point is to explore the package after installation using Python's `help()` function or `dir()` to see what modules and functions are available.

- **Explore the Source:** If the package is hosted on a platform like GitHub, checking the source code can give you a clear picture of its capabilities.

- **Evaluate Alternatives:** The Python ecosystem has many excellent utility libraries, such as `ubelt` . It's always a good idea to evaluate different options to find the one that best fits your needs.


## Conclusion


`common-util-py` aims to be a valuable asset for Python developers by providing a central repository of useful functions. While its documentation could be more detailed, its core promise—to offer common functionalities and reduce repetitive coding—is compelling. If you're looking to standardize your helper functions and speed up development, give `common-util-py` a try. It might just become a staple in your Python toolkit.


Have you used `common-util-py` or a similar utility library? Share your experiences in the comments below

Saturday, July 25, 2026

Testing Your RAM with memtester: A Simple But Powerful Tool for System Stability

 Have you ever experienced random system crashes, mysterious application errors, or corrupted files? Sometimes, the culprit isn't a software bug—it's faulty memory. The memtester utility, originally created by Charles Cazabon and updated by Jason Wee, is a powerful yet simple tool designed to help you diagnose exactly this problem.

What is memtester?

At its core, memtester is a utility for testing your computer's memory subsystem to determine if it's faulty. It's not a replacement for comprehensive hardware diagnostics, but it's an incredibly useful first line of defense when you suspect memory issues.

What makes memtester special? Unlike many memory testing tools that require you to boot from an external medium (like Memtest86+), memtester runs directly from your existing operating system. This makes it perfect for quick tests on production systems, embedded devices, or any situation where rebooting isn't practical.

Key Features

Multiple Test Patterns

The software runs a series of eight different tests that catch various types of memory errors:

  • Stuck bits (bits permanently high or low)

  • Data sensitivity issues

  • Addressing problems

  • More subtle errors that only appear under specific patterns

Cross-Platform Support

memtester is incredibly portable, with successful builds reported on:

  • Various Linux distributions (Debian, RedHat, Ubuntu, etc.)

  • FreeBSD, NetBSD

  • macOS (OS X)

  • HP-UX on PA-RISC and Itanium

  • Tru64 Unix on Alpha

Physical Address Testing

For advanced users, memtester supports testing specific physical memory addresses. This can be useful for checking memory-mapped I/O devices or testing specific RAM banks.

Installing and Using memtester

Installation

Installation couldn't be simpler—there's no complex configure script to run:

# Clone the repository
git clone https://github.com/jasonwee/memtester.git
cd memtester

# Build it
make

# Install it (optional, to /usr/local/)
sudo make install

Basic Usage

The basic command syntax is straightforward:

sudo memtester <memory-amount> [runs]

For example, to test 256 megabytes of memory:

sudo memtester 256M

If you want to run the test only once (the default is unlimited):

sudo memtester 256M 1

Important Notes on Usage

  1. Run as Root: memtester needs root privileges to lock memory pages, preventing them from being swapped out. Without this, testing becomes slow and inaccurate.

  2. Memory Amount: You can specify memory in bytes (B), kilobytes (K), megabytes (M), or gigabytes (G). For example: 256M, 1G, 1024K.

  3. Memory is Overwritten: The memory you're testing will be overwritten during testing. Don't point it at memory containing critical system data or running applications!

When Should You Use memtester?

Here are some common scenarios where memtester proves invaluable:

  • After hardware upgrades: Just added new RAM? Test it before trusting it with your data.

  • System instability: If you're experiencing random crashes, freezes, or corruption, memory issues should be on your suspect list.

  • Embedded systems: For devices without external boot media, memtester can be cross-compiled and run directly.

  • Overclocking: Testing memory stability after overclocking your system.

Advanced Use Cases

Testing Specific Memory Regions

If you have hardware that exposes memory via /dev/mem or a custom device file:

# Test memory at physical address 0x0C0000 (64KB region)
sudo memtester -p 0x0c0000 64k

Custom Device Files

# Test device memory via a custom device file
sudo memtester -p 0 -d /dev/foodev 64k

The jasonwee Repository

The GitHub repository maintained by jasonwee serves as a convenient mirror of the original memtester source, with the latest version (4.7.1 as of December 2024). It includes:

  • The complete source code

  • Build scripts

  • Documentation files

  • Licensing information (GPL v2)

The maintainer builds it for work-related purposes, making it easy to access the latest stable version.

Limitations and Alternatives

While memtester is incredibly useful, it's important to understand its limitations:

  1. Not as comprehensive: For thorough testing (especially finding intermittent errors), you might want to use Memtest86+ or similar bootable tools.

  2. Requires free memory: You can only test memory that's not in use by the system.

  3. Performance impact: The tests can be resource-intensive and may affect system performance.

Final Thoughts

memtester is a gem in the sysadmin's toolkit. Its simplicity, portability, and ability to run from a live system make it an essential utility for diagnosing memory problems quickly. Whether you're a system administrator, developer, or enthusiast, having this tool in your arsenal can save you countless hours of debugging mysterious issues.

The jasonwee GitHub repository ensures this valuable tool remains easily accessible and up-to-date. So next time your system acts up, give memtester a run—it might just identify the problem faster than you'd expect!



Saturday, June 27, 2026

๐Ÿงฐ Building a Practical Java Utility Library: Exploring common_java

 When working across multiple Java applications, one problem appears again and again:

you keep rewriting the same “basic but essential” components.

common_java is a lightweight utility-style library that groups these repeated concerns into reusable modules — from validation and caching to HTTP, database helpers, and email utilities.

Let’s walk through what this library provides.

๐Ÿ“ฆ 1. Project Overview

The library is organized into clear functional packages:

  • validator → input validation logic
  • string → string utilities
  • cache → in-memory caching (including LRU cache)
  • network → HTTP and IP utilities
  • http → URL fetch example app
  • alert → email composition and sending
  • database → JDBC helpers and result handling
  • properties → config loading utilities

This is a classic “common utilities” architecture: each package solves a real-world repetitive backend problem.

✅ 2. Validation Layer

Key classes:

  • Validator
  • EmailValidator

This layer focuses on ensuring data correctness before processing.

Typical responsibilities:

  • checking input format
  • validating email structure
  • centralizing reusable validation rules

๐Ÿ’ก Design idea:
Instead of scattering validation logic across services, it is centralized.

Example concept:

Validator.isNotNull(value);

EmailValidator.isValid(email);

๐Ÿงต 3. String Utilities

Hex.java

This likely provides:

  • hex encoding / decoding
  • conversion between byte arrays and hex strings

๐Ÿ’ก Why it matters:
Hex utilities are commonly needed in:

  • encryption
  • networking
  • debugging binary data

⚡ 4. Cache System (Most Interesting Part)

Core classes:

  • Cache
  • LRUCache
  • CacheElement
  • Node
  • LinkedListNode
  • DoublyLinkedList
  • DummyNode
  • CacheApp

๐Ÿง  What this module shows

This is a classic LRU Cache implementation using:

  • Hash-based lookup (likely via Cache)
  • Doubly linked list for ordering
  • Node abstraction for entries

๐Ÿ” LRU Cache concept

Least Recently Used (LRU) cache works like this:

  • Recently used items stay in memory
  • Old unused items are removed first

๐Ÿงฑ Data structure design

This design typically combines:

  • HashMap → O(1) access
  • Doubly Linked List → O(1) insert/remove

๐Ÿ’ก Why multiple node classes?

  • Node → base structure
  • LinkedListNode → real element
  • DummyNode → sentinel node (simplifies edge cases)

This shows clean separation of concerns in data structure design.

๐Ÿš€ Why this module stands out

This is not just a utility — it’s a fully custom cache engine, useful for:

  • performance optimization
  • memory control
  • backend caching strategies

๐ŸŒ 5. Network Utilities

Classes:

  • HttpUtil
  • HttpClientApp
  • HttpResponse
  • HttpResponseCode
  • IP

What this module does

It likely provides:

  • HTTP GET/POST helpers
  • response wrapper object
  • HTTP status code abstraction
  • IP-related utilities

๐Ÿ’ก Design strength

Instead of directly using low-level HTTP calls everywhere, the library:

✔ wraps HTTP logic
✔ standardizes response handling
✔ centralizes error handling

This improves consistency across projects.

๐Ÿ“ง 6. Email / Alert System

Classes:

  • Email
  • EmailAddress
  • EmailBody
  • EmailAttachment
  • SMTP
  • EmailApp

What this represents

A structured email system with:

  • strongly typed email components
  • separation of:
    • recipient (EmailAddress)
    • content (EmailBody)
    • attachments (EmailAttachment)
  • SMTP abstraction

๐Ÿ’ก Why this design is good

Instead of passing raw strings:

sendEmail(to, subject, body)

You model email as an object:

Email email = new Email(...)

This improves:

  • readability
  • validation
  • maintainability

๐Ÿ—„️ 7. Database Utilities

Classes:

  • DatabaseManager
  • DatabaseStatementManager
  • StatementUtil
  • Jdbc
  • Result
  • RStoListMap

What this module solves

JDBC in Java is powerful but verbose.

This module likely simplifies:

  • connection handling
  • statement execution
  • result set mapping

๐Ÿ’ก Key idea: abstraction over JDBC

Instead of repeating boilerplate:

Connection conn = ...
PreparedStatement stmt = ...
ResultSet rs = ...

You centralize it into utilities.

๐Ÿ” RStoListMap

This likely converts:

ResultSet → List<Map<String, Object>>

This is extremely useful for:

  • APIs
  • JSON conversion
  • dynamic queries

⚙️ 8. Configuration Utilities

ConfigApp

This likely handles:

  • loading .properties files
  • environment configuration
  • app-level settings

๐Ÿ’ก Why it matters:

Every Java system needs config loading, and centralizing it avoids duplication.

๐ŸŒ 9. HTTP Example App

UrlFetchApp

This is likely a demo or utility showing:

  • fetching URL content
  • using HttpUtil

This acts as:

a usage example of the network module

๐Ÿง  Overall Design Observations

✔ Strengths

1. Clear modular separation

Each package has a single responsibility.

2. Real-world utility coverage

It covers:

  • validation
  • caching
  • HTTP
  • email
  • database

This is basically a mini backend toolkit.

3. Strong focus on reusability

Everything is designed to be reused across projects.

๐Ÿš€ Final Summary

common_java is essentially a personal backend utility framework that helps reduce repetitive Java boilerplate across projects.

It demonstrates:

  • practical backend engineering patterns
  • data structure implementation (LRU cache)
  • abstraction over JDBC and HTTP
  • structured email handling
  • reusable validation logic 
 

Wednesday, June 3, 2026

Run macOS in linux docker container

To be able to run macOS in linux docker container to access macOS applications without switch back and forth makes life easy. This project allow you to do that. The instruction given is very tricky, so I have written a step by step how to begin.


0. This is the main project which we will work on. Essentially we need to build an image where the image is not found in dockerhub at the moment.

```

$ git clone  https://github.com/sickcodes/Docker-OSX

$ cd Docker-OSX

$ docker build -t docker-osx:naked -f Dockerfile.naked .

```


1. Start the macOS installer, this will take some times. If clone repository OpenCorePkg is slow , add this `-v "<USERNAME>/macos/OpenCorePkg:/home/arch/OSX-KVM/OpenCorePkg"` to the command below. But make sure you have clone the repository before https://github.com/acidanthera/opencorepkg

```

$ docker run -it \

    --device /dev/kvm \

    -p 50922:10022 \

    -v /tmp/.X11-unix:/tmp/.X11-unix \

    -e "DISPLAY=${DISPLAY:-:0.0}" \

    -e GENERATE_UNIQUE=true \

    -e MASTER_PLIST_URL='https://raw.githubusercontent.com/sickcodes/osx-serial-generator/master/config-custom.plist' \

    -e SHORTNAME=monterey \

    sickcodes/docker-osx:latest    

```


2. In the mean time, get the container id and note the container id

```

$ docker ps

```


3. A qemu screen will appear, click on `macOS Base System`. wait the messages loading is complete.




4. Once at the installer screen is up, then to erase the biggest disk. You can name the disk any name because it is not important. Example `my_macos_vd`.




5. Then reinstall the macOS. Pick the disk that you erase in step 4. This installation will take a long time. Approximately 1hour in my host machine.

6. Inspect the container and get the directory where we will copy out the disk. 
```
$ docker inspect 0a0fdebac3ac | grep Upper
                "UpperDir": "/var/lib/docker/overlay2/11043fba8b6ed2e4ffeaeb8a439d791f03081cd785a9a14e60024dc3e6c4f461/diff",
```

7. Once installation is done, power down the container. 

8. Based on the step 6, the value of `UpperDir`, now copy the `mac_hdd_ng.img` to another directory in your host. Any directory will do. I pick `~/macos/`
```
$ sudo su -
# cd /var/lib/docker/overlay2/11043fba8b6ed2e4ffeaeb8a439d791f03081cd785a9a14e60024dc3e6c4f461/diff
# ls -lh ./home/arch/OSX-KVM/mac_hdd_ng.img
-rw-r--r-- 1 jason jason 37G Jun  2 20:43 ./home/arch/OSX-KVM/mac_hdd_ng.img
# cp ./home/arch/OSX-KVM/mac_hdd_ng.img </home/USERNAME/>/macos/
```

9. Update the file permission to your username correctly. 
```
$ cd ~/macos/
$ sudo chown jason:jason mac_hdd_ng.img
$ chmod 664 mac_hdd_ng.img
```

10. Now start the container using the virtual disk, the local built naked image to finish the OS setup/configuration. It will takes more than 30 minutes to complete at least.

```
docker run -it \
    --device /dev/kvm \
    -p 50922:10022 \
    -v "/home/jason/macos/mac_hdd_ng.img:/image" \
    -v /tmp/.X11-unix:/tmp/.X11-unix \
    -e "DISPLAY=${DISPLAY:-:0.0}" \
    -e MASTER_PLIST_URL=https://raw.githubusercontent.com/sickcodes/Docker-OSX/master/custom/config-nopicker-custom.plist \
    -e SHORTNAME=monterey \
    docker-osx:naked
```  
to speed up the container, add the below parameters to the command above if your host hardware support it.
```
    -m 10g \
    --cpus="8.0" \
    --gpus all \
    --device /dev/nvidia0 \
    --device /dev/nvidia-uvm \
    --device /dev/nvidia-uvm-tools \
    --device /dev/nvidiactl \
```

11. Once started, get the container id again. After the mac os setup/configuration is finish, then stop the container. Note that during this step, OS reboot is expected.

```
$ docker ps
```




12. Now every time to start the container
```
$ docker start <container id from step 11>
```




It is a pity that the macOS after Monterey does not work. If you managed to make it work, I would like to know and please contact me!

Saturday, March 28, 2026

๐Ÿ‡ฒ๐Ÿ‡พ A Simple, Fast EPF Calculator for Malaysians — Built for Everyday Use

 

๐Ÿ‡ฒ๐Ÿ‡พ A Simple, Fast EPF Calculator for Malaysians — Built for Everyday Use

Managing your finances in Malaysia often means keeping track of your EPF (Employees Provident Fund) contributions — whether you’re an employee, employer, or freelancer planning ahead.

That’s exactly why I built this lightweight, no-frills web app:

๐Ÿ‘‰ https://weetech-software.github.io/epf/


๐Ÿ’ก Why This EPF Calculator Exists

Most EPF calculators online tend to be:

  • Overly complex

  • Slow to load

  • Filled with ads or unnecessary steps

I wanted something different:

  • Fast

  • ๐Ÿงผ Clean UI

  • ๐ŸŽฏ Straight to the point

This tool is designed to help you quickly answer questions like:

  • How much EPF will I contribute this month?

  • What is my employer contributing?

  • What’s the total deduction from my salary?


๐Ÿงฎ What the Calculator Does

The calculator lets you:

  • Input your monthly salary

  • Instantly see:

    • Employee EPF contribution

    • Employer EPF contribution

    • Total EPF contribution

It reflects standard EPF contribution structures used in Malaysia, making it practical for:

  • Employees checking payslips

  • HR or payroll quick checks

  • Anyone planning savings projections


๐Ÿš€ Key Features

⚡ Instant Calculation

No loading screens, no waiting — results update immediately as you type.

๐Ÿง  Simple & Intuitive

No financial jargon. Just enter your salary and get your numbers.

๐Ÿ“ฑ Works Everywhere

Fully web-based, so you can use it on:

  • Desktop

  • Mobile

  • Tablet

No installation needed.

๐Ÿ”’ Privacy-Friendly

  • No login

  • No tracking

  • No data stored

Everything runs directly in your browser.


๐Ÿ› ️ Built for Practical Use

This isn’t meant to replace official tools — it’s meant to make your daily life easier.

Whether you’re:

  • Checking your take-home salary

  • Estimating job offers

  • Planning monthly finances

This tool gives you quick, reliable answers without friction.


๐Ÿ“Œ Example Use Case

Let’s say you’re offered a salary of RM5,000.

Instead of manually calculating percentages or digging through EPF tables, you can:

  1. Open the calculator

  2. Enter 5000

  3. Instantly see:

    • Your contribution

    • Employer contribution

    • Total EPF savings

Done in seconds.


๐ŸŒฑ Future Improvements

Some ideas I’m considering:

  • Support for different EPF contribution rates (e.g. reduced rates)

  • Yearly projection / savings growth

  • Printable summary

  • More financial tools in one place


๐Ÿ™Œ Try It Out

If you’re in Malaysia and want a quick way to calculate EPF:

๐Ÿ‘‰ https://weetech-software.github.io/epf/


๐Ÿ’ฌ Feedback Welcome

If you find it useful or have ideas to improve it, feel free to share feedback. The goal is to keep it simple, fast, and genuinely helpful.


Built with simplicity in mind — because financial tools shouldn’t be complicated.

Saturday, March 14, 2026

Integrate alert_threshold into Jenkins

To run this application periodically and ensure system admins/support receive timely alerts, a Jenkins installation is required.

  1. Make sure you have already run this app as described in the How to run this app section.
  2. Download and install Jenkins. While Jenkins setup is outside the scope of this document, more information can be found here.
  3. Create a Freestyle Project in Jenkins and apply the appropriate settings. The minimum required settings are:
    • Build periodically
    • Execute Shell
  4. That’s it! Check the console output for any errors. A YouTube video has also been created to briefly demonstrate this integration:


Sunday, October 12, 2025

How to draw arrow in GIMP using plugin

GIMP is a great image editing program that allows us to alter images and better convey our intentions. I like using GIMP for tasks such as resizing, changing formats, or cropping images. In this article, I will explain how to draw an arrow in GIMP.

First, download the arrow.zip which contains two Scheme script files. There should be 3 files in total. Below is a summary of the files:

  • ArrowScriptNotes.pdf : description of the arrow.
  • arrow.scm            : Scheme script file for gimp version 2.x
  • arrow_V3.scm         : Scheme script file for gimp version 3.x
Depending on your GIMP installation, copy the appropriate file to the GIMP script directory and then make it executable. For example , I'm using GIMP version 3.0.4-3 so I would do the following:

$ cp arrow_V3.scm $HOME/.config/GIMP/3.0/scripts
$ chmod 770 $HOME/.config/GIMP/3.0/scripts/arrow_V3.scm
$ # for GIMP version 2.x
$ # cp arrow_V3.scm $HOME/.config/GIMP/2.10/scripts

Restart GIMP if it is already running. I also created a YouTube video demonstrating how to draw an arrow using this plugin.