Sunday, April 21, 2019

Variable arguments for assert

The following is a code snippet that shows how to support allowing variable arguments to be passed to assert.

#include <stdio.h>

#define __ASSERT_INT(COND, format, ...)             \
    do {                                            \
        if (!COND) {                                \
            printf(""#COND);                        \
            printf(" ");                            \
            printf(format "%s", __VA_ARGS__);       \
        }                                           \
    } while (0)
#define ASSERT(COND, ...) __ASSERT_INT(COND, __VA_ARGS__, "\n")

main() {
    ASSERT(0==1, "here");
    ASSERT(0==1, "and here %d", 2);
    return 0;

Monday, June 05, 2017

Launch Emacs for Windows with Batch File using Emacs Configuration from Cygwin

I maintain a shared Emacs configuration under Linux and Cygwin. In Windows, I wanted to easily launch Emacs from the Desktop with the following goals.

  • Create a shortcut in the taskbar that launches Emacs for Windows
  • Have Emacs for Windows obey the Emacs configuration from Cygwin
  • Avoid opening extra console windows

Some prerequisites,

I created a file called c:\cygwin64\emacs.bat with the following contents.
c:\cygwin64\bin\run bash.exe -c ~/dotfiles/bin/

The file ~/dotfiles/bin/ is a shell script that sits in my Cygwin directory. It is a wrapper script that calls Emacs for Windows if I'm running Cygwin.

It is assumed that the default Emacs configuration sits in the ~/.emacs file under Cygwin.

Pin the c:\cygwin64\emacs.bat script to your task bar. See below if you do not know how to do this. Clicking on it will open Emacs for Windows without any intervening console windows.


Monday, May 29, 2017

Restore Nexus 5X Stuck in Boot Loop

If your Nexus 5X gets stuck in a boot loop after upgrading to Android O, you can try to restore the previous Andriod version. You will to download the following

  • Android Debug Bridge
  • Full OTA image for your device

Boot to the recovery console and select install from ADB.

Open a command prompt and go into the platform-tools folder of the Android Debug Bridge.

adb sideload <PATH TO OTA ZIP FILE>

Reboot the device upon completion.

You do not need to install any USB drivers.


Monday, April 03, 2017

Monday, July 11, 2016

Web Browsers Prevent System from Going to Sleep

Your web browser may prevent your system from going to sleep. You can override this by running the following commands in an elevated command prompt. Note, the commands below sets the override for Chrome, Firefox, and Edge.

powercfg /requestsoverride PROCESS chrome.exe AWAYMODE DISPLAY SYSTEM
powercfg /requestsoverride PROCESS firefox.exe AWAYMODE DISPLAY SYSTEM
powercfg /requestsoverride PROCESS MicrosoftEdge.exe AWAYMODE DISPLAY SYSTEM


Wednesday, June 29, 2016

Show Workweek in Windows System Tray

T-Clock is a utility that provides a more flexible date and time display in the system tray. It also includes the ability to show the work week.

Download (

Monday, September 07, 2015

Remove undeletable partitions on flash cards

There are times when partition manager won't let you remove partitions on a flash card. To remove these partitions, it is necessary to run diskpart.

Invoke diskpart in administrator mode.

list disk
select disk X (where X is the disk you wish to clear the partition table)

At this point, you can proceed to create a new partition using diskpart or creating a new partition using the partition manager.