Saturday, March 24, 2007

PS3 or beer? Microsoft poses the ultimate question





While we might've put down a few of Microsoft's last night Europe exploits as a tad immature, we aren't going to deny the genius here: Microsoft's message to gamers is that the PS3 = the Xbox 360 + £146 in beer money. Of course, such a mental exercise is nothing without a bit of illustration, so Microsoft carted in just that much beer to the offices of the UK's CVG magazine (above) and Auckland, NZ's GamePlanet store (pictured after the break). Naturally, Sony will have the last laugh when its utterly sober fanboys use keen rhetoric to destroy their tipsy MS fanboy opponents in the comments section following this post.

[Via Joystiq]

Thursday, March 22, 2007

Configuring Dynamic DNS & DHCP on Debian Stable

For the average home computer user there is no need to install a complex package such as the Internet Software Consortium's BIND DNS or DHCP server, since there are far simpler lower resource tools to use, for example dnsmasq. For those who you wish to learn how to use ISC's BIND and DHCP, for example as a learning exercise, this is how I got it all to work in Debian Sarge, the current stable version of Debian GNU/Linux.

This short article was prompted by my question on the Debian-Administration forum site, where I was able to get some answers to the issues I faced and I did promise to post a solution if I got one.

Installation of Packages

The version of ISC BIND DNS and DHCP servers installed by default in Debian stable are the older versions, which will not actually work together. If you have either server installed you need to remove it and upgrade to the newer version of each package. The newer versions are available in the Debian stable archive so you do not need a back-port from testing.

[user@box ~]$ sudo aptitude remove bind dhcp [user@box ~]$ sudo aptitude install bind9 dhcp3-server 

Let aptitude or apt-get figure out and resolve any dependencies. You will get a set of basic configuration files and start scripts all created for you in the usual Debian way.

To set-up DNS you need to set your domain rules as per normal BIND9 format. BIND9 does have a reputation for being complex but you can find help in the man pages which are complete, if very long, and there are good books to help you get through (see below). Setting up the DHCP server is by comparison much simpler; set that up as you need.

The hard bit is getting the two to talk to each other, as this is less well documented and the documentation that does exist does contradict itself. It was my difficulties with getting the DHCP server to automatically update the DNS server that lead me ask a question on the D-A.org web site. Though I got no perfect answer, I was able to piece together enough to generate this working solution.

Configuring BIND9

/etc/bind/named.conf

You need to tell BIND that it is okay to allow other applications to update it. I added the following to my BIND9 configuration, everything else was left as stock Debian. My DHCP server and DNS server are on the box, so here I am only allowing localhost to perform the update. The file rndc-key is a file containing a shared secret, so that BIND9 knows that it is an approved application sending instructions.

controls { inet 127.0.0.1 allow {localhost; } keys { "rndc-key"; }; }; 

/etc/bind/named.conf.local

Here is my local zone details, suitably modified. Here I let BIND know which domains it can update; in my case I only have one domain to deal with. I am also loading in the shared secret key in at this stage. You can see I am using a private IP address range.

// Add local zone definitions here. zone "network.athome" { type master; file "/etc/bind/db.network"; allow-update { key "rndc-key"; }; notify yes; };  zone "0.168.192.in-addr.arpa" { type master; file "/etc/bind/db.192.168.0"; allow-update { key "rndc-key"; }; notify yes; };  include "/etc/bind/rndc.key"; 

/etc/bind/rndc.key

The secret key is created with a tool. If your DHCP and DNS servers are on separate machines you need to copy the file between them or arrange for one machine to remotely access the file system of the other.

key "rndc-key" { algorithm       hmac-md5; secret          "lgkbhjhtthgtlghtl6567=="; }; 

db files

Set up your zone databases as normal. You do not need to do anything fancy.

Configuring DHCP3 Server

By default the ISC DHCP3 server shipped in Debian Sarge does not do dynamic DNS update. You simply need to enable it. Below are the options I selected for my system.

/etc/dhcp3/dhcpd.conf

You have to turn on the updating with the ddns-update-style interim command. I have client-updates ignore as Windows machines try to set their FQDN, not just their hostname, which causes problems. I have included the key so the two server daemons can trust each other.

# Basic stuff to name the server and switch on updating server-identifier           server; ddns-updates                on; ddns-update-style           interim; ddns-domainname             "network.athome."; ddns-rev-domainname         "in-addr.arpa."; ignore                      client-updates;  # This is the key so that DHCP can authenticate it's self to BIND9 include                     "/etc/bind/rndc.key";  # This is the communication zone zone network.athome. { primary 127.0.0.1; key rndc-key; }  # Normal DHCP stuff option domain-name              "network.athome."; option domain-name-servers      192.168.0.60, 192.168.0.1; option ntp-servers              192.168.0.60; option ip-forwarding            off;  default-lease-time              600; max-lease-time                  7200; authoritative;  log-facility local7;  subnet 192.168.0.0 netmask 255.255.255.0 { range                       192.168.0.100 192.168.0.200; option broadcast-address    192.168.0.255; option routers              192.168.0.1; allow                       unknown-clients;  zone    0.168.192.in-addr.arpa. { primary 192.168.0.60; key             "rndc-key"; }  zone    localdomain. { primary 192.168.0.60; key             "rndc-key"; } } 



Original Post: http://www.debian-administration.org/articles/343

Thursday, March 15, 2007

