Archive for the 'News/personal' Category

Maui, PHP Quebec, etc

Friday, November 9th, 2007

Aloha, I'm back from a family vacation in Maui, HI, feeling rejuvenated after having fun on some nice beaches with crystal water, seen an ex-volcano, sunsets, etc.

An email from PHP Quebec was in my inbox saying I'll be speaking at the 2008 PHP Conference in Montreal. Isn't that great?! I'll have a chance to (have some poutine) meet my friends in Montreal, enjoy (the poutine!) the snow I'm sure I'll be missing this year in LA. If you're in Montreal (do try poutine!), the conference is in March and features quite an impressive lineup of PHP speakers.

I had about 200 entries to go over in my RSS reader. I don't read a lot of blogs (not up-to-date list here) but those that I do are really interesting. That explains why after 2-3 hours of reading, I have only 150 out of 200 posts left to read. Anyway, here's a jewel I came across today - theonion.com (via)

 

On Raymond Chandler’s writing

Friday, October 26th, 2007

I've never been into crime fiction. I mean I've read The Hound of the Baskervilles, but that's about it. I like Douglas Adams, Terry Pratchett, looove Kurt Vonnegut, enjoyed On the Road, Catch-22... So it came as a surprise even to me when I started reading Raymond Chandler and actually enjoying it. The thing is I love to learn about the places I visit - culture, people, history, geography. Living and curious about LA now, I came across an article saying that Chandler wrote quite a few things about LA and California that stuck around. Anyway, I picked up a volume, read The Long Goodbye and loved it.

Just read an article about Chandler's writing process. Since I just started working on my new book, I found the article pretty interesting. The "normal" editing process I think is: you write a draft, you review it and scratch some parts, maybe replacing them with others, adding, removing. Chandler did the opposite - he underlined only the words that will stay in the next draft, everything else is to be rewritten or simply gone. This way he could tighten his sentences if not cut them in half. I like that a lot. Short is good, short is often clearer. It's so easy to be verbose, hoping this will clarify whatever you want to say. But often it isn't. I believe Mark Twain said something like "I would have written you a shorter letter, but I don't have the time"

That makes me think - it's so bad that most computer books today don't aim for brevity, but for volume instead. I've heard authors saying that their publishers love to ship big ass books on the market, because supposedly readers want big books. If it's big, there must be good stuff in there. Luckily my publisher is not like this, of course :) Although they would probably also agree that the overhead of publishing a 100 pages book is pretty much the same as a 1000 pages book. A tiny book still needs to go through the same process as the big one. So why not ship a bigger volume that will look more impressive. Imagine the dialog:

- Honey, how do you want to decorate this room?
- Hmm, I'd love to have a shelf of Java books right there, about four feet long. Yes, and right below it, gimme some design patterns and some .NET, half and half. Fabulous!

 

The “best programmer ever”

Monday, September 17th, 2007

Go ahead, do a Yahoo search for "best programmer ever". Not surprisingly #1 result is the blog of yours truly :)

best-programmer-ever.png

For some inexplicable reason, I'm not #1 in Google search results for the same query. Bizarre, isn't it? Not even on the first page. But hey, there a difference between being yet another piece of software that mines an insane amount of pages, giving matches to a query and being a smart piece of software that mines insane amounts of pages.

So, yeah, sweet stuff, and let me return the compliment with some link love back - thank you, best search engine ever. :D

 

LA Web devs meetup at Yahoo

Monday, July 23rd, 2007

So there is this group of local LA web developers that meet every month or so to meet and discuss what's up. More about/join the group here.

This month Yahoo will be hosting the meetup in the Santa Monica office (my workplace), it's actually tomorrow, so if you're in LA, don't miss the opportunity for beer, pizza and meeting fellow web devs. RSVP here.

On Yahoo's side, Jim Bumgardner, a.k.a. krazydad will be demoing the Facebook app he did that allows you to find music videos and discover artists similar to the ones you like. The app, Jim talking about it, Yahoo Developers Network posting.

Sounds like it would be fun, and also a chance for a local web dev to see what Yahoo's office looks like, meet some of the people that work here, and in a way to try-before-you-apply :D

 

On a publishing diet

Thursday, July 12th, 2007

So I launched this little tool csssprites.com that allows you to upload images and create one CSS sprite image, plus it gives the background-position CSS definitions to use in order to show parts of the sprite. People have been trying it out, but unfortunately sometimes uploading 20 megs of images to create a sprite, which is not the point of the css sprites technique. Anyway as a result I exceeded the disk quota my host gives me and since the site is hosted on the same server as this blog, the blog stopped working. Hence the publishing diet.

