Google Chrome and Facebook Woes

Thursday, September 4, 2008

In general, I think Google chrome is great. Its fast, its secure (well except for the DOS bug), bleeding edge, and did I mention fast?

Problem is, it has some compatibility problems with many ajax driven sites, most notably, Facebook. As of version 0.2.149.27, about 60-70% of the Ajax functionality on Facebook doesn't work with Chrome, so for you Facebook fans, save yourself some trouble and continue using Firefox until Google comes out with a fix.

P.S. If they are going to copy Firebug with "inspect elements", they really should do a more thorough job.

Related articles:

Chrome vs Operating Systems
What Google said, what Google meant
Chrome comics

Daily Notes: Copy on write

Tuesday, August 26, 2008

Copy on write is an optimization technique used in system programming. The way COW works is that if multiple clients or callers that requires access to the same resource, you hand them the pointers instead. When one of the callers decides to change the resource, a copy is created (may or may not be private), and the pointers updated, which may be used by the caller that changed it, and other new callers as well. Note that this process is transparent to existing callers, so that those that didn't change the resource still reference the pointer to the original resource.

Examples of copy on write:

snapshots (most modern volume managers) - usually a block map is created when a snapshot is taken, and changes since the snapshot are written to new disk blocks, with the current block map changed accordingly.

calloc function - when memory is allocated, it initially returns or points all pages "allocated" to a page of zeros, and all pages are marked copy-on-write. As data is written, they are intercepted and written to new memory by the MMU and change the address of the page accordingly.

CentOS 5: chrooted BIND/named

Sunday, August 24, 2008

With CentOS 5, bind is chrooted by default. What this means is that named is started in a "chroot jail", and it cannot see or access files outside its own directory tree as user "named".

You can install bind either during OS install, or later via yum. After installation, it will install the init script "named" in /etc/init.d as usual. Make sure you do a:

chkconfig named on

So that bind will start upon reboot. The install should have added named to both /etc/passwd and /etc/group.

The file that is sourced by the init script which determins whether or not named will be chrooted is /etc/sysconfig/named, which sets the ROOTDIR among other things. By default, the chroot jail for named will be at:

/var/named/chroot

This directory will most likely be empty after the initial install. If you don't want to start everything from scratch, you can copy everything from:

/usr/share/doc/bind-<version>/sample

To:

/var/named/chroot

If not, make sure the following directory are created:

/var/named/chroot/var/named
/var/named/chroot/var/named/data
/var/named/chroot/var/run/named
/var/named/chroot/etc


Either way, the init script will expect the named.conf to reside in $ROOTDIR/etc, in this case /var/named/chroot/etc, so just make sure named.conf is there regardless if you use the sample or create from scratch.

Now, on to named.conf. First thing you'll probably want to set up is the options clause, which contains global options. Some of the useful options include:

options
{
    query-source port 53;
    directory "/var/named";
    pid-file "/var/run/named/named.pid";
    zone-statistics yes;
    dump-file "data/cache_dump.db";
    statistics-file "data/named_stats.txt";
    memstatistics-file "data/named_mem_stats.txt";
    version "Get lost pal!"
};


With version 9, bind now supports "views", which allows you to set up instances of the same zone with different zone files according to the type of clients that queries the server, or limit what type of clients have access to query what zones, and control how each instance is queried/accessed. This allows you to, for example, solve the age old problem of having to have separate DNS servers for internal and external clients. Even if you are not going to set up separate views to start out with, it is always a good idea to use the view clause so if you have to support views later, you don't need to rewrite your named.conf, just add more views.

Now, remember root hints must be declared in each view. Best thing to do is to put the root hint declarations in a separate file and "include" it in each view. You should be able to just copy it from:

/usr/share/doc/bind-<version>/sample/etc/named.root.hints

To:

/var/named/chroot/etc

Then, get the latest root hints:

wget ftp://rs.internic.net/domain/named.root

And copy it to:

/var/named/chroot/var/named

Do the same for localhost TLDs and address zones unless you REALLY wanna waste time and build them manually, copy:

/usr/share/doc/bind-<version>/sample/etc/named.rfc1912.zones

To:

/var/named/chroot/etc

And the following files:

