27 April, 2008

HowTo simulate Googlebot

Googlebot is Google's web crawling robot, which finds and retrieves pages on the web and hands them off to the Google indexer.
Googlebot visits sites with special value in his HTTP request header.

It uses special user-agent string:
"Mozilla/5.0 (compatible; Googlebot/2.1; http://www.google.com/bot.html)"

It is possible to simulate Googlebot from the shell script via wget program.

Like this:

#!/bin/bash

TEST_URL="http://digg.com/"

FIREFOX_USERAGENT_STRING="Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.14) Gecko/20080404 Firefox/2.0.0.14"
GOOGLEBOT_USERAGENT_STRING="Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)"

#get page for firefox browser
wget -c --user-agent="$FIREFOX_USERAGENT_STRING" --output-document=firefox.html "$TEST_URL"

#get page for google bot
wget -c --user-agent="$GOOGLEBOT_USERAGENT_STRING" --output-document=googlebot.html "$TEST_URL"


This script may be useful for testing of site's search engine optimization.

...May the Force be with you...

28 February, 2008

Xml elements and attributes in the ExtJS table

Ext JS - JavaScript Library is pretty powerful JavaScript/AJAX framework for building of Rich Internet Applications.

I've used it in my last public web project: Ubuntu index.


ExtJS has set of useful UI controls, internal components and strong AJAX, XML and JSON support.

E.g. you can present this XML file:



items.xml <?xml version="1.0"?> <items> <item id="alien-arena"> <name>Alien Arena</name> </item> <item id="nexuiz"> <name>Nexuiz</name> </item> <item id="openarena"> <name>OpenArena</name> </item> </items>


as a table via this HTML + JavaScript code:



table.html <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <title>ExtJS Table Sample</title> <link rel="stylesheet" type="text/css" href="ext/resources/css/ext-all.css"/> <script type="text/javascript" src="ext/adapter/ext/ext-base.js"></script> <script type="text/javascript" src="ext/ext-all.js"></script> </head> <body> <script type="text/javascript"> Ext.onReady(function() { var reader = new Ext.data.XmlReader({record: "item"}, [{name: "id", mapping:"@id"}, "name"]); var store = new Ext.data.Store({url: "items.xml", reader: reader}); var columnModel = new Ext.grid.ColumnModel([ {header: "Id", dataIndex: "id"}, {header: "Name", dataIndex: "name"}]); var table = new Ext.grid.GridPanel({ store: store, height: 200, cm: columnModel, renderTo: "table" }); store.load(); }); </script> <div id="table" style="width:300px; height:200px;"></div> </body> </html>



22 January, 2008

Linux reference

I found really useful documentation for Linux beginners.


"This Debian Reference (http://qref.sourceforge.net/) is intended to provide a broad overview of the Debian system as a post-installation user’s guide. It covers many aspects of system administration through shell-command examples. Basic tutorials, tips, and other information are provided for topics including fundamental concepts of the Debian system, system installation hints, Debian package management, the Linux kernel under Debian, system tuning, building a gateway, text editors, CVS, programming, and GnuPG for non-developers."


This book is devoted to Debian system but it is topical for some other Linux systems.

StarCraft (Brood War) under Linux (Wine)

I use this script to play network StarCraft under wine:

#!/bin/bash

#At first, run "wine setup.exe"

BROODWAR_HOME=/usr/games/broodwar

ipx_interface add -p eth0 802.2 0x39ab0222
cd $BROODWAR_HOME
xinit /usr/bin/wine starcraft.exe


I think it is the best game.

Flash-light from console

With this script I use my monitor as flash-light in the darkness.

#!/bin/bash

#Switch monitor (CRT or LCD) to flash-light mode.

echo -e "\\033[47;30m"
clear
read
echo -e "\\033[0m"
clear