Tuesday, January 31, 2006

rar command line

If you need to break down a large file into multiple smaller ones, try rar:
rar a -v10000k test.log.rar test.log
# break a 4GB file into 700MB files quickly (lowest compression level)
rar a -m0 -v700000k SAMPLE_DVD.rar SAMPLE_DVD.ISO

Friday, January 27, 2006

rsync - find repository size

To find repository size before downloading, use --dry-run
$# rsync --dry-run --recursive mirrors.tds.net::rsync
....
sent 62 bytes  received 8161 bytes  5482.00 bytes/sec
total size is 52792107  speedup is 6420.05
That shows RSYNC mirror takes about 50MB.

Tuesday, January 24, 2006

Does GoogleBot run JavaScript?

Yes, Googlebot does execute JavaScript code. I have an AJAX vote form with Yes/No links. The links are in AJAX form. Something like this: href="javascript:vote('Yes');" and the database records these votes. I got many votes from GoogleBot. Its User-Agent string is like this: Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html). Now it's annoying since I do not want the bot to vote.

PHP: strtotime & Windows

It looks like PHP 5.1 on Windows doesn't understand the time zone string "UTC"

Sunday, January 22, 2006

The Planet & Server Owner Privacy

It's quite simple to do a whois on an IP hosted at ThePlanet and get extra information about the person. Implications: good & bad
root# [~]# whois 70.85.27.85 -h rwhois.theplanet.com -p 4321
[Querying rwhois.theplanet.com]
[rwhois.theplanet.com]
%rwhois V-1.5:003eff:00 whois.theplanet.com (by Network Solutions, Inc. V-1.5.9.5)
network:Class-Name:network
network:ID:THEPLANET-BLK-13
network:Auth-Area:70.84.0.0/14
network:Network-Name:TPIS-BLK-70-85-27-0
network:IP-Network:70.85.27.80/28
network:IP-Network-Block:70.85.27.80 - 70.85.27.95
network:Organization-Name:[xxxx xxxx]
network:Organization-City:Warriewood
network:Organization-Zip:1622
network:Organization-Country:AU
network:Description-Usage:customer
network:Server-Pri:ns1.theplanet.com
network:Server-Sec:ns2.theplanet.com
network:Tech-Contact;I:abuse@theplanet.com
network:Admin-Contact;I:abuse@theplanet.com
network:Created:20041129
network:Updated:20041129

%referral rwhois://root.rwhois.net:4321/auth-area=.
%ok

Wednesday, January 18, 2006

FlashObject 1.3 version check

A correction to FlashObject 1.3 when checking for player version, I got the warnings in Firefox.

Google wasting 200 gigs of bandwidth a day?

Even though the analysis has flaws, content optimization + content compression are distinctive. See the source for AdSense: http://pagead2.googlesyndication.com/pagead/show_ads.js It's already quite compact before the webserver gzipped it further. I don't believe that is the same javascript version developers are viewing internally, I imagine they would see comments and meaningful function names.

read more | digg story

wget & mod_gzip

wget & curl are very good command line tools to test and pretend to be any browser. Here I'm testing Google webservers and support for content compression.

# pretend to be Firefox 1.5
wget --server-response --user-agent "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8) Gecko/20051111 Firefox/1.5" --header="Accept-Encoding: gzip, deflate" http://www.google.com

# pretend to be IE6
wget --server-response --user-agent "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)" --header="Accept-Encoding: gzip, deflate" http://www.google.com

Testing Google JavaScript Compression
wget --server-response --user-agent "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)" --header="Accept-Encoding: gzip, deflate" http://www.google-analytics.com/urchin.js

wget --server-response --user-agent "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)" --header="Accept-Encoding: gzip, deflate" http://pagead2.googlesyndication.com/pagead/show_ads.js

Connecting to pagead2.googlesyndication.com|64.233.187.104|:80... connected.
HTTP request sent, awaiting response...
  HTTP/1.0 200 OK
  P3P: policyref="http://www.googleadservices.com/pagead/p3p.xml", CP="NOI 
