Geekblok

B10m, BOK, Joffie - old geeks on a blog

Entries Comments



Category: technical


html: colgroup and col

3 June, 2008 (21:35) | html, technical | By: Joffie

Last week I had to design a table where I’d liked to specify the with of a table. I used to do this by giving a class to the columns of the table like:

<table>
<tr>

<td class=”col1″>some data</td>

<td class=”col2″>some more data</td>

</tr>

</table>

And then to specify the layout of the td classes col1 and col2 from a stylesheet.

This week I discovered that there is better way to accomplish the same, using colgroup and col. Never knew that there was already a way to do this the “right way”. So my next tables will look like:

<table>
<colgroup>

<col class=”col1″>

<col class=”col2″>

</colgroup>

<tr>

<td>some data</td>

<td>some more data</td>

</tr>

</table>

It might not look too different in this small example, but I sure I will find some use for it.

Ethernet over power: Homeplug

14 April, 2008 (10:40) | ethernet, technical | By: Joffie

CPL-85
At home, the only way to reach my server on the attic from the ground floor seemed to be wireless. At least that is what I used for about a year. The connection let me down quite often, most likely because of the crappy wireless card I have in it (a Sweex wireless LAN PC card 140 Nitro XM, model: LW141).

A few weeks ago my father came with a box of hardware that he did no longer use. One of the hardware things was a D-LINE CPL-85 of Dinh-Telecom. It was just a case of plugging in both devices in the power outlet and the connection between my server and the network was there.

This is of course nice, but I wanted to know a little more about the devices.

Read more »

Email address validation

28 February, 2008 (13:22) | spam, technical | By: B10m

Email address validation can be rather tricky. RFC822 gives you some pointers, but to validate an address is still pretty darn hard. In Perl, there’s the module Email::Valid to help you, which does a rather good job, but look at the source for the regexp!

Today I came across a new website called spam-proof-email-generator. Of course I threw in a query that’s bugging quite a lot of parsers: my+address@mailserver.somedomain.co.uk. Most of such JavaScript “checks” hang on the plus sign (which is perfectly valid, and quite useful!) and the subdomain part. And yep, this website tells me the address in invalid. Strange, for you’d expect a site designed for handling email addresses to be a bit more careful!

So let’s look at their technique. Their validation is merely done on the client side (JavaScript). The code is childishly simplistic though. This regexp will determine whether your address is valid or not (broken down into two lines): /^[a-zA-Z][\w\_\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]* [a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$/;

But when you disable JavaScript, you can bypass this simple check and insert any string you like, as you can see here:

So, yeah, rather a useless service. Why not create your own image with GIMP/Photoshop, use JavaScript to display the address or use something like user [at] domain [dot] com?

Fun with bluetooth

31 January, 2008 (22:23) | fun, security, technical | By: Joffie

blueproximity logo

Last week I finally got a telephone with bluetooth. As my laptop also as a bluetooth dongle in it, I thought I should be able to do some geeky things with it.
My thoughts were correct: my screensaver is now working, based on the proximity of my telephone. As soon as my phone leaves the desk, the screensaver kicks in and locks the screen. When it is back in the proximity of the laptop, the screen magically unlocks.

Though I am very aware that this really is no good from a security point of view, it is just cool.

I’ll describe what I have done to get this to work. My phone is a Nokia 6151 and the laptop is running Ubuntu desktop.

Read more »

shell tips and trick, part 2

19 January, 2008 (13:31) | guides, technical | By: Joffie

This trick is a bit bash specific instead of a real shell trick. On most unix systems you’ll find the commands dirname and basename. These are rather useless when you have got bash. First we’ll look at dirname.
The manual page of dirname states: dirname - strip non-directory suffix from file name. In bash this would be accomplished by parameter expansion:
$ I=/home/joffie/geekblok.txt; echo ${I%/*}
/home/joffie
The description from the man page of basename is: strip directory and suffix from filenames. So for example:
$ basename /home/joffie/geekblok.txt
geekblok.txt
The same can be accomplished with:
$ I=/home/joffie/geekblok.txt; echo ${I##*/}
geekblok.txt
The suffix part of the basename command can be done in two steps. What the command basename does is strip something from both sides of the string. So stripping suffix .txt from $I too:
$ I=/home/joffie/geekblok.txt; J=${I##*/}; echo ${J%.txt}
geekblok
Bash can also be used when searching and replacing. Take a look at:
$ I=/home/joffie/geekblok.txt; echo ${I/geek/cool}
coolblok.txt
More info can be found in the parameter expansion section of the man page of bash.