Dual boot with UEFI

Install Windows first. The setup creates an EFI partition, most likely as /dev/sd?2. We’re gonna need that later. Then turn off fast boot. Enter

powercfg -h off

on the command prompt. Make sure that you have local admin rights. Fast boot is incompatible with dual boot. You’ll get blue screens with repair options otherwise. While at it, set the system clock to UTC. Create this DWORD registry key:

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\TimeZoneInformation\RealTimeIsUniversal

and set it to “1”.

Then install linux and mount /dev/sd?2 from above to boot. Then create a new file named arch.conf in /boot/loader/entries:

title   Arch Linux
linux   /vmlinuz-linux
initrd  /initramfs-linux.img
options root=UUID=$(blkid /root/partition) rw audit=0

The paths are relative to /boot, so vmlinuz-linux should be /boot/vmlinuz-linux. Next edit /boot/loader/loader.conf:

console-mode auto
default arch
timeout 5

Assuming that you’re using systemd-boot, run bootctl install and bootctl update, reboot and be happy!

How to create a QIcon with Qt programmatically

First, create a 32×32 QImage and make it transparent (or whatever background color you need):

QImage img(32, 32, QImage::Format_ARGB32);
img.fill(QColor(0, 0, 0, 0));

I use QImage instead of QPixmap, because the documentation says that QImage is optimized for I/O, e.g. painting, and the first attempts with QPixmap looked like crap. Next, create a QPainter for the QPaintDevice and set some render hints to make it look nice:

QPainter *p = new QPainter(&img);
p->setRenderHint(QPainter::Antialiasing);
p->setRenderHint(QPainter::TextAntialiasing);
p->setRenderHint(QPainter::SmoothPixmapTransform);

QPainter::setBrush() sets the background color for shapes, QPainter::setPen() the foreground color for text:

p->setBrush(QColor(Qt::red));
p->setPen(QColor(Qt::white));

Then select a font the size of our future Icon:

QFont f("courier new");
f.setPixelSize(32);
p->setFont(f);

Now we need some background. White on transparent isn’t really readable, so let’s draw a circle:

p->drawEllipse(img.rect());

Since our QImage is actually a square and not an rectangle, QPainter::drawEllipse will draw a circle. Print the QChar, letter, or whatever:

p->drawText(img.rect(), Qt::AlignCenter, QChar(char));

Now clean up and return the QImage as QIcon:

delete p;
return QIcon(QPixmap::fromImage(img));

The whole shebang can be marveled at here. It looks like this:

Have fun!

Update QT under Windows

Well, another lesson in How To Complicate Things ™. Could be as easy as pacman -Syu, run qmake and recompile all, but far from it 🙁

  1. Run MaintenanceTool.exe. Of course it has no entry in the start menu, why should it. But it’s easy to find: C:\Qt\MaintenanceTool.exe
  2. Skip the first page, you don’t need an account. God, how I hate this shit!
  3. On the next page, select “Add or remove components”. “Update components” will only update your *current* version. To install a *new* version, you have select the first option.
  4. Wait…
  5. Select the version you want to install and wait, but take a look while it’s installing. Ignore the errors, it’ll work anyway

Once the installer finished with errors, open QtCreator and load your project. Now you have to manage your “Kit”. Select “Project” on the left sidebar, “Build & Run” on top and then click “Manage kits…”

  • Click “Add” and select the new version for “Debugger” and “Qt version”
  • Give it a “Name:”. Best to copy the string from the Auto-detected version
  • Apply
  • Now change the Kit of your project to the new one. The thingy above “Build|Run” right beside “Manage Kits…” is a drop down box, even if it doesn’t look like it
  • Change the build directory accordingly
  • Clear the environment by selecting “Build” instead of “Run”. Then expand “Build Environment” at the bottom and check “Clear system environment”
  • Select “Run” and set “Base environment for this configuration” to “Build environment”

If you don’t need SQL-Plugins, clean all, run qmake and compile. If you need access to, say, a Postgres-DB, the fun doesn’t end yet. To connect to the database, you have to add the directory with libpq.dll to the PATH. Yes, to the PATH environment variable! WTF? For now that would be “C:\psql\9.5\bin”.

If you create a new project, don’t forget to add

