IPv4 netmask conversions (Bits / Decimal / Hexadecimal / Binary)

Bitmask (Bits) Dotted Decimal Hexadecimal Binary
/0 0x00000000 00000000 00000000 00000000 00000000
/1 0x80000000 10000000 00000000 00000000 00000000
/2 0xc0000000 11000000 00000000 00000000 00000000
/3 0xe0000000 11100000 00000000 00000000 00000000
/4 0xf0000000 11110000 00000000 00000000 00000000
/5 0xf8000000 11111000 00000000 00000000 00000000
/6 0xfc000000 11111100 00000000 00000000 00000000
/7 0xfe000000 11111110 00000000 00000000 00000000
/8 0xff000000 11111111 00000000 00000000 00000000
/9 0xff800000 11111111 10000000 00000000 00000000
/10 0xffc00000 11111111 11000000 00000000 00000000
/11 0xffe00000 11111111 11100000 00000000 00000000
/12 0xfff00000 11111111 11110000 00000000 00000000
/13 0xfff80000 11111111 11111000 00000000 00000000
/14 0xfffc0000 11111111 11111100 00000000 00000000
/15 0xfffe0000 11111111 11111110 00000000 00000000
/16 0xffff0000 11111111 11111111 00000000 00000000
/17 0xffff8000 11111111 11111111 10000000 00000000
/18 0xffffc000 11111111 11111111 11000000 00000000
/19 0xffffe000 11111111 11111111 11100000 00000000
/20 0xfffff000 11111111 11111111 11110000 00000000
/21 0xfffff800 11111111 11111111 11111000 00000000
/22 0xfffffc00 11111111 11111111 11111100 00000000
/23 0xfffffe00 11111111 11111111 11111110 00000000
/24 0xffffff00 11111111 11111111 11111111 00000000
/25 0xffffff80 11111111 11111111 11111111 10000000
/26 0xffffffc0 11111111 11111111 11111111 11000000
/27 0xffffffe0 11111111 11111111 11111111 11100000
/28 0xfffffff0 11111111 11111111 11111111 11110000
/29 0xfffffff8 11111111 11111111 11111111 11111000
/30 0xfffffffc 11111111 11111111 11111111 11111100
/31 0xfffffffe 11111111 11111111 11111111 11111110
/32 0xffffffff 11111111 11111111 11111111 11111111

How to delete all lines of a file in Vim

Sometimes you might want to erase all lines from a file in Vim. You don’t want to spend much time on doing that.

For example, holding ‘d’ is not quite fast if you have over a thousand lines.

And doing ‘d1000d’ (delete exact 1000 lines) will only work if you know how much lines to delete.

The fastest way is to goto the first line of the file with ‘gg’ if you aren’t already there.

Then do ‘dG’, this will tell Vim to first go into delete mode and then goto the last line.

However you might not use this very often, it is handy to know in case you do need it.

Mostly I use ‘dd’ to delete one line, ‘gg’ / ‘:0′ to navigate to the first line and ‘G’ to navigate to the last line.

So now you have it, some nice shortcuts to remember.

VNC Secure Remote Desktop connection over SSH

The following script will make an SSH connection to the remote location and then tunnel the VNC port.

On your machine you can connect to that port on localhost with the VNC client.

Temporarily offline message with PHP headers

Lets say, you have a website where you want to edit some things that might cause errors to your visitor…

You want the best for your visitors right? So it is better to show a temporarily offline message than errors or a blank page… Or worse, 404 errors or internal server errors ;-)

Here you show everyone a maintainance message except the IP ‘’, this might be your office IP.

It is a simple message without an design but at least it won’t show anything bad to the visitor.

When you are done, simply remove this piece of code and everything goes back to normal.
If you done your changes correctly of course ;)

Maximum upload file size possible in PHP

Lets say you build websites for different servers the chance that the maximum upload size differs on these servers might be big. So, you want to automatically handle this.

In the following example we simply get the sizes who have influence on the maximum upload possible. Note that you can set the upload_max_filesize to a really big value but you still need memory to handle the file in most cases!

With the following example you can get the lowest possible value and use that in your script to handle as upload maximum.

This example gets the value in MegaBytes.

How to optional include config files in Apache

If you want to easy manage sites in separate configurations it might become handy to simply include them in the httpd.conf instead of defining the VirtualHosts in your httpd-vhosts.conf every time.

The following will include all files not starting with a hash character in the sites directory.

Of course you still need to check for configuration errors using apachectl -t

My advice for naming the config files is as follows:

  • com_mariusvw.conf
  • com_mariusvw_subdomain.conf
  • com_mariusvw_sub-domain.conf

You might notice that I write the names in reverse, I do this so all the configs of one domain are sorted next to each other.

Of course you can make your own way of writing it down :-)

How to reset a Fritz!Box DSL router to factory settings?

You have two options here.
The first is use an analog phone and dial the reset code.
The second is using the web interface within a certain time on the 169.254.1.x range.

Reset by phone

  • Connect an analog phone to port FON1.
  • Pick up the phone and wait for the dial tone.
  • Dial #991*15901590*

Reset by Web Interface

  • Set your IP manually to something in the 169.254.1.x range (
  • Unplug the router and wait 10 seconds Plug it back in
  • Windows: Open a command window (cmd) and run: ping -t
  • Unix: Open a shell and run: ping
  • As soon as you get reply’s go to the webinterface at
  • You have a option ‘click here if you forgot your password’ (click on here)
  • Then click ‘Restore factory settings’ (This option disappears after about 10 minutes)

Crackling (bad) sound from Bluetooth A2DP headsets or speakers on Mac OS X

If you found this post you probably ran into the same issue as I had, low volume on your headset or speakers or crackling sound.

The solution for this might sound more complex than it is, the Bitpool for the Bluetooth Audio Agent by default is 35, this seems to be too low if you also use a mouse and keyboard at the same time. In my case only a mouse. Raising it to a higher value solved this problem for me.

I raised it to 50 and it worked perfectly!

You can edit the preference file with a plist editor in this file: ~/Library/Preferences/com.apple.BluetoothAudioAgent

Or, more simple, you can run the following in the program Terminal located at /Applications/Utilities/Terminal.app

At the command line enter the following command:

After doing this you might need to reconnect your device or reboot your Mac to apply the change. In my case turning off the bluetooth adapter and enabling it again was enough.

I tested this with a Sennheiser PX 210 BT and it works perfectly!

In case you want to revert to the default settintgs, simply trash:

Updated @ 03-01-2013
It seems that a Macbook Air has a default value of 2. So far, I haven’t noticed bad sound with this system.

Here the default settings:

Updated @ 06-02-2013
After some testing for my Sennheiser PX210 BT it seems that the settings below seem to do the perfect job.

You might want to play around with the Bitpool settings in case these don’t work perfectly for you.

I noticed some difference when locking the Bitpool to a more strict range, these are the values that I tested:

30 – Low audio quality
40 – Medium audio quality
48 – High audio quality
58 – Excellent audio quality

I found these numbers on the Apple discussion forum, seems that still a lot of people seem to have problems with their audio quality.

How to secure wipe a disk

If you need to trash disk its always smart to first erase all your data on a way others cannot recover it easily.

This script is a nice way to wipe it on a DoD 5220.22-M compatible way.

Keep in mind that you WILL lose all data on the target disk!