Friday, July 25. 2008
PEAR bash completion
Lately I've been playing alot with the PEAR CLI. The one annoying thing I noticed the most was its lack of tab completion that I'm used to from the shell. It turns out that this feature is very easy to add, in the bash at least. Here is a simple tab completion script for the bash. In addition to completing the PEAR commands and their respective options, it can even autocomplete the names of installed packages and discovered PEAR channels. Just source it, and enjoy
Tuesday, May 20. 2008
Book review: “Pro PHP: Patterns, Frameworks, Testing and More” by Kevin McArthur
As the title suggests this book is about advanced PHP related topics, being divided into 5 parts and 21 chapters. The title enunciates the book will cover many different aspects, but you'll get disappointed as soon as you perceive it's only about 300 pages.
First part starts with "OOP and Patterns" and will end up with PHP 6's new features. The Patterns chapter is the first one which disappoints you - you'll wish it was a little more verbose, covering some more patterns and being more than only 7 pages.
The next Part is about "Testing and Documentation", covering PHPDoc and DocBook in it's first chapter. In the next one about "Reflection API" - which I think is one of the best chapters - Kevin goes deep into two complete real world examples. But unfortunately then book disappoints you again, trying to cover some topics like "Development Environment", "Unit Testing", "Deployment" and "Continuous Integration" in just about 20 pages. Kevin just skims through introductory concepts of tools like Subversion, PHPUnit, Phing, Xinc and Xdebug.
The third part is all devoted to SPL. Kevin describes SPL from fundamentals to some advanced topics like "Array Overloading" and "Observer Pattern" in a way you wished that all of the book was written this way.
Part 4 covers another Pattern, MVC this time. Describing what it is, why it's good, and talking about criteria you may consider when choosing an MVC framework. Then it helps you to roll your own MVC framework by recommending to choose from one of the publicly available frameworks. The book also covers Zend Framework as one of those "publicly available frameworks" which meets the most criteria in his opinion.
And the final Part, and with no surprise it's titled "Web 2.0". In my opinion the first chapter of this part is the book's truly weakest chapter, it's about Ajax and JSON and it barely covers anything more than what you'll find in any of the beginner Ajax tutorials. But the rest chapters compensates, "Web Services" and "Certificate Authentication".
All in all I found the book a good one, a good next step if you are already familiar with PHP and looking for a book to extend your knowledge, then this one is a recommended one. But I by one would like to see some practical solutions applied to enterprise level when buying a book titled Pro.
First part starts with "OOP and Patterns" and will end up with PHP 6's new features. The Patterns chapter is the first one which disappoints you - you'll wish it was a little more verbose, covering some more patterns and being more than only 7 pages.
The next Part is about "Testing and Documentation", covering PHPDoc and DocBook in it's first chapter. In the next one about "Reflection API" - which I think is one of the best chapters - Kevin goes deep into two complete real world examples. But unfortunately then book disappoints you again, trying to cover some topics like "Development Environment", "Unit Testing", "Deployment" and "Continuous Integration" in just about 20 pages. Kevin just skims through introductory concepts of tools like Subversion, PHPUnit, Phing, Xinc and Xdebug.
The third part is all devoted to SPL. Kevin describes SPL from fundamentals to some advanced topics like "Array Overloading" and "Observer Pattern" in a way you wished that all of the book was written this way.
Part 4 covers another Pattern, MVC this time. Describing what it is, why it's good, and talking about criteria you may consider when choosing an MVC framework. Then it helps you to roll your own MVC framework by recommending to choose from one of the publicly available frameworks. The book also covers Zend Framework as one of those "publicly available frameworks" which meets the most criteria in his opinion.
And the final Part, and with no surprise it's titled "Web 2.0". In my opinion the first chapter of this part is the book's truly weakest chapter, it's about Ajax and JSON and it barely covers anything more than what you'll find in any of the beginner Ajax tutorials. But the rest chapters compensates, "Web Services" and "Certificate Authentication".
All in all I found the book a good one, a good next step if you are already familiar with PHP and looking for a book to extend your knowledge, then this one is a recommended one. But I by one would like to see some practical solutions applied to enterprise level when buying a book titled Pro.
Friday, December 14. 2007
Calling protected SOAP from Mozilla
Recently I had to write a Firefox extension for a company which provides text messaging web services. The Web-Service is an RPC-Style SOAP one which is written by "Nima Shayafar".
When I got this offer, I didn't think that this one would cause any troubles, as Mozilla has a SOAP implementation landed in it's platform since years (
This Web-Service is protected by basic HTTP Authentication, nothing tricky so far, but to my surprise Mozilla's SOAP implementation doesn't provide any mean to do authentication against an endpoint, and nah, not even a basic one.
Well I thought as this (writing Firefox extensions for protected SOAP Web Services) is not that uncommon situation I may get a good amount of information by Googling, but nothing catchy comes there in results except a thread at netscape.public.mozilla.xml where I found two solutions, one was submitting username/password pair together with URL, and the other one was to make an XHR connection to the endpoint (XMLHttpRequest implementation let you provide login/password for a basic authentication), and as Mozilla remembers that for the browser session, you're there.
The first solution is hmm ... horrible! And the second one, I didn't manage to get it to work.
So I started wondering in other possible ways to overcome this, and guess what? It was damn easy!
You just need to set Authorization header in HTTP request (which is base64 encoded of login:password), but just for that particular endpoint, and how?
You need to use nsIHttpChannel in conjugation with nsIObserverService, register it right before invoking the SOAPCall, and (don't forget to!) unregister it when the call is done, that's it.
Well, it took me an hour to come up with this, and I'm writing it in hopes save someone else "one hour".
Posted by Amir Mohammad Saied
in Mozilla, SOAP, Web Services
at
10:46
| Comments (12)
| Trackbacks (0)
Saturday, November 24. 2007
Ohloh API
It's a while since I started using Ohloh API for the facebook app I mentioned in earlier post.
It's a REST-based one with well structured URIs, the only thing that could be implemented better (from the definitions perspective), is the way Ohloh let you know what happened to your request, the response status.
It's now represented in entity-body (<response><status>....</status>...</response>), but IMO using ``HTTP Response Code'' would be a better choice when you're talking about a RESTful web service, data transmitting over HTTP without an additional messaging layer.
Saturday, October 27. 2007
Rock Your Hackers - facebook way
Rock Your Hackers allows you to praise, promote, and in no uncertain terms shout for joy about your favorite free and open source software projects (FOSS) and then share your "Hack List" with your friends (and perhaps fellow hackers)! Wave the banners of your favorite FOSS projects for all your "faceworld" to see.
Here’s how you get started:
1) Add the application
2) Browse for cool FOSS projects (PHP, PEAR, Jaws ...)
3) Add them to your favorites
4) Share your favorites with your friends!
Friday, October 19. 2007
People in the Browser
Flock, the so called "Social Web Browser" has just released the third RC of it's upcoming 1.0 (codenamed falcon), though it's the first public release but is still in private beta.
First of all I've to admit, and let you know that I'm nothing near a review guy, so take this advice, and stop reading here if you're going to use this post as a motivate to start Flocking!
Well, I'm a long-time-but-not-frequent Flock user, actually Flock is the one (browser) which I put behind the proxy to make web surfing a bit more bearable (there're lots of websites which are not accessible here in Iran because of some governments policies, and yes, I won't write that damn word!), at the first I didn't use it's unique features, just simply as a web browser, as a polished Firefox maybe.
But after a while I told myself let's see how Flickr works from within the Flock, and it was great! But doing so for the rest of available integrations didn't go that smoothly, I never managed to make it's Blogging feature to work with my s9y, neither the YouTube experience was great (actually it couldn't be even if wanted to, 'cause I was behind proxy, using a 128Kbps capped connection).
But today, right after receiving an email from Flock guys indicating that the 1.0 beta is ready, I went and downloaded it, and as far as I can tell you, and experienced so far, it's awesome, it's now truly "People in the Browser", if you want to see them (People), simply launch the "People" sidebar, you'll like it.
The catchy feature was facebook integration, the twitter experience was smooth and the Flickr one has just got better.
Actually Flock is where the other browsers are trying to reach using extensions/add-ons. Flock is doing great around it's centric goal, the People, their interactions, media-sharing, communications and the rest, I think if there's a popular'n'cool web-service somewhere, there would be a Flock guy trying to land it into the Flock.
As you may already heard, Mozilla guys has launched a new project called WebRunner, a XULRunner based browser, based on a concept called Site Specific Browsers (SSB). What Flock is doing is not completely SSB (at least when you compare it with the definition over there at Mozilla wiki), but the point is something else.
All of us had experienced a revolution (an evolution to be precise) in web applications in recent months, all those cool and fancy graphics, big bold fonts, nice effects, to-be-desktopish efforts and the rest, but it was just on the web applications side, and nothing on their hosts (aka Web Browsers).
Actually the web browsers was ruining all the fun (e.g., with reaching 99% CPU usage and crashing) because simply they weren't ready.
But now seems web browsers has realized that they are steps behind their guests, they are trying to adopt their selves, and bringing us an even better web-surfing experience.
Monday, June 4. 2007
Wearing the Inside Out(?)
I had always an excuse for not playing with Emacs, and it was that I don't have 24 fingers in my hands, and even if I had, I do promise that those crappy keyboards would break my wrist.
Last week, I bought a new keyboard, a Logitech Media Keyboard Elite.
I must admit that this is the best keyboard that I have ever had, though it has a bunch of useless so called "Multimedia keys".
Well, right after plugging it in and starting my box, I decided to ...
Yess, and finally I migrated from my beloved Vim to Emacs, I'm not sure if I'll stay with Emacs forever but at least I'm withe her for one month.
After writing a cheat sheet and stick it on my monitor pane and learning the basic skills, it was time to port my own Vim plugins to Emacs, If you're a frequent reader of my blog, you probably know I wrote an Audacious plugin for Vim couple of months ago which let me control the Audacious from right within Vim, but now (after a week hanging around in emacs) I really feel that it's missing, and the lack of that code-snippet became an excuse for me to start learning elisp!
There's no doubt that Lisp seems a hilarious programming language at the first glimpse, it will put you alone with Lots of Insignificant Silly Parentheses! But when you got familiar with its syntax and the flow, you'll like it, believe me.
And here you are, an Audacious .el.
Posted by Amir Mohammad Saied
in Audacious, Emacs, GNU/Linux
at
23:57
| Comments (4)
| Trackbacks (0)
Thursday, April 5. 2007
A Vimmiish client for Twitter
Welcome to the crazy world of you've-to-do-everything-from-right-within-your-vim!
I've written a simple Vim script for Twitter, you can update your status and track public or your friends time line with this script.
NOTE: It requires your Vim to be compiled with Python bindings (which is; in most distributions by default)
Wednesday, March 21. 2007
Happy New Year to all PHPers
Happy New Year to all of the PHPers who use the Persian Calendar (also known as Iranian Calendar or Jalāli Calendar).
Happy Norouz!
Saturday, March 17. 2007
PEAR XML_XUL at International PHP Magazine
Today I discovered that my first article finally hit the press (well, e-ones) and it's now available on newsstands (well, e-ones).
International PHP Magazine - March 2007 Issue TOC
(Page 1 of 3, totaling 27 entries)
next page »


