2010
07.24

On my laptop I wanted to mount some directories (via samba) from my workstation so I could always access them. That part wasn’t too hard. Be sure to install smbfs (Samba file system utilities) and put the following line in your /etc/fstab:

//zeus/mtersmitten/Muziek /media/samba/zeus/muziek      cifs     _netdev,credentials=/home/mtersmitten/.cred,iocharset=utf8,ro     0       0

/home/mtersmitten/.cred will contain your samba credentials like this:

username=####
password=####

So the samba path is //zeus/mtersmitten/Muziek and /media/samba/zeus/muziek is the local directory (on the laptop) where we want to mount it to. cifs is the filetype and ro means read-only.

Now comes the annoying part! When rebooting the laptop it would take forever to disconnect the mount(s) and I would get this kinds of errors:

CIFS VFS: Server not responding
CIFS VFS: no response for cmd 50 mid 30

Probably because the wireless connection already was terminated and the smb mount not… Fortunately, thanks to whereofwecannotspeak, I found a solution 🙂

“To unmount Samba shares before shutting down network services, run the following commands as root”

ln -s /etc/init.d/umountnfs.sh /etc/rc0.d/K15umountnfs.sh
ln -s /etc/init.d/umountnfs.sh /etc/rc6.d/K15umountnfs.sh

Et voilà, the errors were gone!

References:

2010
07.24

I wanted to have syntax highlighting for a big SQL file I was working on. Finding a solution didn’t take my too long. Source-highlight given a source file, produces a document with syntax highlighting. Output formats that are supported:

  • HTML
  • XHTML
  • LATEX
  • TEXINFO
  • ANSI
  • DocBook

Input formats that are supported:

  • Ada
  • Asm
  • Applescript
  • Awk
  • Autoconf files
  • Bat
  • Bib
  • Bison
  • C/C++
  • C#
  • CakePhp templates
  • Clipper
  • Cobol
  • Configuration files (generic)
  • Caml
  • Changelog
  • Css
  • D
  • Diff
  • Erlang
  • errors (compiler output)
  • Flex
  • Fortran
  • GLSL
  • Haskell
  • Haskell literate programming
  • Haxe
  • Html
  • ini files
  • Java
  • Javascript
  • KDE desktop files
  • Latex
  • Ldap files
  • Lisp
  • Logtalk
  • Log files
  • lsm files (Linux Software Map)
  • Lua
  • Makefile
  • Manifest
  • M4
  • ML
  • Oz
  • Pascal
  • Perl
  • pkg-config files
  • PHP
  • Postscript
  • Prolog
  • Properties files
  • Protobuf (Google’s Protocol Buffers)
  • Python
  • RPM Spec files
  • Ruby
  • Scala
  • Shell
  • S-Lang
  • Sql
  • Tcl
  • Texinfo
  • Vala
  • VBscript
  • XML
  • XOrg conf files

Exactly what I needed!

For Debian/Ubuntu get source-highlight to work is just as simple as:

apt-get install source-highlight

And adding these two environment variables (to .bashrc):

export LESSOPEN="| /usr/share/source-highlight/src-hilite-lesspipe.sh %s"
export LESS=' -R '

The result looks like this:

source-highlight SQL file

source-highlight SQL file

Be sure this line isn’t present in your .bashrc because it will interfere with source-highlight:

[ -x /usr/bin/lesspipe ] && eval "$(lesspipe)"

For CentOS/Red Hat the procedure will be comparable, but I don’t now for sure if a RPM package of source-highlight is available.

References:

2010
06.10

For some stuff that couldn’t bare the daylight I needed some anonymity. Tor (The Union Router) is really suited for this purpose:

“Tor is free software and an open network that helps you defend against a form of network surveillance that threatens personal freedom and privacy, confidential business activities and relationships, and state security known as traffic analysis.

Tor protects you by bouncing your communications around a distributed network of relays run by volunteers all around the world: it prevents somebody watching your Internet connection from learning what sites you visit, and it prevents the sites you visit from learning your physical location. Tor works with many of your existing applications, including web browsers, instant messaging clients, remote login, and other applications based on the TCP protocol.”

Here’s some more information about Tor:

