#Misc Notes

Today-I-Learned

// misc notes

Disabling Hyper-V in Windows 11

  • If you need AVX/AVX2 instruction sets on your VBox VM, you’ll need to disable Hyper-V. Run these commands in Powershell:
bcdedit /set hypervisorlaunchtype off
# maybe need this line
DISM /Online /Disable-Feature:Microsoft-Hyper-V
# shut down completely
shutdown -s -t 2
  • However, in new windows 11 installations, you also have to disable the Memory Integrity feature to get rid of Hyper-V. Search for ‘Core Isolation’ in Windows Settings and turn off the memory integrity feature. Reboot and you’re golden.

Images and EXIF

  • Apparently, when you snap a picture with an iPhone in portrait mode, pixel data is saved as landscape and its orientation added in its EXIF. This means you gonna get hurt real bad (like me) if you’re not careful when preparing data for training a model.
  • Fortunately, pillow has a great module for transposing images:
import os, glob
from PIL import Image, ImageOps

count = 0

def mylistdir(directory):
  """A specialized version of os.listdir() that ignores files that
  start with a leading period."""
  filelist = os.listdir(directory)
  return [x for x in filelist
          if not (x.startswith('.'))]

for dirName in mylistdir(os.getcwd() + '/img'):
  dirPath = os.getcwd() + '/img/' + dirName + '/*.jpg'
  for infile in glob.glob(dirPath):
    img = Image.open(infile)
    rotated_img = ImageOps.exif_transpose(img)
    rotated_img.save(infile)

    count += 1

print('Transposed %d images' % count)

Google Cloud SDK

  • gsutil rsync will sync OS-related files and symlinks if you don’t supply it with the necessary flags. This one worked particularly well for me:
# https://stackoverflow.com/a/35210687
gsutil -m rsync -r -d -e -x '\..*|.*/\.[^/]*$|.*/\..*/.*$|_.*' [YOUR_DIRECTORY] gs://[YOUR_BUCKET]

UniFi Controller

Unifi Network Application v8.1 has begun supporting MongoDB 7.0, which requires a ARMv8.2-A processor.