QT       += sql
LIBS     += "C:\psql\9.5\lib\libpq.lib"

to you .pro-file.

If you build a release, don’t forget to copy the dll-files to the release directory. For a QT-Gui application those would be at least:

  • libeay32.dll
  • libecpg.dll
  • libecpg_compat.dll
  • libgcc_s_dw2-1.dll
  • libiconv-2.dll
  • libintl-8.dll
  • libpgtypes.dll
  • libpq.dll
  • libstdc++-6.dll
  • libwinpthread-1.dll
  • libxml2.dll
  • libxslt.dll
  • Qt5Core.dll
  • Qt5Gui.dll
  • Qt5Sql.dll
  • Qt5Widgets.dll
  • ssleay32.dll
  • zlib1.dll

Well, I hope I didn’t forget anything. See you next time!

Windows 10 Update

I had another fight with my Windows 10 VM after realizing that it didn’t get all the updates my other Win10 box got. Turns out I was stuck at Build No. 10240.

Why? Because the VM had the wrong Processor! <sarcasm attr=”biting”>Obvious, isn’t it?</sarcasm>

After Downloading the installer Windows10Upgrade28084.exe (WinVer 1607, build 14393) for a manual upgrade, it failed with a blue screen:

SYSTEM_THREAD_EXCEPTION_NOT_HANDLED

Quite self-explanatory, right? Well, all you have to do is to set the virtual CPU type to core2duo and limit the VM to 1 socket. Silly me! Why didn’t I think of that in the first place? It’s so obvious!

Once the upgrade is installed, you can change it back to anything you want. Thank you so much, Microsoft!

This update orgy is getting worse every time. ‘Nuff said 🙁

Remote git from Windows

To push your latest code ejaculations to a remote repository, e.g. for making it available via cgit:

Create a bare remote repository:
$ cd /path/to/repository
$ git init --bare
Add the remote repository
c:\repo> git remote add <name> ssh://server.tld.domain:/path/to/repository
c:\repo> git push --set-upstream <name> <branch>

You must have write permissions on /path/to/repository, and you have enter the password manually, so do it from cmd.exe. I guess you could setup a windows SSH agent, but I don’t trust it. Who knows what it sends where…

And then…

… it’s just as easy as:

c:\repo> git push

That’s all, folks!

Printing troubles

In a painful, tedious quest to make my OKI B431dn actually print from a Windows VM I learned several things:

  1. First and foremost: It really, really helps if your printer doesn’t share the IPv4 address with your TV (even if it’s turned off!)
  2. Thinking that you can get the IPv6-stacks on embedded devices such as said printer to work is just wishful thinking
  3. That I (fortunately) didn’t set an admin password for my printer
  4. That my SAMSUNG TV is still online even on standby

To elaborate: My quest started, because I wanted my Windows 10 VM to print. Easy enough, you’d think, but nothing is as easy as it seems 🙁

Adventure Levels:
  1. Fight with cups and Windows and encryption (http vs. https). That was a red herring.
  2. Fight with Samba, shared printers and Windows: another red herring
  3. Fight with different drivers or PPDs
  4. Find out that printing via localhost cups is also painstakingly slow
  5. Eventually figure out that the printer shares the IP with my TV
Solution:
  • Change the IPv4-adress of the printer, turn off IPv6 and only use the (now unique) IPv4-adress.
  • Use the URLs provided by the printer web page
Remarks:

Still don’t know why printing via IPv6 didn’t work as it should, because the printer’s IPv6-address was pretty unique, but what do I know… Anyway, after applying the solution using the generic cups postscript driver and the installed windows postscript driver, printing started after seconds instead of minutes, so problem solved 🙂

Adding a custom icon to an application – Windows 10

Wow, it just took me the better part of an hour to figure out how to pin a custom program to the taskbar with a custom icon! If the .exe doesn’t contain an application icon, the task bar icon is replaced by the default icon on exit.

Well, my program does contain an icon (it’s a QT App), but Winblows doesn’t care. Maybe because it’s a PNG instead of ICO, but who knows.

The Würgaround: create a shortcut for the executable, then right-click for properties and voila, there’s a “Change icon…” button! Change the icon to whatever, start the App via the shortcut and pin it to the taskbar!