DEV PSA PSD IVA PVD OTP OUR OTR IND OTC"
  Last-Modified: Thu, 29 Dec 2005 19:55:11 GMT
  Content-Type: text/javascript; charset=UTF-8
  Content-Encoding: gzip
  Server: CAFE/1.0
  Cache-Control: private, x-gzip-ok=""
  Content-Length: 2268
  Date: Wed, 18 Jan 2006 22:03:43 GMT
  Connection: Keep-Alive
  Length: 2,268 (2.2K) [text/javascript]

JavaScript compression with Dojo Rhino

http://dojotoolkit.org/~alex/js_with_compress.jar This is a modified version of Rhino (the Mozilla JS interpreter written in Java). We (the Dojo project) have added a “compressor” method to the built-in Decompile class. Since we’re operating on the token stream from the parser, this system is somewhat less prone to errors and “overzealousness”. A new “-c” flag sends the “compressed” version of the input to stderr. Normal invocation is:
java -jar js_with_compress.jar -c in.js > out.js 2>&1
This tool will NOT mangle your public APIs. We’re using it as a part of the build process in Dojo and it’s been working well for some time now. It’s much less error prone than the regexp-based stripper we used in netWindows. Source for the tool (i.e., a zipped up version of my anonymous CVS checkout) is available in the same directory as the Jar file. Regards Comment by Alex Russell

mod_gzip/mod_deflate, JavaScript & IE problem

Description: They are not a very good combination as problems have been reported in different applications with JavaScript not loading when served with mod_gzip/mod_deflate on. The error is not deterministic and cannot guarantee 100% error replication but it happens frequent enough.

Affected: The problem only occurs in Internet Explorer (6 and probably lower versions) and refreshing (F5) the page will load the script again. Firefox and Opera do not have this problem.

Solution: a temporary solution is to turn off mod_gzip/deflate in Apache at least for JavaScript in IE.

Reference: http://www.schroepl.net/projekte/mod_gzip/browser.htm

Monday, January 16, 2006

Masters of their Domains

Forget condos and strip malls. Domain names, the real estate of the Web, have been delivering far greater returns. How some of the savviest speculators on the Net are making millions from their URL portfolios.

read more | digg story

Saturday, January 14, 2006

Opera & page body margin

body { margin: 0px; }
In IE & Firefox there will be no margin for the page. In Opera there is still the spacing. Why? Because Opera has in its default styles, just as the CSS2 specification suggests (see appendix A)
body { margin: 0px; padding: 8px; }
To have no spacing between page body & borders:
body { margin: 0px; padding: 0px; }

Friday, January 13, 2006

HOWTO: clear bash history?

[root@ ~]# history -c

Get CPU information

Sample Output:
Make: AMD Opteron(tm) Processor 244
Speed: 1792.558
Count: 2
Hyperthreaded: No

View & sort existing RPM packages

rpm -qa --qf '%{SIZE} %{NAME}\n' | sort -nr | less

Sample Output:
186925230 kernel-source
184937329 kernel-source
74392320 rpmdb-redhat
44488420 emacs
42509842 glibc-common
41262406 libstdc++-ssa-devel
31483893 frontpage
27851009 perl
25825586 comps
23352847 kernel
23219902 libgcj-ssa-devel
22570875 kernel
21628214 rpm-devel
21543354 kernel-smp
20757085 kernel-smp
18808196 gcc-gnat
17833551 MySQL-server
17596278 ant-libs

Thursday, January 12, 2006

wget, login & cookie

If you need to sign into a site and download a file automatically with wget, here is a shell script for that:

Tuesday, January 10, 2006

phpESP 1.8 - Poll/Survey Script - DB Design

Thursday, January 05, 2006

JSCookMenu 1.4.3 Bug

File: JSCookMenu.js line 178
Old: hasChild = (item.length > 5);
New: hasChild = (item.length && item.length > 5);

Purpose: avoid warning because _cmSplit is parsed as an object and does not have length property

Updated: JSCookMenu updated to 1.4.4 with a quick fix for a bug for _cmSplit checking.

Passing Arguments to a JavaScript Function

Firefox 1.5 returns "Warning: deprecated arguments usage" Solution: "var argv = arguments;" Reference: http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Functions:arguments "The arguments object is a local variable available within all functions; arguments as a property of Function can no longer be used."