Overrolling effect with the help of CSS

Overrolling effect with the help of styles

Vlad Merzhevich

Overrolling effect means change of one image to another while the mouse cursor is aimed at it. So, as soon as a cursor appears on image, it changes to another one, and when a mouse is led away aside, an image becomes former. Usually JavaScript is used for creation of an overrolling effect, but in many cases CSS is enough.

Pseudo-class hover

First lets come to understanding of how this effect is actually done. For this purpose the pseudo-class hover is used, it’s added through a colon to the desired selector. This pseudo-class determines the style of element, when mouse cursor is over it, that is exactly what we aquire. Alas, but browser of Internet Explorer versions 6 and below in this case are able to work only with references, while other browsers (in particular, Firefox and Opera) understand hover also for other elements. So for universality of the code it will be necessary to place an image into a container <A>. An image is added and changed by the stylish parameter background. The algorithm of actions is the following.

  1. Two images of identical size are prepared, one for an initial kind, and the other — for his replacement at the overrolling effect.
  2. An initial image is added as a background image to the selector of A through the stylish attribute of background with the value of url('URI'), where URI is a way to the graphic file.
  3. We attach a pseudo-class to the selector of A (a:hover) and once again include the parameter of background, but as a value specify a substitutional image.
  4. In order to make the link sizeable to image, it is necessary to convert it into a sectional element by the attribute display with the value of block, and also to set a height and width of the link.

On the img. 1 two images are shown: initial (img, 1a) and substitutional (img. 1b).

Image 1a Image 2b

Img. 1. Pictures for creation of the overrolling effect

It remains to collect the whole code together, as shown in an example 1. In order not to allow the link to lead to some certain file, which is needless in this case, we’ll add a «stub» as character of grate (#) to the parameter of href tag <A> .

Example 1. Use of pseudo-class of hover

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=windows-1251">
<title>Overrolling effect</title>
<style type="text/css">
A.rollover {
 background: url('1.gif'); /* Way to the file with an initial image */
 display: block; /* Image as sectional element */
 width: 196px; /* Image width */
 height: 183px; /* Image height */
 border: 1px solid #000; /* Image border */
}

A.rollover:hover {
 background: url('2.gif'); /* Way to the file with a commutable image */
}
</style>
</head>
<body>
<a href="#" class="rollover"> </a>
</body>
</html>

The result of the example is shown below.

The resulted method though is simple to implement, but has the certain failing. As the second image is loaded only at aiming of cursor on the link, reflection of an image takes place with some pause. For the removal of this delay we may use not two images, but only one.

Overrolling effect with one image

It seems controvercy takes place, in fact the overrolling effect is concluded in replacement of one image by another, then how can we use one image? Actually there will be two images (img. 2) kept in one graphic file.

Image 2

Img.2. Picture with two images

Changing one image to another is carried out by the shift of image on a vertical line due to the use of universal attribute of background or properties of background-position, as shown in an example 2.

Example 2. Change of the image position.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=windows-1251">
<title>Overrolling effect</title>
<style type="text/css">
A.rollover {
 background: url('3.jpg'); /* Way to the file with an initial image */
 display: block; /* Image as sectional element */
 width: 151px; /* Image width in pixels */
 height: 40px; /* Image height */
}

A.rollover:hover {
 background-position:
  0px /* Horisontal shift */
  -40px; /* Vertical line shift */
}
</style>
</head>
<body>
<a href="link.html" class="rollover"></a>
</body>
</html>

The result of the example is shown below.

For the selector A background image is set through the parameter of background, width coincides with an image, and a height (attribute of height) is equal to the half of height of image. Originally a green inset must be viewed at large.

At aiming on the link background is displaced upwards on 40 pixels with the help of background-position property and an orange inset becomes visible.

Summary

Overrolling effect is rarely used independently, from the viewpoint that users actually do not need an image which simply changes on the other one. Therefore this effect is used for accenting of attention on the links, menu creations, underlining of insets, etc. Operating area is limited only by our fantasy and its practicability.

Rasmus Lerdorf, the inventor of PHP, recently headlined the PHPCon East 2003 show at the Park Central Hotel in New York City. Along with a keynote address, Lerdorf ran a session called “tips & tricks.” The following tip is taken from that session. To get additional tips from that session, please visit http://lerdorf.com/nytips.pdf.

5 tips for optimizing PHP

1) Don't use a regex if you don't have to, instead, use PHP’s string manipulation functions. For example:

BAD:
GOOD:
BAD:
GOOD:

2) No references. Usually it is not faster to use references because of PHP's copy-on-write nature.

3) Use Persistent Database connections. Some databases are slower than others at establishing new connections, and the slower the database, the more of an impact using persistent connections will have. Keep in mind, however, that persistent connections will use resources even when not in use.

4) Take a look at MySQL unbuffered query. If you’re using MySQL, check out mysql_unbuffered_query(). You use it exactly like you would mysql_query(), the difference is that instead of waiting for the entire query to finish and storing the result in the client API, an unbuffered query makes results available as soon as possible and they are not allocated in the client API. You get access to your data quicker and use a lot less memory. But you can't use mysql_num_rows() on the result resource and it is likely to be slightly slower for small selects.

5) Keep it simple. Don't over-architect things. If your solution seems complex to you, there is probably a simpler and more obvious approach.

Copyright © 2005 Ziff Davis Media Inc. All Rights Reserved. Originally appearing in Publish.