hmage.net

Hello and welcome to my (pretty much empty) site!

I make music, I code, I DJ, I eat tea.

Music

You can listen to my music here:

I also have Twitter where I spam random nonsensical stuff — feel free to chat up with me there, I won't bite… unless you want me to.

Projects

I also have some projects in various stages of completeness (and abandonment):

Random notes

This site is mainly used as my personal notepad for random scribbles – In some situations it's very hard to google them later. To avoid wasting my time I'm putting them up here. So here they go. In random order.

coding

Snippets:

  • C89 standard section 3.5.7 — omitted entries in the initalizer list are defaulted to being assigned 0. This is valid C89:
  • main() {
        int array[100] = {104, 5}; /* initializes rest to 0 */
        struct blah {int a; int b; char c; void* d;} blah = {10}; /* initializes rest to 0 */
        return 0;
    }
  • Show which options -march=native will enable:
    gcc -march=native -Q --help=target

    alternatively more verbose

    gcc -fverbose-asm -x c - -S -o - < /dev/null
  • Show difference in effective flags between -march=native and -march=haswell:
    diff -uw <(gcc -fverbose-asm -march=haswell -x c - -S -o - < /dev/null | sed "1,/options enabled/d") <(gcc -fverbose-asm -march=native -x c - -S -o - < /dev/null | sed "1,/options enabled/d")
  • Show GCC's built-in preprocessor defines:
    gcc -dM -E - < /dev/null | sort
  • Make git think ignore deletion of files, useful for big blobs:
    git ls-files --deleted -z | git update-index --assume-unchanged -z --stdin
  • Show default pkg-config search paths:
    pkg-config --variable pc_path pkg-config

Hashing and Avalache tests

security

unix

Snippets:

  • List installed dpkg packages sorted by size (in kilobytes):
    dpkg-query -Wf '${Installed-Size}\t${Package}\n' | sort -n
  • Prevent an OSX partition from automounting in /etc/fstab:
    UUID=FAB060E9-79F7-33FF-BE85-E1D3ABD3EDEA  none     hfs    rw,noauto
  • Tar into archive sorted by extension:
    find directory | rev | sort | rev | tar cv -T - --no-recursion | xz > directory.tar.xz
  • Tame APT from getting translations and keep it from installing unwanted packages:
    echo 'Acquire::Languages "none";' > /etc/apt/apt.conf.d/zz-local-tame
  • Prevent NTP server from panicking inside suspended VM's:
    tinker panic 0
  • Remove duplicate lines without sorting:
    awk '!x[$0]++'
  • Avoid creating temporary files to feed as filename:
    diff -u <(sort /etc/passwd) <(shuf /etc/passwd | sort)
  • Dump backtraces for all processes in pidlist:
    for i in $pidlist; do gdb -batch -n -ex 'thread apply all bt' -p "$i"; done
  • Fix slow SMB on OSX 10.11+:
    printf "[default]\nsigning_required=no\n" | sudo tee /etc/nsmb.conf >/dev/null
    sudo defaults write /Library/Preferences/SystemConfiguration/com.apple.smb.server SigningRequired -bool FALSE
    sudo /usr/libexec/smb-sync-preferences
  • To disable modesetting inside qemu, add this to kernel command line:
    fbcon=map:99
  • Put Dropbox on OSX to use background IO scheduler:
    lldb -p `pgrep Dropbox`
    expr (int)setiopolicy_np(0, 0, 3)
    quit
  • Make time machine normal priority:
    sudo sysctl debug.lowpri_throttle_enabled=0
  • Force hostname instead of DHCP-given:
    sudo scutil --set HostName <newname>
  • Enable screen sharing from command line:
    sudo defaults write /var/db/launchd.db/com.apple.launchd/overrides.plist com.apple.screensharing -dict Disabled -bool false && sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.screensharing.plist
  • List all excluded items in Time Machine:
    sudo mdfind "com_apple_backup_excludeItem = 'com.apple.backupd'"
  • Show exclusions that were active in latest backup:
    sudo defaults read /Volumes/Time\ Machine\ Backups/Backups.backupdb/*/Latest/.exclusions.plist
  • Remount OSX volume with noatime:
    mount -vuwo noatime /Volumes/FADownloader
  • Make HFS+ volume acceptable for Time Machine on newer OSX:
    mkdir Backups.backupdb

Video

Browser-based benchmarks

Other