/usr/share/doc/bind-<version>/sample/var/named/named.broadcast
/usr/share/doc/bind-<version>/sample/var/named/named.local
/usr/share/doc/bind-<version>/sample/var/named/named.ip6.local
/usr/share/doc/bind-<version>/sample/var/named/named.zero
/usr/share/doc/bind-<version>/sample/var/named/localhost.zone
/usr/share/doc/bind-<version>/sample/var/named/localdomain.zone


To:

/var/named/chroot/var/named

Now, continuing with views in named.conf:

// localhost_resolver is for RFC1912
// this is all you need if you just want a local cache
// this view only serves the server this is running on
view "localhost_resolver"
{
    match-clients { localhost; };
    match-destinations { localhost; };
    include "/etc/named.root.hints";
    include "/etc/named.rfc1912.zones";
    zone "example.com" {
        type master;
        file "data/example.com.zone";
    };
};

view "internal"
{
    match-clients { localnets; };
    match-destinations { localnets; };
    recursion yes;
    include "/etc/named.root.hints";
    zone "example.com" {
        type master;
        file "data/example.com.zone";
    };
};


Now everything should be set, except for the zone file for example.com. I've included here as an example (no pun intended):

$TTL 1h
@         IN    SOA    ns1.example.com. hostmaster.example.com. (

          2008081004 :serial
          12h :refresh
          15m :update retry
          1d :expiry
          1h :minimum
          )
@         IN    NS     ns1.example.com.
          IN    MX  10 mail.example.com.
ns1       IN    A      192.168.2.50
mail      IN    A      192.168.2.100
kickstart IN    A      192.168.5.150

Now we just have to set the permissions, do the following:


chmod -R 770 /var/named/chroot
chown -R named:named /var/named/chroot


Now we're set. Simply start named with:

service named start

And off we go.

Games: Warhammer Online, Road to War!

Wednesday, August 20, 2008

Guys/gals, help me out...goto:

http://www.road-to-war.com

And register. In the field where it says "Recruited by (email)", please enter my email address :)

This way I get 500 gold and victory points per person that registers. Why? Well, this is a mini-game before the launch for Warhammer online...basically it'll help me get a unique in game item. I started a bit late, only have 2500 victory points, so I need to catch up.

Although it doesn't look like Order will win anytime soon...

For those that don't know what Warhammer online, its from the same creators of "Dark Age of Camelot"...Mythic Entertainment. Its a MMOG based on the Warhammer universe. For more information, go to:

http://www.warhammeronline.com

Anyway, go register!!!

PERL: sequential to CSV conversion

Tuesday, August 19, 2008

Given a file abc.txt with:

1
2
3
4
5
6
7

Here's a quick one liner to convert that to a line of CSV:

perl -e 'chomp(@data=<STDIN>);print join(",",@data),"\n";' < abc.txt

Incidentally, I tested this with a quick bash counterpart:

tr "\n" "," < abc.txt | sed 's/,$//'

After timing them both a few times, the results were pretty much the same.

Pre-existing Conditions...wha?

Gotta love Kaiser Permanente...I had applied for a family health plan (insurance) with them like 4 weeks ago. The letter I received from them last week says I was denied coverage because of the following pre-existing condition:

"You are an expecting father"

Lol, I won't go into how I think its crock that being pregnant counts as a pre-existing condition...but come on, being an expecting father?!?

The joys of being a consultant/contractor...thank goodness I can still elect for CORBA from my previous job...at least the wife is covered now.

BASH: Passing values from function to array

This has always been something that sort of irks me from time to time. Sure, you can pass values to an array as follows:

biteme() {
x=abc
y=123
echo $x $y
}

array=($(biteme))
echo "Element 0 is ${array[0]}, element 1 is ${array[1]}"

And you would get:

Element 0 is abc, element 1 is 123

But what if the value had a space in it? For example, change x in function biteme to abc def, and you would get:

Element 0 is abc, element 1 is def

Instead. I've always gotten around this by setting IFS to something else, say colon...then reset IFS after the function is called. For example:

biteme() {
x=abc
y=123
sp=":"
echo $x$sp$y
}

OFS=IFS;IFS=":";array=($(biteme));IFS=OFS
echo "Element 0 is ${array[0]}, element 1 is ${array[1]}"

Obviously this isn't very elegant...but it works...its either IFS or parse it through a for loop and manually assign each element in the array...if there's another way to do this I'm all ears.