Installation of Tor (for Firefox) isn’t to hard:

  • First we have to add the repository:
    sudo apt-add-repository ppa:sevenmachines/tor
    
    Executing: gpg --ignore-time-conflict --no-options --no-default-keyring --secret-keyring /etc/apt/secring.gpg --trustdb-name /etc/apt/trustdb.gpg --keyring /etc/apt/trusted.gpg --primary-keyring /etc/apt/trusted.gpg --keyserver keyserver.ubuntu.com --recv 454FEDB228E1455D687C9CBE35DA01C261E46227
    gpg: opvragen sleutel 61E46227 van hkp sleutelserver keyserver.ubuntu.com
    gpg: sleutel 61E46227: publieke sleutel “Launchpad Default PPA” geimporteerd
    gpg: Totaal aantal verwerkt: 1
    gpg:               Geimporteerd: 1  (RSA: 1)
    
  • After that we have to update apt and install the needed packages:
    sudo apt-get update
    sudo apt-get install tor polipo
  • Next, we have to configure polipo:
    cd /etc/polipo/
    mv config config.ori
    wget https://svn.torproject.org/svn/torbrowser/trunk/build-scripts/config/polipo.conf
    mv polipo.conf config
    /etc/init.d/polipo restart
  • And finally we have to install the Torbutton Firefox plugin
    Torbutton

    Torbutton

References:

2010
06.10
IE6 denial

IE6 denial

A problem all web designers know is making a website work in Internet Explorer 6. IE 6 is not standards conforming. So even when you, as a designer, stick to the W3C rules there’s quite a chance your website won’t render as it should. A few big websites (i.e. Youtube, Apple’s MobileMe) already banned IE6 and even Javascript guru Douglas Crockford has called for a global IE6 boycott. Although the market share is rapidly declining, quite a large portion still seems to be using it; especially in Asia and Africa (+/- 21%).

IE6 Percentage

IE6 Percentage

Why? IE6 was released in 2001, and even failed to properly support the CSS 1.0 standard from 1996…

IE6 Why?

IE6 Why?

We have to stop this oldie hold us back and make the Internet a better place 🙂

Free the web suggests:

  • make sure your browser is up to date
  • help others to get up to date
  • if you are a web designer, stop supporting IE6
  • spread the word: Boycott IE6

Ajaxian follows a more aggressive approach: amelie()

I would suggest we all just copy and paste the following code onto your site:

<!--&#91;if lt IE 7&#93;>
<div style='border: 1px solid #F7941D; background: #FEEFDA; text-align: center; clear: both; height: 75px; position: relative;'>
<div style='position: absolute; right: 3px; top: 3px; font-family: courier new; font-weight: bold;'><a href="#" mce_href="#" onclick='javascript:this.parentNode.parentNode.style.display="none"; return false;'><img src="http://www.ie6nomore.com/files/theme/ie6nomore-cornerx.jpg" mce_src="http://www.ie6nomore.com/files/theme/ie6nomore-cornerx.jpg" style="border: none;" mce_style="border: none;" alt='Close this notice' /></a></div>
<div style='width: 640px; margin: 0 auto; text-align: left; padding: 0; overflow: hidden; color: black;'>
<div style='width: 75px; float: left;'><img src="http://www.ie6nomore.com/files/theme/ie6nomore-warning.jpg" mce_src="http://www.ie6nomore.com/files/theme/ie6nomore-warning.jpg" alt='Warning!' /></div>
<div style='width: 275px; float: left; font-family: Arial, sans-serif;'>
<div style="font-size: 14px; font-weight: bold; margin-top: 12px;" mce_style="font-size: 14px; font-weight: bold; margin-top: 12px;">You are using an outdated browser</div>
<div style="font-size: 12px; margin-top: 6px; line-height: 12px;" mce_style="font-size: 12px; margin-top: 6px; line-height: 12px;">For a better experience using this site, please upgrade to a modern web browser.</div>
</div>
<div style='width: 75px; float: left;'><a href="http://www.firefox.com" mce_href="http://www.firefox.com" target='_blank'><img src="http://www.ie6nomore.com/files/theme/ie6nomore-firefox.jpg" mce_src="http://www.ie6nomore.com/files/theme/ie6nomore-firefox.jpg" style="border: none;" mce_style="border: none;" alt='Get Firefox 3.5' /></a></div>
<div style='width: 75px; float: left;'><a href="http://www.browserforthebetter.com/download.html" mce_href="http://www.browserforthebetter.com/download.html" target='_blank'><img src="http://www.ie6nomore.com/files/theme/ie6nomore-ie8.jpg" mce_src="http://www.ie6nomore.com/files/theme/ie6nomore-ie8.jpg" style="border: none;" mce_style="border: none;" alt='Get Internet Explorer 8' /></a></div>
<div style='width: 73px; float: left;'><a href="http://www.apple.com/safari/download/" mce_href="http://www.apple.com/safari/download/" target='_blank'><img src="http://www.ie6nomore.com/files/theme/ie6nomore-safari.jpg" mce_src="http://www.ie6nomore.com/files/theme/ie6nomore-safari.jpg" style="border: none;" mce_style="border: none;" alt='Get Safari 4' /></a></div>
<div style="float: left;" mce_style="float: left;"><a href="http://www.google.com/chrome" mce_href="http://www.google.com/chrome" target='_blank'><img src="http://www.ie6nomore.com/files/theme/ie6nomore-chrome.jpg" mce_src="http://www.ie6nomore.com/files/theme/ie6nomore-chrome.jpg" style="border: none;" mce_style="border: none;" alt='Get Google Chrome' /></a></div>
</div>
</div>