Initially I blamed WordPress because it started acting strangely, asking me to update my database, saying that I don't have admin privileges, then not loading the CSS files and finally just stopped working even on the front end. I said oh well, I need to upgrade it anyway, so let's do it now. Just trying to FTP a single file got me the message that I can't copy so I finally figured out the real case - the exceeded disk space.

It's all good now, I just deleted all CSS sprite images that were generated, I was planning to do a cron job do delete the ones older than a day or two anyway, but never got around doing it. I should just check and warn the cssspritres.com users not to upload huge images, because this is not how CSS sprites were designed to work anyway.

Long story, short message. I'm off the publishing diet now.

Meanwhile I wrote an article for the International PHP Magazine, it's an intro to unit tetsing with PHPT, called "PHPT - Unit testing for the rest of us". Nice, eh? Just got an email today that the new IPM issue is out the door, you can check the TOC here. I wanted to further experiment with PHPT and was thinking of writing this test generation tool. Say you have a bunch of classes, you run the tool and it generates PHPT test stubs, based on the classes and methods in finds. Then you tweak the generated stubs here and there to implement the actual tests. PHPUnit has this feature, so why not PHPT as well. We'll see if I'll find the time.

On a different technology, I was playing around implementing the decorator pattern in Javascript, will post about it later (sneak peek).

On a different subject, just added a few very simple tools to my favorite Textpad, I found them helpful for PHP development, will post about them later.

On a yet another subject a few days ago I finished a draft outline for my new book-to-be and we started discussing with the editor.

On a totally unrelated subject, I did a new phpBB theme (copy of the default subSilver) following as many of the Yahoo front end performance rules as I found applicable. Naturally, I'll post about it later.

Otherwise life has been good. I moved with my family to LA to start working for this company called Yahoo!. Work is great, LA was bit of a surprise and not very welcoming, but hey, it's the experience. We had some initial rental issues (we lost quite a bunch of money double and some point triple renting), then there was the stress of the whole move, having to start everything over again, driving licenses, shocking 20% APR rates from Toyota, credit cards refusals and stuff (the only thing that I still use here from Canada is the Costco card!). Yahoo did help a lot during the moving process, can't imagine what would have been without all the little and not so little perks I got during the relocation. So anyway, after all that initial shock, the family is starting to settle. The kids just loooove Disneyland, we ended up getting anual passes for California residents, so we'll be seeing it a lot. Also the beach is quite nice, not the cleanest mind you, but it's probably because we're new don't know where to go, we just hit the closest to us, in Venice. By the way, Venice is amazingly similar to some little Bulgarian towns on the Black Sea. In general LA is quite expensive, especially the Santa Monica area, where the office is, but I wanted to be close to the family in those times of change, so we ended up renting a place only 5 miles from the office (still getting used to those miles and pounds). I proudly bike to work now, doing my share in saving the environment. Half an hour in each direction, it's a nice excersise. Talking about biking, here's some biking-to-work wisdom for you:

Tree branches are hanging lower than they appear.

also

Just when you thought you learned how to bike without using your hands and to light a cigarette meanwhile... you didn't.

 

My 5 strenghts

Tuesday, June 5th, 2007

I got a copy of a book called strengths finder (or something) that advocates that you should know, love and get your strengths to work, instead of focusing on correcting weaknesses. They have an online test to figure out your strengths, here are mine.

  • Ideation
  • Intellection
  • Adaptability
  • Input
  • Positivity

Nice list, eh? Basically I'm full of ideas, but the completion part kind of falls behind. Which is something I should need to learn to put to work, instead of correct. Pretty cool.

Although English is not my first language, not even the second, I could swear Ideation is not a word, but Firefox's spell checker corrects me, it says that actually Intellection is not a word :)

 

AJAX-MCV in Russian

Monday, January 29th, 2007

Boris of http://www.ajaxplanet.ru/ has published a translation of my article on the little AJAX/MVC framework I came up with, this is trully flattering, thanks a lot!

If you speak Russian check the post here.

The translation is by Gennady Potapov, sposibo Gennady!

 

DB-2-MDB2 in Portuguese

Tuesday, January 16th, 2007

Through a trackback I found out that Walter Cruz has translated my DB-2-MDB2 article in a language I was led to believe is Brazilian Portuguese.

Thanks very much Walter, this is very flattering!

Thanks to my buddy Isidoro who enlightened me that the language was Portugeese!

 

Canadian

Tuesday, January 16th, 2007

It's official, last Friday, Jan 12, I pledged my allegiance to the Queen (and her successors) and sang Oh Canada in French and English. Now I'm Canadian.

Incidentally this happened 10 days after Jan 2nd when Bulgaria became part of the European Union. Now I am European Canadian, North American Bulgarian and otherwise a citizen of the Big Wide World. It feels good :D

 

(almost) Canadian

Friday, November 3rd, 2006