This is wrong in so, so many ways… Don’t even get me started 🙁

Powershell and square brackets

Have you ever tried mass renaming files with square bracket in the path? Then I’m pretty sure you failed, because you can’t escape them easily. You have to do it manually by setting up temporary variables and replace ‘[]’ by ‘“[“]’.  It’s a nightmare. Find a box with a bash shell or install cygwin. Then simply do this:

$ for i in * ; do mv "$i" "newname $i" ; done

instead of this shit! That makes PowerShell almost useless for file operations 🙁

How to get rid of Adobe Flash

How to remove

It’s not as easy as it seems. First of all, do not use the official Uninstaller from Adobe. I don’t know what it does other than showing a reverse progress bar, but it certainly does not remove the Flash-Crap from your computer.

To remove it for good, you have to jump through several hoops:

  1. Close every program using Flash, like IE (if you’re using this piece of shit) or Firefox. AFAIK Chrome has its own plugin, but it can’t hurt to close it, too
  2. Open the Explorer and go to C:\Windows\System32. Select the Macromed-Folder and take ownership. Then grant yourself full access including all subdirectories.
  3. Delete the Folder
  4. Do the same in C:\Windows\SysWOW64.
  5. Take ownership of C:\Windows\SysWOW64\FlashPlayerApp.exe and C:\Windows\SysWOW64\FlashPlayerCPLApp.cpl, grant yourself full access and delete the files
  6. Go to %appdata% and remove the Macromedia\Flash directory
  7. Reboot (surprise!)
  8. Check that the Flash-Crap is gone from the control panel
  9. Open this link in Edge or IE to see if Flash is gone for good
  10. If you’re using Chrome, disable the plugin in about:plugins

What else can I do?

If you’re monitoring your Windows-Box with check_mk, you can use these scripts to check for Flash.

Put this into C:\Program Files (x86)\check_mk\local\check_flash.ps1 or wherever your check_mk agent is installed

$items = "C:\Windows\System32\Macromed",`
"C:\Windows\SysWOW64\Macromed",`
"C:\Windows\SysWOW64\FlashPlayerApp.exe",`
"C:\Windows\SysWOW64\FlashPlayerCPLApp.cpl"

echo "<<<flash_gordon>>>"

foreach ($i in $items){
 if(Test-Path $i){
  echo ("{0} 1" -f $i)
 }else{
  echo ("{0} 0" -f $i)
 }
}

Now put this script into ~siteuser/local/share/check_mk/checks/flash_gordon:

#!/usr/bin/python 
 
def inventory_flash_gordon(info): 
    inventory = [] 
    for line in info: 
        inventory.append((line[0], line[1])) 
 
    return inventory 
 
def check_flash_gordon(items, params, info): 
    retstring = "Good, no Flash-Crap found!" 
    found = [] 
    retval = 0 
    for line in info: 
        if int(line[1]) > 0: 
            found.append(line[0]) 
 
    if found: 
        retstring = "Crap, found %s" % ', '.join(found) 
        retval = 2 
 
    return (retval, retstring) 
 
check_info["flash_gordon"] = { 
    "check_function":   check_flash_gordon, 
    "inventory_function":       inventory_flash_gordon, 
    "service_description":      "Check for Adobe Flash Crap", 
    "has_perfdata":             False, 
}

Reinventorize. Now the host goes CRITICAL if any part of Flash is found.

[Update 2015-12-09]

I hate this crap! Windows Update decided that I need a security update for Flash, even though it isn’t installed any more. What the fuck? Of course the update fails, but in their wisdom they decided to remove the option to hide updates from the Windows 10 dialog. Now you have to use this program 🙁

Anyway, I only noticed it because of check_mk. At least now I know it works 🙂 Let’s see when this bites my ass…

[Update 2015-12-30]

What a clusterfuck! Another Windows update for flash. Thanks to check_mk I noticed it right away. Shouldn’t be too difficult to check for this crap before installing the update, right?

[Update 2016-11-10]

Finally got tired of removing this crap manually again and again! Since you can’t prevent Windows Update from installing this shit, I wrote a script to put it where it belongs. You need the Powershell Community Extensions (PSCX) for it to work. Install then, download the txt, remove the txt-Extension and replace the owner with whatever is appropriate.

Have fun!