RSS icon Home icon
  • Resize the RAID1 root partition without rebooting

    Posted on February 26th, 2023 admin No comments

    Resizing the root partition on a server 12 miles away seemed a bit risky. The root partition is on a software RAID1 mirror, no LVM. Twelve years ago I left only 2 GB for the root partition. I wanted to upgrade to Ubuntu 20.04.5 and the small size quickly became a problem. I managed to upgrade to Ubuntu 18.04.6 LTS, but ran out of space while upgrading to 20.04.5 LTS. Even after uninstalling previous versions, there was not enough space left. I had to make the root partition bigger. There was a relatively large 8 GB swap partition right after the root partition. The RAM is only 2 GB, so I was able to reduce the size of the swap. The plan was to delete the swap and extend the root partition, then create a smaller swapfile. I’ll show you how I did it. The server did not have to be restarted even once during the partition conversion. Finally, I have 5 GB free space after upgrading to Ubuntu 20.04.5 LTS.

    Read the rest of this entry »

  • Sort numbers before adding up!

    Posted on February 19th, 2023 admin No comments

    A few years ago my teammate came up with this statement. At first we misunderstood each other. I thought of integer numbers while he meant floating point. I know how the processor represent floats and I’m aware of how/why floating point numbers are normalized or rounded. But to be honest, I never thought the order of adding numbers is relevant. Ok, let see is it important or not. Before starting I have to say, this is all about floating point numbers, integers are not affected.

    Read the rest of this entry »

  • How to disable Windows auto sleep in AC mode with code

    Posted on February 17th, 2023 admin No comments

    It can be annoying if you use your computer 24/7 and when you don’t interact with the desktop, your machine will go into sleep after a while. If you’re using the PC remotely, you cannot bring it back from sleep. You can also turn off sleep mode manually in Power & sleep under System preferences by changing the “When plugged in, PC goes to sleep after” setting to Never.

    Or even better, you can modify it with the PowerCfg utility by invoking the following command:

    powercfg /x -standby-timeout-ac 0

    This should be a simple set-and-forget option, but surprisingly, this setting can sometimes revert to its original value. I didn’t spend time trying to figure out why the value can change, instead I got my supervisor application watch and reset the value. Here’s how I figured out (debug) how to do it with API calls, and of course I’ll show you the working source code (C++, C#, Delphi).

    Read the rest of this entry »