Dark's Code Dump

Possibly useful

How to actually reduce battery drain on Android

This assumes you’ve tried all the normal methods of reducing drain – apps like BetterBatteryStats, Wakelock Detector, etc, the built-in battery stats, trimming permissions, using Pie background restrictions, etc.

I very rarely see this mentioned anywhere when people are trying to track down mysterious Google Play Services/Android OS/Android System drain – most people seem to resort to a factory reset, which won’t fix the problem when the issue lies in dodgy apps.

The fix is really simple:

(more…)

Print tar label without reading entire tar archive

GNU Tar lacks an option to print the tar label and exit immediately – it can only print the label as part of reading the whole archive. This works ok-ish for hard disks where ctrl+c is instant and without side effects, but is unsuitable for tape drives.

The following simple perl one-liner prints the label from a tar archive passed in stdin:

cat my.tar | perl -e 'read(STDIN, $header, 100); print(unpack("Z100", $header)."\n");'

Sometimes you get weird shit at the start of tar archives like ‘/tmp/GlobalHead’, in which case you can use this hacky alternative approach:

cat my.tar | strings | grep volume.label | cut -d \= -f2

You can see a use case for this in my post on LTO tape drives: https://darkimmortal.com/2018/10/adventures-with-lto-tape-for-home-casual-use/

How to merge old VirtualBox snapshots into single VDI

I was recently faced with a situation where I had a the data of an old VirtualBox VM including .xml file, .vdi/.sav snapshots and main .vdi hard disk from 2012 that I wanted to merge into a single .vdi.

Crucially these files were from another machine and not registered/present in any way in my active copy of VirtualBox.

There doesn’t seem to be a clear set of instructions for doing this online, but the process is:

  1. VBoxManage showhdinfo [harddisk.vdi]
    • Note ‘showhdinfo’ is, confusingly, not just showing the info but also registering the disk so VirtualBox can find it later
  2. VBoxManage showhdinfo [snapshot.vdi] for each of the snapshots in order of oldest to newest
  3. VBoxManage clonehd [newest-snapshot.vdi] [output.vdi]

Adventures with LTO Tape for Home/Casual Use

I’ve spent the past while buying and experimenting with some old LTO gear as a secondary backup solution besides backing up to both local disks and cloud. I chose LTO because:

  • My upload speed is trash so the only way I can hope to do a full off-site backup is via physical media
  • With LTO4, it works out cheaper than buying about 2-3x 2+TB external hard disks, especially if you go SCSI instead of SAS.
  • I have the option of taking tapes out of rotation and storing them long-term. With hard disks this is risky and expensive.
  • Good for air hand luggage
  • It’s old school cool

My learnings and notes follow…

(more…)

eBay support literally encouraging fraud

Goes without saying that I’m returning the item manually and not following their advice!

02:34:36 UTC (me)

Hello, I recently opened a return and the seller has sent me a refund before I had a chance to print the postage label, and now the option to print a postage label has disappeared. How can I get the postage label to return the item with?

02:35:43 UTC (ebay support)

Alright, thank you for the confirmation and sharing the details with me. I can understand that you are concerned about the return case in which you received the item and refund both. I will look into it and help you with best possible resolution from my side.

02:36:33 UTC (ebay support)

Just to confirm, are you referring to item “redacted”?

02:36:47 UTC (me)

yes that's the one

02:38:06 UTC (ebay support)

I have checked the case details and found that case is closed as seller has issued the refund to you. Now, you are not required to take nay further action in this. You can keep the item or you can return it by communicating with seller. However, the case is closed so no further action is required.

^ What the literal fuck

(more…)

VW Composition Media M3U playlist bug

Spent the best part of 2 days trying to figure out why the composition media system (same probably applies for discovery media system) in a MK7.0 VW Golf was failing to read M3U playlists, with the error “No playable files found”.

Tried every combination imaginable of file paths, separators, line endings, and even went as far as writing a script to generate extended m3u data from a plain m3u, but nothing made any difference.

The fix turned out to be very simple: have more than one folder on the SD card with MP3 files in it. The software must have a special case for all MP3 files in one folder that (probably unintentionally) breaks playlists. Even a single mp3 file in a second folder is enough to kick it into life.

Once this fix is in place the M3U support is pretty comprehensive – plain or extended and a variety of line endings and path separators all work fine.

Disable touchpad acceleration on Debian Stretch (libinput, KDE Plasma)

For some unknown reason, there is no option exposed to disable acceleration when using a laptop touchpad with libinput. [insert gamer-oriented argument about how mouse acceleration is incompatible with muscle memory]

Thankfully it isn’t too difficult to remove it in the source code and recompile libinput.

  1. cd to a suitable empty folder
  2. apt-get source libinput10
    sudo apt build-dep libinput10
  3. cd to the downloaded folder (e.g. cd libinput-1.6.3)
  4. Edit the file src/filter.c, find:
    #defined TOUCHPAD_ACCELERATION 9.0
    And replace with:
    #defined TOUCHPAD_ACCELERATION 1.0
  5. debuild -b -uc -us
  6. Glance over the output to make sure build has succeeded
  7. cd ..
    sudo dpkg -i libinput10_1.6.3-1_amd64.deb
    sudo dpkg -i libinput-bin_1.6.3-1_amd64.deb
    (update version number as necessary)
  8. Reboot

Slow upload on Kimsufi server

Recently I spent far too long diagnosing a slow upload speed on a low-end Kimsufi 2G server with an old SiS900 ethernet adapter. The download speed was full 100mbit, but upload was less than 0.1mbit. The issue did not persist into rescue mode, which led me to assume a software issue.

The symptoms matched an issue with TCP windows, or with half duplex vs full duplex, but neither of those turned out to be the case.

The issue turned out to be IRQ related. Simply blacklisting a few unnecessary modules (parallel port, sound) and disabling acpi solved the issue

2018 update:
The exact steps you should take:

Create /etc/modprobe.d/blacklist.conf, containing:

blacklist snd_intel8x0
blacklist ppdev
blacklist parport
blacklist parport_pc

In /etc/default/grub, add acpi=off to GRUB_CMDLINE_LINUX_DEFAULT and rebuild your grub config.

Fix for Gigabyte motherboard boot loop on resume from sleep

From what I’ve read, this seems to affect a large percentage of Gigabyte motherboards since S3 sleep became a ‘thing’.

The issue is as follows: on a significantly overclocked Gigabyte motherboard (high end or low end), when resuming from S3 sleep the screen never wakes up and after about 15-20 seconds, the system repeatedly turns off and on again every few seconds. The only way to break this loop is to completely remove power from the PSU for several seconds.

The issue is connected with PCIe power, as evidenced by the various reported fixes of disabling onboard NIC power saving and reverting from Intel/AMD AHCI drivers to the Microsoft default ones.

The real fix is very simple: Use Balanced power mode in windows and check that PCI Express Link State Power Management is set to ‘Moderate Power Savings’ and not ‘Off’. The fact that the default setting of moderate does not have the issue explains why it is not more widely reported.

Fix for last.fm scrobbler not working on Windows 8

Since the 2.1.30 update, if your media player is running as admin (this may only apply to Winamp), the scrobbler needs to run with admin privileges too.