Skip to content

Windows Send to http-server with NodeJS

Serve any directory from web server using ‘Send to’ menu in Windows.

Install Node JS

Open command prompt, run

npm install -g http-server

Verify it works. From any directory, run


Open up Windows Explorer and enter into address bar


You should see a handful of familiar shortcuts – this maps to a folder C:\Users\<yourusername>\AppData\Roaming\Microsoft\Windows\SendTo

In that folder, create Windows shortcut to c:\Users\<yourusername>\AppData\Roaming\npm\http-server.cmd

Now you can right-click on any folder in Windows, select Send to > http-server and enjoy the folder contents served up via web server.


Detect user idle in pure JavaScript

function detectIdle() {
    var timer,
    timeout = 10; // timeout in seconds

    function idle() {
        console.log('You have been idle for', timeout, 'seconds');
        // resetTimer(); // repeated detection

    function resetTimer() {
        timer = setTimeout(idle, timeout * 1000);

    document.onmousemove = resetTimer;
    document.onkeypress = resetTimer;
    resetTimer(); // or window.onload = resetTimer;

Wacom Bamboo in Linux Mint

No Tablet Detected in Graphics Tablet app in Linux Mint 17.3

Files you need to download for amd64 systems:

If these don’t work, you can try other versions of these two packages from here:

Then run this command form that download folder:

sudo dpkg -i libwacom2_0.8-1_amd64.deb libwacom-common_0.15-1_all.deb

Now go to Menu > Preferences > Graphics Tablet and it should show up.

Left handed mode

In Graphics Tablet settings, the Left handed mode switch doesn’t work.
But it works from terminal like this:

xsetwacom set stylus rotate HALF
xsetwacom set eraser rotate HALF

Since the device naming has changed, you need to find out what stylus and eraser are now called. So enter in a terminal:

xinput --list

Then substitute the longer more descriptive device name in for stylus, with quotes around it, etc.

PHP Manager for IIS on Windows 10

PHP Manager for IIS does not install on Windows 10.

Make sure you install Visual C++ redistributables 2010 and 2012 both 32 and 64 bit. Also install .NET 3.5

Then modify HKLM/System/CCS/Services/W3SVC/Parameters/MajorVersion. The default value is 10 (Ax0). Change the value to 9 (or 8), then try to install PHP Manager again. After installation, change the value back to 10.


Fixing FreeNAS Currently unreadable (pending) sectors error

If you have redundancy, one or two bad sectors can be fixed even without any downtime.

The error message might look something like this:

10-06-2014 16:25:20 Daemon.Critical storage2 Oct  6 16:25:21 smartd[1560]: Device: /dev/ada2, 2 Currently unreadable (pending) sectors

You can see that the faulty device is /dev/ada2. Now, login to console and run long SMART test:

smartctl -t long /dev/ada2

It should tell you that the test is started and when it will finish. After it finishes, check test results:

smartctl -a /dev/ada2

The output will tell you two important things. In information section there is sector size:

Sector Size:      512 bytes logical/physical

Near the end there is SMART Self-test log which tells you whether it failed and what’s the faulty sector number (LBA_of_first_error column)

# 1  Extended offline    Completed: read failure       90%     25166         892134344

Now we have all the info we need to fix it. We will directly write to this sector to force it to reallocate. The important parameters are ‘of’ which is your faulty device name, ‘bs’ which is sector size and ‘seek’ which is sector number.

sysctl kern.geom.debugflags=16
dd if=/dev/zero of=/dev/ada2 bs=892134344 count=1 seek= conv=noerror,sync

Then check if the ‘Current_Pending_Sector’ in ‘SMART Attributes Data Structure’ table went to 0:

smartctl -a /dev/ada2

If not, repeat the long test and write to all sectors until they reallocate. Then run a scrub, replace ‘poolname’ with your poolname:

zpool scrub poolname

Finally check scrub status

zpool status -v poolname

That should do it.

Configuring Windows for high network connection rates

When a TCP/IP socket is closed, it goes into TIME_WAIT state before closing, for a period of time determined by the operating system. A socket in TIME_WAIT state cannot be reused; this can limit the maximum rate at which network connections can be created and disconnected.

The client application normally closes the socket; if the application is on a different machine, the limitation usually applies to the machine running the application. The symptoms of a machine that is reaching these limits include:

All of the TCP/IP resources of the operating system are in use, and requests for new connections fail. Running the netstat -a command on the application machine shows a large number of sockets in TIME_WAIT state.
Performance deteriorates.

To improve the ability of the Windows operating system to deal with a high rate of network connections, add the following registry entries in


A DWORD value, in the range 30-300, that determines the time in seconds that elapses before TCP can release a closed connection and reuse its resources. Set this to a low value to reduce the amount of time that sockets stay in TIME_WAIT.

A DWORD value that determines the highest port number that TCP can assign when an application requests an available user port. Set this to a high value to increase the total number of sockets that can be connected to the port.

For example, a system making a large number of connection requests might perform better if TcpTimedWaitDelay is set to 30 seconds, and MaxUserPort is set to 32678

Replay traffic with httperf

If you need to replay your live traffic on a web server, here’s how to do it using httperf:

First you need to prepare your webserver log file, which means removing all unwanted stuff like javascript, images, css etc.

Then extract the URLs from log file with e.g. awk:

awk '{print $7}' access.log > requests.log

Translate into httperf format (requests must be separated by ASCII NUL):

tr "\n" "\0" < requests.log > httperf_wlog

Finally, feed it into httperf:

httperf --server --wlog=B,httperf_wlog

If parameter B is set to ‘‘y’’, httperf will wrap around to the beginning of the file when reaching the end of the list (so the list of URIs is accessed repeatedly). With B set to ‘‘n’’, the test will stop no later than when reaching the end of the URI list.