News


Latest site news

Getting AirTunes To Connect To Airport Express

Posted December 20th, 2011 in Breadcrumbs by admin

iTunes not connecting to your Airport Express’ AirTunes? Turn off IPv6 and it should start working again.

To turn off IPv6 open the terminal app and enter the following for your network adapter(s). For example, if you’re connected via the Wi-Fi interface:

sudo networksetup -setv6off WiFi

 

Ring Buffer With Tshark

Posted December 14th, 2011 in Breadcrumbs by admin

Using a ring buffer with tshark

You can use a ring buffer with tshark to overwrite files by time, size, or both. So to capture on interface ath0, disable name resolution, start a new file when the previous reaches 250k, capture up to three files with the prefix wifi-cap_NNN_<dstamp>”, capture only traffic with DST or SRC set to xx:xx:xx:xx:xx:xx you can enter:

#tshark -n -i ath0 -a filesize:250 -b files:3 -w wifi-cap -R "wlan.addr eq xx:xx:xx:xx:xx:xx"

 

Redirecting URLs with mod_rewrite

Posted May 12th, 2010 in Breadcrumbs by admin

If you’ve ever needed to move a web page’s location or change it’s URL but didn’t want to break external links to it as well as loose your Google juice, you can use Apache’s mod_rewrite to redirect a user’s browser automatically to the new location. Although there are many ways to do this with simple URL names it can become more challenging when using dynamic links. The question mark is a special character and escaping it doesn’t produce the desired effect when used on URLs like somepage.php?id=12&yada=yada.

When I changed my URLs to pretty human readable URLs I used the following to keep from breaking my links.

Old URL

http://www.fatofthelan.com/articles/article.php?pid=29

New URL

http://www.fatofthelan.com/technical/how-to-install-postfix-dovecot-amavis-clamav-and-spamassassin-etch/

So in my httpd.conf I added the following stanza that redirects the old URL to the new URL.

RewriteEngine  on
RewriteCond %{QUERY_STRING} ^pid=29$
RewriteRule .* /technical/how-to-install-postfix-dovecot-amavis-clamav-and-spamassassin-etch/? [R=301,L]

One word of caution. Don’t forget to add the question mark at the end of the new URL as this forces a blank query string. Otherwise, the original query string will be retained and appended to the end of the URL producing a 404 page.

mod_security missing from Debian

Posted May 8th, 2010 in Breadcrumbs by Tobias

Due to some licensing issues, mod_security was removed from Debian. To get it back you can do this. Etch users add this line to your /etc/apt/sources.list:


deb  http://etc.inittab.org/~agi/debian/libapache-mod-security/etch ./

Apt doesn’t know about this site’s gpg key so you’ll need to import it.


gpg --keyserver wwwkeys.eu.pgp.net --recv-keys  C514AF8E4BA401C3
apt-key add /root/.gnupg/pubring.gpg
apt-get  update

Now you should be able to install as before!

Mac backup with rsync

Posted May 8th, 2010 in Breadcrumbs by Tobias
I needed to backup my wife’s MacBook to our home server and have it be “1 click” easy so she’d use it. I used ssh and rsync so she could use it anywhere securely.
First I generated her ssh key:


ssh-keygen  -t dsa -b 1024 -f ~/.ssh/backup-key

Then I copied the contents of .ssh/backup-key.pub to her ~/.ssh/authorized_keys2 file on the server.
And finally, I created the following script to backup to the server:


#!/bin/sh
# This backs up Eve's data
# Backup  with this one:
rsync -avz -e "ssh -i /Users/eve/.ssh/backup-key"  --delete --stats --progress /Users/eve eve@myserver.com:/home/eve/   --exclude '.Trash' --exclude '.DS_Store'

And that does the trick. Backs up, deletes files that have been deleted on the Mac, and excludes .Trash and .DS_Store files.

Fix GPG error with debian volatile

Posted May 8th, 2010 in Breadcrumbs by Tobias

If you’re having trouble adding debian’s volatile source, this should fix it.


gpg --keyserver wwwkeys.eu.pgp.net --recv-key  EC61E0B0BBE55AB3
gpg --export EC61E0B0BBE55AB3 | apt-key add -

Then apt-get update should work fine.

Deleting old log files

Posted May 8th, 2010 in Breadcrumbs by Tobias

If you need to create a script to delete old logs based on number of days, you can use this:


find /path/to/logs/ -mtime +90 | xargs rm -rf

…and that’ll remove any thing older than 90 days.

Quickly find/replace stuff in files

Posted May 8th, 2010 in Breadcrumbs by Tobias

I had to replace a string in a bunch of files and wanted to do it quickly.
1. cd to the directory where your files live.
2. Run this:


for i in *; do perl -i -pe 's/oldtext/new better  text/g' $i; done

..or no perl? Use sed.


for i in *; do sed -e 's/oldtext/newtext/g' -i $i;  done

Convert DOS eol to UNIX eol

Posted May 8th, 2010 in Breadcrumbs by Tobias

To convert a DOS text file (end-of-line = ^M^J) to a Unix text file (end-of-line = ^J).

# apt-get install sysutils (if using Debian) 
$ dos2unix dosfile

Configure VI to return to last line in Debian

Posted May 8th, 2010 in Breadcrumbs by Tobias

To have VI(M) in Debian to act like it does in Redhat, create a file named .vimrc (Note the dot) in your home directory and add this to it:

syntax on
au BufReadPost * if line("'\"") >  0|if line("'\"") <= line("$")|exe("norm '\"")|else|exe "norm  $"|endif|endif