RSSAmplifier

Blog

hanshq.net

hanshq.netRSS feed ↗25 posts

Latest posts

Big-Endian Testing with QEMU

In computing, the terms big endian and little endian refer to the order in which a value's bytes are stored in memory: with the most significant (big) or least significant (little) part first.

Shrink, Reduce, and Implode: The Legacy Zip Compression Methods

Last year I wrote a long article about Zip files, covering the history, describing the Deflate compression method in great detail, and showing the implementation of a simple Zip program. I was fascinated by the subject: the magic of data compression, and how this truly ubiquitous file format works.

Zip Files: History, Explanation and Implementation

I have been curious about data compression and the Zip file format in particular for a long time. At some point I decided to address that by learning how it works and writing my own Zip program. The implementation turned into an exciting programming exercise; there is great pleasure to be had from creating a well oiled machine that takes data apart, jumbles its bits into a more efficient…

The Old-School Fire Effect and Bare-Metal Programming

Many years ago, sometime in the nineties, my family was having dinner at the neighbours', and their son showed me some cool DOS programs on the computer. One of the programs was a demo that drew animated flames on the screen. I was amazed! Asking what language it was written in, I was told it was Pascal.

Finding the First 10-digit Prime in (a Billion) Digits of e

Back in 2004, Google ran a recruitment campaign where they posted the following billboard along the main freeway running through Silicon Valley, and later at other locations in the country:

Othello for Desktop, Mobile and Web: an AI and GUI Exercise

Artificial intelligence (AI) is one of those subjects I really wish I'd taken while at university. Philosophical questions about intelligence aside, much of what AI comes down to in practice is techniques for solving problems with computers, which is really what computer science is all about.

Building an Android App from the Command Line

Update 2024-03-01: Updated the article to use newer SDK, NDK, etc. and target Android API level 34.

Algorithms for Roman Numerals

Converting between regular (Hindu-Arabic) and Roman numerals seems to be a common programming exercise.

A Bigint Calculator

This is a programming exercise I've wanted to do for a long time: an implementation of arbitrary-precision integer ("bigint") arithmetic in C.

Green's Sorting Network and a Cheque From Knuth

The first time I heard about Don Knuth and his famous books, The Art of Computer Programming (TAOCP), was during a summer internship more than ten years ago. When my colleague explained how Knuth pays a finder's fee for any errors in his books, cheques more commonly framed than cashed, I hardly expected to ever receive one myself.

Ones and Zeros, Part 2: Making Executable Files

I first started programming in QBasic. My father had brought home a used IBM PS/2 Model 50 from work, and I spent many hours writing programs that printed text in different colours whilst beeping the internal speaker.

Nibble Sort

A while back, John Regehr posted the Nibble Sort Programming Contest on his blog. The objective was to write a program that sorts the 4-bit components (nibbles) of 64-bit words as fast as possible. For example, 0x42badc0ffeed00d5 should result in 0xffeedddcba542000 after sorting.

Programming With Ones and Zeros

I have always been fascinated by computers. As a child, I heard that they run "ones and zeros", and was curious as to what that actually meant. Eventually, I learned a bit of x86 assembly language. I think it was from an early version of Randall Hyde's The Art of Assembly Language and the now long-out-of-print Vitaly Maljugin et al., Revolutionary Guide to Assembly Language. For example, this x86…

Building GCC from source

I spent a lot of time trying to get my GCC build to work the first time. These are my notes.

tmux notes

tmux is a terminal multiplexer, much like screen. I use it at work to keep my terminals organized. Typically I have one session running for each project, e.g. one for Chromium and one for LLVM. Within each session I often have one window for editing, one for compiling and running, and one for source control.

Unboxing Happy Hacking Keyboard Professional 2

Pictures from the unboxing of a Happy Hacking Keyboard Professional 2:

Perl One-Liners of the Month

Below are links to all the Perl One-Liner of the Month episodes from The Linux Gazette. I enjoyed reading them when learning Perl.

Kryptonite New York Fahgettaboudit Mini

As I was about to leave for work one morning a few weeks ago, I found that my neighbour's bike had been stolen. It had been parked right next to mine, locked with the same kind of lock: a KryptoLok Series 2, the pieces of which were now lying on the ground. My bike is not very fancy, which is probably why my neighbour's bike was stolen instead of mine, but buying a better lock still seemed like a…

Validating HTML and CSS with curl

The World Wide Web Consortium (W3C) provide automatic validation tools for HTML and CSS. Sometimes it's handy to be able to validate a web page or style cheet from the command line. Here is a way to do it with curl:

Clang Plugin Example

Clang is a compiler for the C family of programming languages (C, C++, Objective-C, etc.) based on the LLVM compiler infrastructure. Besides being an excellent compiler, it can be used for building language-aware tools. One way of doing that is to write a Clang plugin, and this page provides an example of writing such a plugin.

Notes on Bash

At some point I wanted to learn more about Bash's command history facility. Here are some notes I made about this and other things I found.

Unboxing Soekris net5501-70

Pictures from the unboxing of a Soekris net5501-70:

ansi2tex

A while back, I was doing a presentation about Clang (a C/C++ compiler) at my university. (The presentation can be found here.) Clang has very nice coloured diagnostics, and I wanted to show some examples of that in the presentation. I was using LaTeX and Beamer to do the presentation as usual. If I just copy-pasted the diagnostics, I would lose the colours. I could of course add them manually,…

Histograms with GNUPlot and LaTeX

Gnuplot is a program for plotting functions and data. It can be used for creating plots suitable for inclusion in LaTeX documents. For my master's thesis, I wanted to present some data in a stacked histogram. There are some examples on the Gnuplot web site, but I found it tricky to get it right.

Notes on Vim

This is a list of things in Vim that I have learned but find hard to remember.