After living in Montreal, QC, Canada for a little more than 4 years, yesterday me and my wife passed the citizenship exam and we're almost Canadians now. What's left is waiting for another invitation in the following weeks for a ceremony, including pledging allegiance to Ellizabeth II, the Queen of England and singing O Canada! Soon I'll be able to tell I have the same citizenship as my kids, they are already Canadian, since they were both born here.

Note to the person responsible for writing my bio in the encyclopedias of the Future - start with "Stoyan Stefanov is a Bulgarian Canadian, who ..." :D

 

Personal news update Nov/06

Wednesday, November 1st, 2006

So what I've been up to recently? Having a bit of a break, I guess. First, I'm not currently writing a book, after the last one for which I completed my chapter back in June. That's some free time (There is a very exciting book project on the horizon though, we'll see). Then, I'm not working so much on our new house. Now (August) that my family is back from Bulgaria, and the two little princesses are running around, it's next to impossible to do any construction work, however small.

I changed my job not so long ago, I'm working for SAP now, here in good old Old Montreal. Meeting smart people every day and learning new things, SAP has quite a bit going on and there's always something to learn. Take the proprietary ABAP programing language for one.

As always a PHP junkie, I looked into what's possible in terms of integration of PHP and SAP. Turns out it's possible and it's fun. There is this open-source SAPRFC PHP extension, that allows you to use PHP to connect to an SAP system and do stuff. Out of this interest a few things happened:

  • I published an article at the International PHP Magazine about a tool (or more like a collection of tools), called Scripting In A Box which is developed at SAP. It's one big archive (as in ZIP) which you unpackage to your C:\ drive and you get Apache, MySQL, PHP(+SAPRFC), Perl, Ruby/ROR, Python, Eclispse(+PHPEclipse), all pre-configured and running together. So you can start scripting in minutes. This tool actually gave me a chance to try out and love PHPEclipse, something I've missed, being so attached to my TextPad and ignoring any other way to do PHP. Now I can highly recommend PHPEclipse as a PHP IDE.
  • Next, some folks at SAP (Thanks Craig, AndrĂ©!) recognized my PHP experience and asked me to do a little demo of SAP+PHP at SAP's big event, called TechEd in Las Vegas. This was quite an experience! Las Vegas is one different place and the conference itself was pretty big with 5000 people, I think. I had a chance to meet guys from SDN (SAP Developers Network), which is quite a vivid community with something like half a million members. You know what's the everage response time when you post a question on the SDN forums? 7 minutes.
  • Then, I wrote another article for IPM, which described the demo I did at TechEd. (I'll add the source code and some screenshots at the bottom of this post.)
  • I also contributed one new container for the PEAR::Auth package, it allows you to authenticate users against an SAP system in your PHP app.
  • Another contribution to PEAR was the ABAP language definition for the Text_Highlighter package
  • Finally, I did a little ABAP console, but I'll blog about it seperately and will share the code, of course.
  • ... and my first posting on SDN was published today. The next one will be a sort of a cross-post here and on SDN about the ABAP console thingie.

I think that's about it for SAP. Otherwise, as usual, I get easily excited by different things, so I've been doing this and that, here and there, on my own terms, relaxing, without any deadlines preasure.

On the pipeline, I have a bit of stuff to do, again, small little things I enjoy doing, like helping with one article for the PEAR::MDB2 manual, assembling an extra intro chapter for the PEAR book, helping out with Text_Highlighter (I'm this package's official helper since a few days ago), also doing some work for the Image_Text PEAR package, as well as anything else that comes into the radar any given day. Yeah, this is how I understand relaxation, doing whatever you're passionate about, even if this means less sleep at night. Ah, and I have the test for Canadian citizenship tomorrow, so I should be reading as opposed to writing now (I always do this, the busier I am, the more interesting things I "shoehorn")

SAPRFC/PHP demo files

Yeah, the demo app uses YUI and a bit of AJAX and animation to make it a bit sexier.

 

The PEAR book

Sunday, October 15th, 2006

PEAR bookIn case you've missed it - the PEAR book hit the streets! The exact title is "PHP Programming with PEAR" and it's co-written by Stephan Schmidt, Carsten Lucke, Aaron Wormus and yours truly. Aaron also put up a Wiki for book and PEAR-related updates, it's at thepearbook.com

I tried to put up a list of the packages and classes covered in the book, I've probably missed some classes, especially Date_* and Calendar_* ones, but I hope I got all the packages. Here goes (alphabetically) :

  • Calendar
  • Date
  • Date_Holidays
  • Date_Span
  • Date_Timezone
  • File_PDF
  • HTML_Table
  • HTML_Table_Matrix
  • HTTP_Request
  • MDB2
  • MDB2_Schema
  • Services_AmazonESC4
  • Services_Ebay
  • Services_Google
  • Services_Technorati
  • Services_Webservice
  • Services_Yahoo_Search
  • Spreadsheet_Excel_Writer
  • Structures_DataGrid
  • Structures_DataGrid_Column
  • Structures_DataGrid_DataSource
  • XML_Beautifier (mention)
  • XML_FastCreate
  • XML_Parser
  • XML_RPC
  • XML_RPC_Client
  • XML_RPC_Message
  • XML_RPC_Response
  • XML_RPC_Server
  • XML_RPC_Value
  • XML_RSS
  • XML_Serializer
  • XML_Util
  • XML_XUL

For more info on a package, you can consult the PEAR site and manual. Did you know that you can access a package's page by typing its name (case insensitive) in the URL after pear.php.net, like http://pear.php.net/mdb2_SCHEMA for example?

 

RSS feeds

Friday, October 6th, 2006

Here's a list of RSS feeds I'm subscribed to, I'm using the Google Reader thing and check these usually once a day, sometimes several times a day, if I feel I need a break and don't have anything in mind. These have become de facto the way I get informed of what's up, my pretty limited view of the world, if you wish. Sometimes I feel a bit guilty of using the feeds, for example I don't visit SitePoint as much as before I subscribed to its feeds, therefore I'm not so exposed to their ads and so on, feels a bit like stealing. Anyway, on to the list.

The list is ordered as Google Reader orders it, seems like alphabetically, only the first ones had some spaces in the names. The list was produced from their OPML export feature. How I managed to get HTML out of the OPML would be a subject of another post. OK, the list.

  • [RSS] The Net is Dead - Life Beyond the Buzz
    Marco is this cool guy, web dev from Netherlands. I "met" him through his comments on my CSS conventions post, which turned out to be a bit controversial at times. Marco was totally on my side. Seems like he's pretty busy now and doesn't post as much as he used to, but I'm sure he'll be back.
  • [RSS] phpied.com
    My own blog, yes, now narcissistic of me, I subscribed as part of the blog's QA process (or lack thereof) ;)
  • [RSS] SitePoint Blogs
    This has been my primary source of web-dev-related information and news for years. Very good stuff on the blogs, especially Harry Fueck's posts!
  • [RSS] Bruce Eckel's Weblog
    Bruce Eckel is the author of the Thinking in Java|C|Python books, he doesn't post too often, but what he has to say is a must-read.
  • [RSS] Creating Passionate Users
    Recently found and subscribed, because of this post. Haven't been really reading it since, unless the title is catchy.
  • [RSS] Fleegix.org
    SitePoint author of an AJAX book I recently read, loved and reviewed on Amazon, added the guy's feeds after reading the book.
  • [RSS] Isidoro's Blog
    Just testing a buddy's blog. Doesn't post much and when he does, it's in Spanish. And I don't know Spanish, apart from one meaningless poem. OK, let me see how the poem goes. Aham - "Tipi-tape, tipi-tape, tipi-tape, tipiton. Tipi-tape, zapa-zapa, zapatero remendon."
  • [RSS] Ivo Web 2oo6
    The only request I've ever got to add somebody to my blogroll was from Ivo. I thought I might subscribe to his feed first. Posts in Bulgarian.
  • [RSS] Let the Good Times Roll--by Guy Kawasaki
    I've seen this Guy quoted here and there, so I decided to subscribe. Apparently he has (had?) something to say, but lately seems like becomming a top-whatever-technorati is more important for him. Haven't read a full post recently and I do hate list posts, you know like "10 ways to ... do something". Such posts always remind me of this Douglas Adams's joke about a book, called something like "101 things you never wanted to know about sex, but have been forced to find out"
  • [RSS] Official Google Blog
    Mhm. Although I don't think I've leared much there. Most of the important news tend to spread organically anyways.
  • [RSS] Paul Graham: Unofficial RSS Feed
    Love his articles. This unofficial feed works in its weird ways, but it's better than nothing.
  • [RSS] PhilRenaud.com
    A blog I found through stylegala.com, loved his design and subscribed (since I don't have the habit of bookmarking). I like his posts, but recently haven't read anything, he decided not to have the full-size posts in the feed, so this extra click turned out to be too much of an effort. That's sad, come to think of it.
  • [RSS] PHP: Hypertext Preprocessor
    PHP news, not too often and seems like more conferences than anything else. The rest just spreads.
  • [RSS] Poo-tee-weet
    Lukas Smith, the guy who did PEAR::MDB2!
  • [RSS] QuirksBlog
    This guy knows his javascript, I'd love to read his book (if the publisher is reading, please don't hesitate to send me a review copy)
  • [RSS] SAP Developer Network SAP Weblogs by Piers Harding
    I've been experimenting with SAP and PHP connectivity and this guy has done a lot, but with Perl, Python and Ruby, no PHP.
  • [RSS] Signal vs. Noise
    With all the noise around Ruby On Rails... I don't like most of the posts though, I mean how much (or less) can you say about "less". There are exceptions though.
  • [RSS] Simon Willison's Weblog
    Followed to his blog from the times he contributed to SitePoint. Not too many posts though.
  • [RSS] SitePoint.com
    SitePoint again, this time it's feed for their articles. They have some really good articles ;)
  • [RSS] Stylegala | news
    Admin-posted news on Stylegala. Always fresh, always good.
  • [RSS] Stylegala | public news
    Public news on the Stylegala site. Anyone can post (I've done it myself). Firstly from here I get news about interesting web-developments (for example I'm not subscribed to ALA, because people post the links to Stylegala) and secondly I find stuff that is posted by guys like me, that probably won't be the-next-biggest-thing, but is often very, very interesting. Democracy in action - Google's next tool, together with the small guy's latest JS trick.
  • [RSS] Web Standards with Imagination
    The title says enough about the topics. I like his posts very much. Lately he's been podcasting more than blogging, but that's still good.
  • [RSS] Webmaster Central Blog
    This is something new from Google and so far not too appealing, unless you're into SEO and getting ranked well. Or getting paid to get someone else ranked well ;)
  • [RSS] Yahoo! User Interface Blog
    Not much posts, but good stuff. Sometimes by Mr. JavaScript himself!

In addition to that I'm subscribed to a few mailing lists, of which I read the PEAR-General and PEAR-Dev ones, the rest (such as YUI list) is just storred by gmail for latter searches ;)

 

HTML2DOM

Thursday, September 14th, 2006

Here's this HTML-2-DOM service - http://www.html2dom.com What it does is pretty simple - you paste some HTML code and the output is JS script code that uses DOM functions to produce the same result. Could be useful when you're working on an AJAX-style app that generates new content using JavaScript.

I build this simple script, inspired by this great book I was reading - "Build Your Own AJAX Web Applications". In the book, the author sometimes starts with writing up what is the HTML code for the result you want to achieve, and then goes ahead with giving the DOM code. Because, you know, DOM code can be quite verbose and sometimes a bit hard to follow. So I thought, why not write up a simple tool to automate this HTML to DOM transition.

The code is not complicated at all, it just takes the HTML, treats it as an XML document, then loops through all the elements of the XML doc and all the attributes for each element. The script is here, hopefully reusable and you can grab it for your own projects if you wish. You can check the source of html2dom.com's index page for an example how to use the html-2-dom class.

Some limitations of the script (that I know of) are result of the fact that I'm treating the HTML as XML document. So you might get some errors if the HTML you paste is not well-formed, with all closed tags and so on. Also you cannot use   and other entities, because XML doesn't know about them. What XML knows is only the pre-defined 5. And last, out of the different node types, my script understands only three - element, attribute and comment. I think it's enough for the practical purposes I was aiming at, even the comment type is a bit of a stretch.

So enjoy and as always, any feedback is welcome!

 

The PEAR book is on it’s way

Tuesday, September 12th, 2006

PEAR book Here's the link to publisher's page dedicated to the PHP Programming with PEAR. Guess who wrote the chapter for MDB2? ;)

