software engineering

IIS .woff MIME type

By Adam K Dean on

IIS does not have a MIME type set up for woffs. I don' t like this, it throws errors like this one:

GET http://localhost/fonts/glyphicons-halflings-regular.woff 404 (Not Found)

To fix this, add a MIME type for .woff as application/x-font-woff.

Don't just add application/x-woff or you'll get Chrome nagging you about resources interpreted as fonts but transferred with MIME types of application/x-woff.

Adding Windows back to grub

By Adam K Dean on

After my previous post, I sit here with a working grub installation, but it doesn't yet allow me to boot into Windows.

This is really easy.

$ sudo update-grub
[sudo] password for adam: 
Generating grub.cfg ...
Found linux image: /boot/vmlinuz-3.11.0-22-generic
Found initrd image: /boot/initrd.img-3.11.0-22-generic
Found linux image: /boot/vmlinuz-3.11.0-12-generic
Found initrd image: /boot/initrd.img-3.11.0-12-generic
Found memtest86+ image: /boot/memtest86+.bin
Found Windows 7 (loader) on /dev/sda1


Error file '/grub/i386-pc/normal.mod' not found in Ubuntu 13.10

By Adam K Dean on

As I'm working less and less with the Microsoft stack and more and more with the Node stack, I decided it would be a good idea to develop on Linux. Ubuntu is the choice at work so to keep it consistent, I thought I'd try it at home. 14.04 LTS had some quirky bugs so I installed 13.10 to some space I made.

But after installing, grub decided to throw me a nasty message.

Error: file '/grub/i386-pc/normal.mod' not found

I knew this had something to do with UEFI. I hate UEFI. SecureBoot is nothing but trouble. I tried many things but finally went to bed. Now, I'm writing this from a working installation. This is how I fixed it.

I booted into a Live environment, opened the terminal, and mounted the installation and chrooted into it. I had Windows siting on /dev/sda1 and /dev/sda2, and installed Ubuntu to an Ext4 partition which was /dev/sda3:

$ sudo -s
# mount /dev/sda3 /mnt
# mount -t proc none /mnt/proc
# mount -t sysfs none /mnt/sys
# mount -o bind /dev /mnt/dev
# mount -o bind /tmp/ /mnt/tmp
# chroot /mnt

Next I removed the grub EFI packages:

# apt-get remove --purge grub-efi-amd64 grub-efi-amd64-bin

Next I tried to re-install the grub pc packages, but had a strange error about resolving To fix this, I had to add some entries to the /etc/hosts file:

Now I reinstall grub pc packages:

# apt-get --reinstall install grub-common grub-pc os-prober

When the screen pops up asking about where to install grub, I just selected /dev/sda. After that, reboot your machine and you might be in luck. If not, you could go and ask over at #ubuntu on freenode, though you probably won't get an answer.

Count number of files deleted between Git commits

By Adam K Dean on

To count the number of files deleted between two Git commits, use the following command:

$ git log --diff-filter=D --summary 45b0487..HEAD | grep 'delete mode' | wc -l

Be sure to change 45b0487 to the commit you want to count from, or remove 45b0487..HEAD altogether to look through the entire history.

We use grep to count the number of deleted files.

$ git log --diff-filter=D --summary | grep 'delete mode'

delete mode 100644 test (3).txt
delete mode 100644 test (4).txt
delete mode 100644 test (2).txt

Then we use wc -l to do a line count:

$ git log --diff-filter=D --summary | grep 'delete mode' | wc -l

Sometimes you get whitespace back from wc -l, you can trim that with tr:

$ git log --diff-filter=D --summary | grep 'delete mode' | wc -l | tr -d ' '


This may take some time for larger repositories.

Find IP address of Docker container

By Adam K Dean on

To get the IP address of a Docker container, use the following command:

$ docker inspect --format '{{ .NetworkSettings.IPAddress }}' ${CID}

So let's say the ID of the container is a2150s, we could get the IP like so:

$ docker inspect --format '{{ .NetworkSettings.IPAddress }}' a2150s

I have written a script for this, /usr/local/bin/dockerip:


COUNT=`docker ps | grep $1 | wc -l | bc`

if [ $COUNT -gt 0 ]; then
  IP_ADDRESS=`docker inspect --format '{{ .NetworkSettings.IPAddress }}' $1`
  echo "$1: $IP_ADDRESS"
  echo "Could not find $1. Check container is running."

This will form part of a repository of useful docker scripts.