Tech Notes 1

A monthly-ish run down of some things I learned while using a computer.

Faster Cursor on Mac

My cursor speed was too slow, but I already had the speed maxed out in System Preferences. Thankfully you can use defaults command line tool to increase the mouse speed beyond what you can do in the UI.

# read your current mouse speed
defaults read -g com.apple.mouse.scaling

# Set it to > 3, requires a restart to take effect
defaults write -g com.apple.mouse.scaling 9

There are plenty more things you can change with this tool, do man defaults to learn more.

Better Shell Scripts

Batch and Bash scripts are never elegant, but they are also the lowest common denominator and they get the job done. The minimally safe bash script template was doing the rounds on Hacker News a while back with some handy advice for making bash a bit less error prone.

One of the best tips was having the script exit on the first failed command. While it seems windows dosen't have a way to exactly replicate that behavior, I was able to get something similar.

: task 1
commandThatMightFail || goto :error

: task 2
... something else

goto :EOF
:error
echo Failed with error code %errorlevel%.
exit /b %errorlevel%

Using the || syntax means 'run this command if the previous one failed'. The goto :error then jumps to the error label, prints a message, and exits, passing out the error level from the failing command.

If you want to learn more about writing bash I found this enlightening StackOverflow post. You could even read the Advanced Bash Scripting Guide.

ditto and rsync

rsync is like a fancy version of recursive cp. It is geared towards copying things over the network by doing compression, deltas, and skipping unchanged files.

rsync -az --exclude=".DS_Store" --progress built/site network/site

# -a                        recursive archive
# -z                        compress transfer
# --exclude=".DS_Store"     skip certain files
# --progress                show copy progress

ditto does something similar, but it can also create .zip files in the process and has solved some issue I've encountered in the past with cp breaking symlinks inside .app bundles.

# copy 1 folder to another, add -v for verbose
ditto movies backup/movies

# zip at the same time.
ditto -c -k --keepParent ${APP_NAME}.app ${APP_NAME}.zip

# -c -k         creates a zip archive
# --keppParent  include the source directory in the output
#                e.g. MyApp.zip/MyApp.app/{Contents,Resources,etc.}

Use man ditto and man rsync to learn more.

Organising Photos.app Libraries

I use the default Photos.app on mac to store my photos going back ten years and counting. However through some dumb mistakes with my 'backup' system, I ended up with a bunch of duplicate photos.app libraries, each with slightly different content...

Thankfully there were a couple apps that helped me sort out the mess I made. Both these apps cost money. Think about your own photos and decide if it's worth it for you. Also this is not necessarily the best way, but it's been working for me.

Duplicate File Finder Pro

First I used this to eliminate duplicates between libraries. With Duplicate File Finder Pro that means dragging both libraries onto the app, letting it scan for a while, then choosing 'Select Duplicates In Folder' to select the library I want to eliminate duplicates from. It can also eliminate duplicates within a single library and in fact find any duplicates in any old folders or drives.

There are lots of tools out there that claim to help eliminate duplicates but it's hard to know what to trust with your precious data. This one did what I needed it to well, plus has a heap of other features that could come in handy.

PowerPhotos

Once I have eliminated duplicates, I use PowerPhotos to merge the libraries. PowerPhotos also does a bunch of other things, just skim the website. Come to think of it, PowerPhotos also apparently can eliminate duplicates, not sure why I needed Duplicate File Finder Pro...

Anyway these are the apps my brother recommended after fixing his own photo library meltdown. Worked for him, worked for me.

Logitech MX Keys

After spending far too much on keyboards (Microsoft Ergonomic, Ergodox EZ, Das Ultimate 4, Apple Magic Keyboard) plus trying out some mechanical ones, and being disappointed by all of them in one way or another. I decided to get off the 'keyboard hypetrain' and go back to a cheapo £10 wired usb keyboard. I've been using the same one for 3+ years now and it's fine.

Recently however I was gifted a Logitech MX Keys and I must admit it is nice. The bluetooth feels very responsive so far (The MS Ergo would become laggy randomly), and it can switch between up to 3 different machines almost instantly with a single key press. Tastefully printed keycaps with both mac and pc symbols and comfortably spaced and shaped keys (the Das Ultimate 4 keys were too far apart, causing RSI after a couple hours for me).

I've only had the MX Keys a week so far, the real test will be how I feel after a few years, but it's persuaded me to put away my trusty £10 keyboard for the time being.