Making swapping scalable

The swap subsystem is where anonymous pages (those containing program data not backed by files in the filesystem) go when memory pressure forces them out of RAM. A widely held view says that swapping is almost always bad news; by the time a Linux system gets to the point where it is swapping out anonymous pages, the performance battle has already been lost. So it is not at all uncommon […]

Quick Sort Implementation in C

Quicksort is an efficient sorting algorithm, serving as a systematic method for placing the elements of an array in order. Developed by Tony Hoare in 1959, published in 1961, it is still a commonly used algorithm for sorting. When implemented well, it can be about two or three times faster than its main competitors, merge sort and heapsort. Quicksort is a comparison sort, meaning that it can sort items of […]

Sort a Scrambled Itinerary

This algorithm problem is from Google Code Jam. Here is the description of the problem. Once upon a day, Mary bought a one-way ticket from somewhere to somewhere with some flight transfers. For example: SFO->DFW DFW->JFK JFK->MIA MIA->ORD. Obviously, transfer flights at a city twice or more doesn’t make any sense. So Mary will not do that. Unfortunately, after she received the tickets, she messed up the tickets and she […]

Web server in one line of shell code

If you want to quickly save a file through http but you don’t want to install a web server, you can just use netcat. You can run: index.html can be any file you want to serve it. You can access it after that as: http://<YOUR HOST>:8080/