It's an honour to me to be in the company of the other authors, people who have done a lot for the PEAR community:

Here's what the book is about:

  • Accessing databases with MDB2
  • Displaying data in a range of formats (HTML, Excel spreadsheet, PDF)
  • Creating and parsing XML documents
  • Serializing PHP objects into XML, and unserializing XML documents to PHP objects
  • Consuming and offering web services
  • Accessing Web APIs including Google, Yahoo, Amazon, and Technorati
  • 250 pages of good stuff :) Get your copy or just spread the word!

    Update: In the rush to share the news I forgot to say a big "thank you!" to Lukas Smith, the man behind MDB2, who was responsive as always and was kind enough to review my chapter.

     

    HiLiteMe.com

    Sunday, September 3rd, 2006

    In case someone is wondering how do I highlight the code I post on this blog ... well, the lazy way. I don't. Some time ago I setup a free service, hiliteme.com to do it for me, then I just copy/paste the generated code. It's far from the best solution, but it's definitelly the laziest, without any spend-time-to-save-time effort on my end ;)

    So if you ever need to highlight source code - for a blog, word doc or whatever, you can use this free service, I'll be happy. HiLiteMe.com is using the PEAR Text_Highlighter package (I talk about it here)

    BTW, I think in general it's a good idea is to use JavaScript to do the code highlighting. After all, it's just presentation and if it can be done on the client, why loading you server with this task. I know at least two free scripts that do that, there's probably more. The one that looks very good is this one.

     

    News update

    Tuesday, July 25th, 2006

    Hi all, after a long time of silence, I wanted to drop a line here to say I'm still alive. I'm back from beautiful Bulgaria, had a great time there, friends, family, trailer trip. Now I'm back in Montreal, moved to and working on the new house we bought at the end of May; it's coming along pretty nice, but all this renovation work really does take time, especially if you're doing it yourself ("with a little help from my friends") and you don't have too much experience. But I'm actually enjoying being away from the monitor all day, it was a surprising discovery ;)

    Meanwhile other things are happening, but they are mainly result of work I've done previously. The second part of my MDB2 tutorial was published in the IPM (TOC). In the same issue, the magazine published a book review of mine, actually it's the first book review I've ever written. It's about this excellent book - AJAX and PHP. I have a few other book (and one software) reviews piped, I'll probably publish them here on this blog. Meanwhile I also became the lead dev for the Image_Text PEAR package, expect a quick intro soon. The last news is that I submitted the first draft of one chapter I'm contributing to what is going to be a great book. Details later.

    I thinks that's it for now. Probably there won't be too much postings in the nearest future (I started a new job on top of everything), but I'll be back!

     

    Bulgaria, IPM, quick update

    Monday, June 12th, 2006

    I'm currently on a vacation in my native land Bulgaria, the party's on (and so the soccer World Cup finals) so It wuould be quiet around here for a while. Meanwhile I've disabled comments, trackbacks and pingbacks, I appologize, it's just that I'm receiving a lot of spam and since I don't have the time to clean it, the spam will look as an insult to my readers.I cannot find the WordPress option to disable comments retroactively, so all comments will be held for moderation. I appologize once again.

    Meanwhile my article on DB and MDB2 was published in the International PHP Magazine, the TOC is here. This article is an extended and improved version of the original DB-to-MDB2 blog posting you can find here, plus I've added an intro part in case you've never used DB or MDB2.

    BTW, I'm enjoying writing this post on a dial-up and using IE5.5., this is an experience that is pretty ... interesting ;)

    l8r!

     

    Amazon Connect blog

    Monday, May 22nd, 2006

    Just finished setting up my Amazon Connect profile and posted one message to the blog Amazon create for you when you set your profile up.

    Here's the blog.

    Amazon Connect is an initiative where book authors can post messages directly to their books pages. So my smiling face is exposed on Amazon now when you browse one of the two phpBB books. Pretty nice. I mean the Connect idea, not so much the face ;)

    BTW, Amazon really have to work on those URLs to make them friendlier. Every time I post an Amazon link anywhere, it's just waaay too long and usually messes things up.

     

    The Focus and The Pocus

    Thursday, March 30th, 2006

    About tfatp.com

    The Focus and The Pocus (a.k.a. tfatp.com) is a toy project of mine, started a couple of days ago in a moment when I had so much work on my plate, that the only way to stay relatively sane was to take a break, doing something different ;) . So it goes.

    User guide / feature list

    • Go to the site, move your mouse around and admire how colors are changing.
    • Click a square to "freeze" a color. Click again to un-freeze.
    • Point you mouse to the upper right corner to see the color definitions and a link to this page.

    If you freeze a nice color combination, fell free to mail me a screenshot, I'd appreciate it.

    OK, why? / History

    Sometimes when I think about something (or just convincingly look as if I am), I find myself staring blindly into my monitor and clicking here and there. A usual place for this activity (due to the lack of a more appropriate word, let's say we'll call it activity) is the desktop where I single-click icons and watch them getting highlighted. Another fave is any average phpMyAdmin table, where colors change as you hover over a row and change again when you click.

    In one such occasion a few days ago, that tfatp idea came to me and I thought it would be a nice CSS/JS exercise. So it goes.

    The name is kind of influenced by Vonnegut's Hocus-Pocus, I'm currently re-reading some of the Vonnegut's books for the n-th time. How Hocus-Pocus became tfatp - well, if you've tried registering a domain name recently, you know it ain't so easy to get what you want. (But, as the old Stones' song goes, sometimes you might just get what you need :) )

    In case you're wondering, "so it goes" is an often-repeating phrase from Slaughterhouse-5. So it goes.

    Todos

    • You might not notice it, but every time you click to freeze a color, it's saved to a database. So a to-do is to produce a report, once there is enough data, of which colors are considered freeze-worthy by people that come to the site. Maybe it can be useful the next time you design a site and you're lacking color ideas.
    • More interesting reports such as color of the day, of the week, by location... (Thanks, Brian!)
    • "Your color combination on your blog" sort of thing
    • Static URLs. If you freeze one or several nice colors, you should be able to get a static URL to send friends and family and they could reproduce the same thing.

    If you think of a nice new feature - let me know.

    Coding

    In terms of coding it's all best practices. No, I mean, seriously. Well, front-end best practices at least. On the backend it's not the case, because the backend is just a few lines of PHP code.

    Best practices, because there is a clean separation between:

    • content (a.k.a. markup or HTML),
    • visualization (a.k.a. styles, formatting or CSS), and
    • behaviour (JavaScript).

    This means no font tags, no tables, no style attributes, no onclick-s or onmouseover-s. Needless to say it's XHTML-strict compliant.

    Implementation

    HTML

    Nothing interesting here, just 4 divs placed in a container. That may explain why the markup is so beautiful and XHTML-strict. It would be actually harder to make it non-standards compliant ;) Check the source out.

    CSS

    Here's the stylesheet. I'm using float to move the squares to the left and to the right and position: absolute to make setting the positioning and the heights possible. For example the fourth square (bottom right) has top: 50% and left: 50%

    Behaviour - events

    I'm using Yahoo! UI library scripts to attach events to different elements on the page. (Check my previous post for more Yahoo! UI). So I attach a mouseover listener to the container div. It's lazier than attaching 4 listeners to the 4 squares. Then I check the event to see what was clicked. If a square was clicked, I call a method to change its background.

    BTW, all JS code is in behaviour.js

    Similarly I attach a click event to the container div to do the freezing.

    And two more listeners to handle mouseover/mouseout on the little "About" div.

    JSON

    Using the JavaScript Object Notation, I'm defining a variable focuspocus which is a class instance that contains all methods and properties I need, thus keeping the global namespace clean of any functions.

    Colors

    Generating random colors is easy, just use Math.random() to generate a random red value, a random green and a random blue. Use them to set the background by using the rgb(r, g, b) form.

    Then getting the color value back is the tricky part (as I'm writing this I just thought I could simply store it once it's generated, duh!). So I'm using my little RGBColor library (described here) in its lightweight version (also used here) to parse the value returned by getComputedStyle() a.k.a. currentStyle in IE.

    AJAX

    I just couldn't launch anything without using AJAX, could I? So once you click to freeze a color, there is a tiny AJAX request to send the color you've just frozen and the square where you clicked. The aim is to store those and at some point try to make a noble use of them.

    To make the AJAX request, I'm using the Yahoo!s UI connection lib.

    YAHOO.util.Connect.asyncRequest(
        'POST',
        'frozo.php',
        {success: function(){}}, // callback
        'color=' + thecolor + '&sq=' + theid
    );

    Easy, isn't it? There is no response from the AJAX request and none is actually needed. So the success callback is an empty function. Just POST-ing two variables to frozo.php

    Server-side

    "Server side" is too big a name for the few lines in frozo.php. There is just DB connection and an INSERT. The interesting thing is that there's no DB abstraction, config, none of that. Just the good old mysql_query() call, which (don't tell anyone, but) I actually had to lookup on php.net, since I've used abstraction layers for years now and I've kinda forgotten... So it goes.

    <?php
    // error reporting - none in production
    error_reporting(E_NONE);
    // sanity check
    if (empty($_POST['color']) || empty($_POST['sq'])) {
        die();
    }
    // session init
    session_start();
    // db connection
    $db = mysql_connect('host', 'username', 'pass');
    mysql_select_db('database', $db);
     
    // insert
    $sql = sprintf(
        'INSERT INTO frozo VALUES("","%d","%s","%s","%s",UNIX_TIMESTAMP())',
        intval(str_replace('sq','',$_POST['sq'])),
        mysql_real_escape_string($_POST['color']),
        mysql_real_escape_string(session_id()),
        mysql_real_escape_string($_SERVER['REMOTE_ADDR'])
    );
    $result = mysql_query($sql);
    ?>

    Thanks for reading!

    And have fun - tfatp.com. Hope you enjoy it. I surely enjoyed coding it ;)

     

    Happy birthday and a new book

    Tuesday, March 7th, 2006

    phpbb-guide.jpgToday my blog turns 1 year, hence a few hiccups with the DNS change and the migration to a new server (thanks, Eric Gruber for the heads-up).

    Blog stats: 85 posts and 183 comments(thanks everyone!), contained within 19 categories. Actually this post's ID is 100, but I have a few drafts lying around...

    I started this blog as a diary while preparing for the Zend PHP exam, hoping that others will benefit. Now it's more like a little bit of this, a little bit of that, web-dev stuff. Anyway, hoping I'll post more this next year. Actually 85 posts is about once a 4 days, hmm, not bad, I thought I was lazier than this.

    So celebrating the blog's first day I treated it to a nice new theme, designed by Marco and ported to WordPress by Christoph. Nice, thanks guys for you work!... I also updated to WordPress 2, very slick.
    (Marco has also published a post about my blog, that's very, very flattering...)

    And as another present, I saw that the second phpBB book is out! It's a scaled down version of the first, basically without the more advanced programming chapters and it comes at a much lower price.

     

    Car accident

    Wednesday, November 30th, 2005

    Crashed the car two days ago. The road was all ice, with just a bit of snow covering it. Raining, very cold, awful weather. I went out to return the books to the library and a DVD to the video store. Several times when I hit the breaks I felt that the tires are not rolling, that the car is just sliding. I even looked at the tires to see if there something wrong with them. All this to say I was extra careful and driving really slowly.

    On my return, a block from my place I took a left turn. The car just didn't change direction at all, just kept straight. I was sliding. I released the break pedal, didn't help. For a millisecond I was just sliding, with no control over the vehicle, basically just sitting there like a passenger. I had time to see recent parts of my life running before my eyes ;) , I thought about my two kids, I thought about my wife and the last thing I thought was something like "Looks like I'm gonna crash... can I be any dumber?".

    ...then I hit an electricity pole.

    The whole situation happened so fast and I felt so, so stupid. I mean I had my winter tires on, I was extra careful, because I felt the road was slipperly, I was driving very slowly (fact is, the air bags didn't even deploy). Haven't been drinking or smoking or anything. And I was just a block from home...

    Today my neighbour cheered me up: "Don't worry, there are only two types of cars - crashed cars and those that will crash" ;)

     

    Found in translation

    Tuesday, November 22nd, 2005

    Whoa! Today I found out that one of my posts on this blog was translated in Russian. That's quite a compliment for me. Many thanks to the guy who translated the post, or I should say ?‘???»?€???µ ?????°?????±??, ?¤?µ?????????? ?????·?????°! I can only hope that the Russian PHP community will enjoy the reading.

     

    phpBB book review

    Sunday, November 20th, 2005

    I was browsing Amazon today and decided to check the page of my phpBB book. There was a new (second) review by a reader, very flattering :) Many thanks to the both reviewers if they happen to read this blog post someday!

    Got me thinking - is anyone reading this interested in writing a review of the book? Doesn't have to be a praise, just an honest unbiased review. (Unbiased reviews are really something rare these days, when everyone seems to be an affiliate of the product they are reviewing).

    If someone is interested in reading the book, learning a great deal about phpBB :D and sharing his/her thoughts, let me know. I'll speak to the publisher. The condition of course is to publish the review somewhere - on a site, magazine, or somewhere that it has chances of being read ;) Sitepoint is a good example I can think of right now to publish on. Or your local PHP user group. Contact me at stoyan at phpied com if you think of something.

     

    WebConsole – Take command (line) with AJAX

    Friday, October 14th, 2005

    My article describing how to create a simple Javascript XMLHTTP application is now featured on SitePoint. How cool is that!

    A bit of history: several months ago I thought SitePoint, my daily read, was missing an intro article on AJAX, so I sat down and wrote one. Meanwhile, while I was preparing it, SitePoint published this excellent AJAX tutorial by Cameron Adams. (Do check this guy's site! He definitely knows his JS!) His article was overlapping mine in the intro part. So I thought it doesn't make sense to have two intro articles and revised mine, basically stripping the intro part and leaving just the second part - the creation of a simple WebConsole application - a web interface for executing shell commands (Try it out here). This second part of the article was published today on SitePoint and I'm quite proud of that fact ;)

    Then some time later I saw that DevMo - Mozilla Developers Wiki - started an AJAX section and there was an invitation on it for somebody to write the "Getting Started" article, that was missing at the time. And since I had my intro tutorial lying around, I just published it right there on the Wiki.

    So if you're new to the XMLHTTP (AJAX) concept and looking for a place to start:

    • Start with the DevMo article, then
    • Read through the SitePoint articles - Cameron's and mine, then
    • Check the links at the end of the SitePoint article, then/or
    • ...just experiment on your own!

    BTW, as another real-life example of the reusable JS function for making requests, which is discussed in the SitePoint's article, check this out. It's a little AJAX touch for phpBB, scroll down where it says "Word of the day" and "Mot du jour", click. How is it working? Well, I have a simple PHP script that hits two RSS feeds - Dictionary.com and a French blogger's. My script caches the XML file just not to abuse the RSS feeds with too many requests (not that this site has a lot of requests, but still). So the PHP script basically copies the feeds as two XML files on my server - wotd.xml (as in Word of The Day) and mdj.xml (Mot du Jour).
    Steps in JavaScript! When you load the forum's index page nothing special happens. When you click though, an HTTP request is performed, the requested XML file is retrieved, parsed, and the contents we want - displayed. Pretty easy thing to do, using the same JS function for making requests, described in the article.