newline characters in PHP error log or debug output

There is a PHP Predefined constant PHP_EOL that allows you to print a newline character if you are running php CLI or if you are outputting text to an error log file.

Apparently, it is also cross platform compatible.

For a long time I was using print statements to throw debug output and had a hard time reading the blob of text output that was getting spit out.

Now my log output and debug output are much more readable :-)

Stumble it!

Some useful and common regular expressions (regex)

Regex for URI

 var uri_re = /^(?:(?:[^:\/?#]+):)?(?:\/\/(?:[^\/?#]*))?([^?#]*)(?:\?([^#]*))?(?:#(.*))?/;
Stumble it!

” Don’t miss this one! “

While waiting for my car to be fixed at the dealership, I was browsing through the day’s local newspaper.

This ad on the business section of the paper caught my eye,

“Great Minds Gathering on Oct 7 - Don’t miss it. Today’s date Oct 23 2008.”

Quite entertaining

Quite entertaining

With all the doom and gloom, market crashes and poor earnings reports, this is the only thing on the business page that brought a smile.

Stumble it!

MPLS ALT.NET - The first get together.

MPLS ALT .NET

MPLS ALT .NET

Yesterday was the first ever MPLS ALT.NET get together at the Bulldog N.E Thanks Ira Mitchell and Jim Swanson for hosting. Judging by the turnout at the initial meet one can easily tell that there is a great enthusiasm for alt .net in Minneapolis.

Jim and Ira do a better job of explaining What ALT .NET is all about.

The folks at Redmond, WA do a great job trying to build awesome tools for developers but often times committing resources to every available tool in the open source community is not possible. Filling this gap is where a community like ALT .NET can help.

The state of Microsoft and the OSS community is better explained by Ayende Rahien.

I hope that this community becomes successful and brings in the best of the OSS, Java and RoR communities into the .NET world.

Stumble it!

Capturing, Debugging localhost HTTP traffic with Fiddler

Fiddler does not capture packets sent to the localhost URL which makes debugging web applications hosted in your local machine painful.

Here is how I configured Fiddler to debug web applications hosted in your local machine,

Lets say your application is accessed using the URL http://localhost:8090/MySpiffyApp/default.aspx. To make fiddler capture the HTTP requests sent to this URL, all you have to do is edit the HKCU\Software\Microsoft\Fiddler\ReverseProxyForPort and set the decimal value to 8090. This tells fiddler to proxy all traffic sent to HTTP port 8888 (default proxy port) to HTTP port 8090. Now access the application using the fiddler proxy port

http://localhost:8888/MySpiffyApp/default.aspx

and you should be able to see the packet trace in Fiddler.

If you see the page below instead of your application then try restarting Fiddler and make sure the registry key name matches exactly as above.

GET / HTTP/1.1
Host: localhost:8888
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.2; en-US; rv:1.8.1.3) Gecko/20070309 Firefox/2.0.0.3
Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Cookie: ASPSESSIONIDAADBDSRQ=NJJLKNGCKNJMNIIFAIDFCEIB
Cache-Control: max-age=0

If you’d like to configure Fiddler as a reverse proxy instead:

  1. Set the HKCU\Software\Microsoft\Fiddler\ReverseProxyForPort registry DWORD to the local port you’d like to route inbound traffic to
  2. Restart Fiddler

Let me know if this didn’t work for you or if you have another way of debugging web applications hosted on your local machine.

Stumble it!

Is this a Revolution ?

A cool rap video about the Large Hadron Collider (LHC) caught my attention and I shared it with some of my old buddies.

I received a few encouraging words mostly in jest about how I should be involved with something revolutionary like the LHC project and drew a few sarcastic comments too.

The email responses from my friends inspired me to write this post and made me understand the significance of the LHC project a little better and also made me realize how we may be overlooking great revolutions happening around us.

Here is my email response,

Dear XYZ,

Thanks for the encouraging words and I enjoyed the sarcasm too…

Revolutions don’t happen overnight… rather they reach a crescendo at the right moment or they erupt from their simmering state into an eruption almost overnight. The trouble with revolutions, too is that you don’t know when they are happening.

The point of sharing that video was to show, how serious research can be presented in a light manner.

And personally, it had a context to me since I recently read this article, Surfer dude rewrites Physics ?that made references to the Large Hadron Collider.
If you do not have the time to read the whole article , here is a snippet that references the Large Hadron Collider,

“…The ultimate proof, or disproof, could then come when the world’s most powerful particle accelerator, the Large Hadron Collider, begins operating later this year in Switzerland. It is widely anticipated that the LHC will lead to the discovery of new subatomic particles, and string theorists are also betting on it to validate some of their ideas…”

In short, the assumptions we are making about how we are held together in one piece can be shattered by this collider.

This my friend is an example of a revolution in progress since it can explain among other truths the beginning(s) and the end of time…

-Senthil

Stumble it!

Obviously overstated

Sometimes you should never understate the obvious. You have to overstate the obvious.

For example here are some obvious Smart people traps and yet they need to be overstated.

I particularly liked the following observations,

..in order to change the world through politics, you must gain power, and the game of gaining power will fuck you up for sure.”

“…They leave school thinking that the way to be useful and show your smarts is to point out why things won’t work, rather than using some of those smart to find a way forward.”

Can you think of more smart people traps like these?

Stumble it!

If sudo apt-get install gitweb fails

I hope this is useful to someone. I was trying to set up git and gitweb.

>sudo apt-get install git-core

was successful but gitweb was not,

>sudo apt-get install gitweb
Reading package lists… Done
Building dependency tree
Reading state information… Done
Package gitweb is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
E: Package gitweb has no installation candidate

If you get this error message,

Try sudo apt-get update

and then run

sudo apt-get install gitweb

This installed gitweb successfully.

Stumble it!

Building online communities

Online communities are popular. In case, you are interested in building one here are some tips from the trenches.

Highlights from the original article

* Build a personal profile:

While it was difficult to get the attention of the mainstream media, Hamilton did find a receptive audience writing for community and neighborhood papers, and speaking to local women’s groups.

* Take advantage of technology:

Linking up with like-minded sites and including lots of references to other electronic sources — especially to lesser known causes such as Ovarian Cancer Canada — has really helped, Hamilton says.

* Seek sponsorships, not advertising:

Traditional advertising is not always available to website developers and the big companies tend to be interested mainly in an audience of millions, but there are tons of smaller sources of support, she says.

* Building a network of skills:

There is only so much one person can do, and Hamilton draws from a loosely knit association of professionals that ranges from web designers, to regular contributors, to brand management specialists. She gets the skills she needs without the expense of a full-time staff.

Stumble it!

Six cool CSS links

Here are some useful CSS links from Christopher M. Leighton-Brooder. Christopher was my colleague and a great designer/ IA.

I asked him for some good CSS links for a beginner and he suggested these, I haven’t gone through all of these links and I am repeating these links verbatim , in his memory.

http://www.gne.net/
http://stopdesign.com/log/2004/07/06/filtering-css.htm
http://glish.com/css/
http://www.thenoodleincident.com/tutorials/box_lesson
http://www.stylegala.com/articles/no_more_css_hacks.ht
http://www.alistapart.com/articles/holygrail

Stumble it!