< !&#91;endif&#93;-->

And IE6 users would get this nice notification when visiting your website(s):

IE6 No More

IE6 No More

References:

2010
06.03

Yesterday I did an upgrade from cake 1.30 to 1.31 on my Windows 2003 server. Unfortunately there was a problem with the cache files:

<a href="javascript:void(0);"><strong>Notice</strong> (8)</a>: unserialize() [<a href="http://php.net/function.unserialize">function.unserialize</a>]: Error at offset 0 of 1391 bytes [<strong>CORE\cake\libs\cache\file.php</strong>, line <strong>176</strong>]

Fortunately, finding an solution wasn’t to hard. A removed trim() seemed to be the culprit:

Txt cake/libs/file.php
<div>@@ -192,7 +192,7 @@ class File extends Object {</div>
195
<div>-    return $data;</div>
195
<div>+    return trim($data);</div>
Txt cake/tests/cases/libs/file.test.php
<div>@@ -115,7 +115,7 @@ class FileTest extends CakeTestCase {</div>
118
<div>-    $this-&gt;assertEqual($result, $expecting);</div>
118
<div>+    $this-&gt;assertEqual($result, trim($expecting));</div>

References:

2010
05.22

A few minutes ago I tried to add some music to my N900 for my girlfriend. Unfortunately the media player doesn’t automatically scan for new media (or it takes a while?). If you want to force the N900 to re-index everything just invoke this command in your X Terminal (or via SSH):

tracker-processes -r

Found 136 pids...
Setting database locations
Checking database directories exist
Checking database version
Checking database files exist
Removing all database files
  Removing database:'/home/user/.local/share/tracker/data/common.db'
  Removing database:'/var/tmp/tracker-user/cache.db'
  Removing database:'/home/user/.cache/tracker/file-meta.db'
  Removing database:'/home/user/.cache/tracker/file-contents.db'
  Removing database:'/home/user/.cache/tracker/email-meta.db'
  Removing database:'/home/user/.cache/tracker/email-contents.db'
Setting index database locations
Checking index directories exist
Checking index files exist
Removing all database index files
  Removing database index:'/home/user/.cache/tracker/file-index.db'
  Removing database index:'/home/user/.cache/tracker/email-index.db'

And after a few minutes (the player will show your) your music/video collection will be up to date!

References:

2010
05.20

Of course there are a million ways to do so (Samba, AFS, NFS, SSH, FTP et cetera), but I think this is the easiest way you’ve ever seen. It is called SimpleHTTPServer and the only requirement is that you have Python installed, which is the case for most Linux systems.  You use it like this:

python -m SimpleHTTPServer

This will launce a simple webserver serving you currect directory via port 8000. It is obvious that this page will only be accessible when this port isn’t firewalled. When you acces this page it will show you something like this:

Browser Listing

Browser Listing

And what you see on the console is:

Python Server SimpleHTTPServer

Python Server SimpleHTTPServer

To have this command always with you, simply create an alias in your .bashrc:

alias pyServ='python -m SimpleHTTPServer'

As said before, by default the server listens on port 8000. If we would like it to listen on 8001 that’s also possibe. Just add another parameter:

python -m SimpleHTTPServer 8001

Two other, related, (Python written) file sharing utilities I came across a while ago are Droopy and Woof. Have a look at them the’re quite handy too!

References:

2010
05.20

DynDNS offers “free Dynamic DNS service that lets you easily connect to your home network from anywhere. Use your personalized URL to view home security cameras, download shared files from your VPN, or even host a personal website. Don’t pay for a static IP address; our software syncs your domain to your network automatically”

Of course it is (completely) pointless, but what the hack. You could use it for running public services (apache, ssh et cetera) on your N900 if your 3G provider assigns you a public IP address, but I guess the main purpose would be tracking your phone when it’s lost or stolen.

Since Python is already present on the N900 the easiest way to get things working would be a Python based DynDNS client. Such a client is available at sourceforge.net and is named ipcheck. So what we do is:

And I assume that you already have SSH (root) access to your phone

  • Download ipcheck to the N900
    mkdir /opt/ipcheck -p
    cd /opt/ipcheck
    wget http://downloads.sourceforge.net/project/ipcheck/ipcheck.py?use_mirror=ovh
    chmod 0755 ipcheck.py
  • Test it
    ./ipcheck.py --makedat -l -r \
    checkip.dyndns.org:8245 #username #password #domain
    
  • Create a if-up.d script
    touch /etc/network/if-up.d/ipcheck
    chmod 0755 /etc/network/if-up.d/ipcheck
    vi /etc/network/if-up.d/ipcheck
    

    And paste these lines in it:

    #!/bin/sh
    #
    if [ ! -d /opt/ipcheck ]; then
      exit 1;
    else
      cd /opt/ipcheck;
      ./ipcheck.py -l -r checkip.dyndns.org:8245 #username #password #domain;
      exit 0;
    fi
    
  • Check if it works (by switching connection 3G/Wireless and watching what happens at DynDNS.org)

References:

2010
05.20

A few days ago I was visiting one of my favorite sites (commandlinefu) and read something about “Color Highlighted Log Viewing” so I tried it and was instantly hooked. According to it’s website: “CCZE is a robust and modular log colorizer with plugins for apm, exim, fetchmail, httpd, postfix, procmail, squid, syslog, ulogd, vsftpd, xferlog, and more”

Usage is really simple. Just install it:

yum install ccze (Red Hat/CentOS)
apt-get install ccze (Debian/Ubuntu)

And use it like:

tail -f -n 50 /var/log/syslog | ccze

You will see something like this:

CCZE Colored logs

CCZE Colored logs


References:

2010
05.20

To get full control over your N900 what would by easier than have SSH (root)access.

OpenSSH

If you have the Maemo Extra repository enabled and already installed rootsh the only thing we have to do is search for a package named openssh. This is a meta package which contains both client and server. We install this package and it will ask us to choose a root password. After setting this password the installation is finished. We now should be able to login with that password:

client: ssh root@192.168.1.4
Nokia-N900-42-11:~#

Nokia-N900-42-11:~# ssh -v
OpenSSH_5.1p1  Debian-6.maemo5, OpenSSL 0.9.8g 19 Oct 2007

For extra security we could choose not to allow password authentication, but only publickey. To configure this on Debian/Ubuntu have a look at this article. What we do is:

  • Install the ssh client
    client: apt-get install openssh-client
    
  • Generate the key-pair, a public-key and a private-key
    client: ssh-keygen -t rsa
    
  • Copy the public key to the server (in this case the N900)
    client: ssh-copy-id -i ~/.ssh/id_rsa root@192.168.1.4
    
  • See if you can login without entering a password
    client: ssh root@192.168.1.4
    
  • If so, disable password authentication
    server: cd /etc/ssh
            cp sshd_config sshd_config.orig
            vi sshd_config
    

    and change PasswordAuthentication yes to PasswordAuthentication no

  • Restart the SSH server
    server: /etc/init.d/ssh restart

References: