Arch linux recover GRUB

Boot the archlinux cd

find you linux root partition with fdisk -l

mount /dev/<root partition> /mnt

arch-chroot /mnt /bin/bash

grub-install /dev/sda

Test network speed


root@computer1:~# nc -vln 12345 >/dev/null



root@computer2:~# dd if=/dev/zero bs=1M count=1K | nc -vn 12345
Connection to 12345 port [tcp/*] succeeded!
1024+0 records in
1024+0 records out
1073741824 bytes (1.1 GB) copied, 16.7192 s, 64.2 MB/s

Indenting HTML output in PHP

I care about indenting my HTML output from PHP scripts and prefer to keep this between the <?php ?> blocks. Another thing is that I want to keep my code < 80 chars/line. That’s why I use a very simple but neat function that helps me do this and read and check my HTML output more easily.

Below function safes you from using stuff like “/n/t/t” in your code. In this case you’d just use nl(2).
If you embrace the concept of using this simple function for your HTML output you can edit your code much easier and also much faster. This is especially true when using a modal editor like VI or Vim.

Read the rest of this entry »

Remove ^M with Vim

These are instructions on how to get rid of ^M in text-files with the use of Vim.

In Linux/Unix by pressing:


Note that ^M is inserted by pressing the keystoke: Ctrl+V  Ctrl+M
This is because Ctrl+V will give the escaped form of the key pressed after this.
You’ll see that when you press Ctrl+V <RETURN> it is actually the same.
So yes, you can insert return/enter by pressing Ctrl+M in Unix.

In the Windows version of Vim the instruction will not work but you can accomplish the same by using:


The substitute command

The % means that this aplies on all the lines in the file.
The s/old/new/ is a substitute command where old gets replaced by new.
The g on the end means to this mutliple times if found more then once in the same line.
For more info, you can use the help function of Vim by entering:

:help substitute

Enable the alt key in OS X terminal

Here is howto enable the alt key in terminal

Terminal > Preferences > Settings > Keyboard
select ‘Use option as meta key’

OS X terminal settings

New network client notifier

This scripts listens to al broadcasts messages captured with tcpdump,
registers all new discovered mac addresses in a txt table,
it resolves the hostname by querying the wins server,

and send a mail notification about the newly discovered clients hostname to all configured recipients.

Read the rest of this entry »

Using a smart host in OpenBSD’s sendmail

Here are some quick notes of configuring sendmail(8) to transfer mail
to your ISP’s smart host on a standard OpenBSD Installation. Tested with
OpenBSD 4.7/i386 and 4.8/i386

First, make a copy of the default configuration. Here ‘mysettings’ is something you can name anything you’d like.

Read the rest of this entry »

Filter authlog

With this script you can filter the authlog log file,

Script usage

./ <ip list file> <authlog file> <word> [-z]

<ip list file>       #file with trusted ip adresses on each line
<authlog file>   #authlog location, /var/log/authlog
<word>            #pettern to grep from output, ‘Accept’ for all accepted logins
-z                     #use zcat, for gziped log rotate log files, do not forgot the quotes

Read the rest of this entry »