Updates and ::’s

In my previous article (Microsoft Access and PHP), I discussed getting mdbtools setup and dynamically interacting with a instance of mdb-sql. Well it turns out somewhere in the pipeline (probably mdb-tools), we're either not getting an EOF or reading an EOF right and as such I can read lines from the program's STDOUT stream, but as soon as I hit the end of the output my script hangs indefinitely waiting for something and all my attempts at detecting an EOF failed. Sorry to disappoint.

On lighter news, my coworker got the greatest error ever:

Parse error: syntax error, unexpected T_PAAMAYIM_NEKUDOTAYIM

Turns out according to these guys it's Hebrew and refers to the double colon (::) operator.

Right...

Microsoft Access and PHP

Microsoft products can really be a big wrench in the finely oiled machine that is your development environment. While Microsoft does offer some excellent products and development tools, when you work from an open source context, these great tools become great hazards and headaches.

Case in point, access databases. Take as a recent example, a client that gets its data from a third party. That data comes in a Access (.mdb) format, probably convenient for the producing company as well as the assumption that chances are very likely that the person receiving the data will be able to read it (due to the widespread availability of Microsoft Office).

Importing said .mdb in PHP is not so nice or convenient, that is if you aren't running your server on Windows (which chances are you aren't). In Windows you merely need to either create an ADO object (or use ADODB), or use COM to communicate with a local install of Microsoft Office to trigger an export. In Linux, neither of those choices are even available. However we thankfully have some good command line utilities, for example: MDB Tools. (Tip: Check out a copy from CVS if 0.5 is segfaulting on your database)

In addition to some unixODBC drivers, it provides some very nice command line utilities like mdb-tables (which prints the tables in a .mdb file), mdb-schema (which prints the schema for all or a specific table), mdb-export (which produces a CSV output of a specific table in the .mdb), and mdb-sql (which provides a subset of SQL interface to the .mdb file). All of these tools come together to form a very nice tool set to import a .mdb file.

Fun things however, as I was working on my import script (I was just using simple exec() commands and getting full output and parsing from there), I decided to play around with stream programming and provide an interface to mdb-sql using proc_open() to make the import less memory intensive. I ran into some snags using fgets() on the STDIN stream and when I solve those I'll post my code and a tutorial.

OO Design and PHP

I was helping a coworker the other day with some object oriented design issues in PHP and thought it would be great to share with the general PHP community as the general PHP community seems to lack in good OOP skills.

The task, which will be detailed later when we release it, boiled down to having a collection of files we needed to perform an operation on. Sometimes the entire collection, sometimes just a subgroup. Currently the system will only support 1 kind of file however in the very near future a new file will be added. My coworker tackled it well but a few problems that I helped him out with. Namely he made a few common mistakes in the design that most PHP developers make, namely being inconsistent with naming/etc. and not utilizing Interfaces and argument type-hinting to enforce good design, as well as putting logic in the wrong classes.

One of the few pitfalls that did happened was placing the render() function in the collection class. While this would not be a problem for a single type, when extending the system to handle n node types we come across unnecessary complexity issues in adding to the render() function, as well as making it nigh-impossible to keep the original includes intact (so as to make upgrades work without the hassle of merging code).

Continue reading ‘OO Design and PHP’ »

Lenovo Expanding ThinkPad Linux Offerings

Matt Kohut posted on the Lenovo corporate blogs a very good sign of industry Linux support.

According to Kohut, Lenovo will be expanding its Linux offerings not just by expanding their preloaded selection, but by porting the ThinkVantage software (their "Craplet but Not Craplet" driver/application suite) to Linux.

Normally all I see as far as far as industry Linux support goes is just installing Linux on a few machines, but not really expanding Linux itself (through drivers and software). I have high hopes (which will probably be dashed like they always are) for Lenovo's offerings as they intend to port their drivers and management software.

In a perfect world I would like to see open sourced applications centrally distributed by Lenovo for multiple distributions (they currently will only preload SLED). In a perfect world I see modularized drivers that would allow more savvy users to install a hard disk shock driver but write their own OS integrated interface, or a user would install Lenovo's interface.

I also see much potential for their port of their presentation mode software. Currently dual monitors in Linux is a bit of a bitch to deal with, and I can potentially see them develop an application that would be usable on other laptops for quickly setting the monitor out port to be an 800x600 desktop that Open Office or Totem would send their full screen output to. While from a business standpoint this is not so much of a smart move (a competitive advantage via exclusivity is lost), the Linux crowd tends to handsomely reward supportive companies that make moves like this with free press, referrals, and making their next purchase through these somewhat philosophically aligned companies. Given the Linux user is the guy 10+ people go to for hardware purchasing advice, the sheer scale of 100 techies telling 1000 people to buy Lenovo machines because of how impressed they are with their support of Linux can't hurt at all. One need only look at the gPC and how Walmart could not keep enough in stock.

Since the ThinkVantage software appears to be written in .NET 2.0 (the update utility requires .NET 2.0, so I think thats a reasonable assumption), maintaining ports should not be entirely difficult thanks to the inroads the Mono project has made. I would love to see care made to make native feeling ports of the software rather than just dumping the same interface their Windows counterparts use (e.g. splash screens are usually frowned upon in Linux software, especially with system utilities). Since SLED is now GNOME based, I'm really hoping that their team decided to go for GTK+ and sticking to Gnome HIG for their interface, however given that QT is more easily portable, I fear a nasty looking QT setup (Disclaimer: I dislike QT from a visual standpoint. It's a good toolkit but makes for an inconsistent, unpolished interface).

One fear I do have is seeing Lenovo attempting to reinvent the wheel with their suite. There are many things that Linux already does well that do not need yet another third party application attempting to perform from scratch. One in particular is the network-manager applet that installs with Gnome most of the time. I find it to be an extremely easy to use wireless and network configuration utility, especially when you expand it with VPN plugins.

However I can see Lenovo stretching itself too thing trying to do a 1:1 port of the ENTIRE suite when they are better off ensuring packages like network-manager and power-manager from the gnome desktop or their KDE equivalents are installed and focusing their time on missing features, like easy fingerprint setup (perhaps contributing to the gnome keyring manager by allowing it to authenticate through PAM, allowing for finger swipes to unlock the keyring), hard disk shock protection (completely lacking on this aspect), presentation manager, and setting up and providing quick interfaces to all the special keys and shortcut buttons (namely the ThinkVantage and forward/back buttons do not work out of box). The could also spend their time contributing wifi drivers (or contributing to existing drivers) to fix some issues like the wifi light not working, as well as working with the major distributions to eventually work in the fixes they create to allow Suspend to RAM and Suspend to Disk to operate without dying.

As a final request and hope, please make sure you not only provide binary packages, but APT/YUM repositories as well for keeping the applications up to date (the update software can easily be reduced in complexity by using built in package management software).

All and all, my hat is off to Lenovo for taking the extra step in their Linux support by (potentially) supporting the community, not just installing a distribution and calling it a day.

PHP Feeds, or, Get Your Read On!

I've started to amass a large amount of feeds in my reader and I thought I'd share a few with you:

PHPDeveloper.org (feed)

Great aggregation of blog posts and updates in the PHP world.

Zend Developer Zone (feed)

Zend's place for all things PHP related

SitePoint.com (blogs) (articles)

The infamous SitePoint. Not entirely PHP, but excellent web related articles and a good way to keep loose tabs on the other web spheres (ASP.NET and RoR in particular)

Particletree (feed)

Doesn't update very often, but each article is a gem (in terms of solving a programming problem).

Chris Shiflett (feed)

THE PHP and Web Application Security guy.

Joel on Software (feed)

A classic, not really PHP oriented.

And finally, definitely not PHP focused, but a very good blog to read if you do any MySQL work (if you are a PHP person, chances are this includes you)

MySQL Performance Blog (feed)

Great collection of articles and talks on optimizing MySQL, either at the server or query level, and more...

While this isn't all of the feeds I have on programming related topics, some of them are new adds and I want to give it some time before I share the links.

It’s HERE!

Holy crap my ThinkPad T61 got here FAST!

Lenovo informed me on Wednesday that my laptop was shipped, cool right? Shipped from Hong Kong. I had 2 day shipping so sweet, I get my laptop on Friday.

Nope, Thursday morning. At 10. A.M.

First thing I did of course was completely obliterate vista (I downgraded to Vista Home Basic to save $45 bucks since (a) I have a copy of XP Pro and (b) I can get a copy of Vista Ultimate through A&M if I so choose).

One snag is that XP hates AHCI mode for SATA (won't even see the disk at all), though when I get the Intel Matrix Storage Drivers installed I could turn it back on.

Sadly XP Pro doesn't have any drivers on a fresh install to do anything of value on the laptop, so a quick CD burned with the LAN and WiFi drivers along with the "ThinkVantage Update Center" software and .NET 2.0 redistributable gave me everything I needed to install ALL the drivers.

Seriously, Lenovo, I'm actually impressed with your "craplet" software. It gets the job done WELL (the update center is AWESOME for getting all my drivers setup). Granted it runs a ton of processes, but I haven't noticed any lag in my performance (though we'll see how my battery stands up).

One thing I must note thats interesting is after all the pictures I was expecting the 6 cell batter to stick out the back. I didn't like this so much, but I had come to terms with it and moved on. But, Lenovo's website LIES. My 6-cell doesn't stick out the back (unless its a 4-cell that's been mislabeled...). Weight is amazing, and its a lot smaller than I was expecting.

So far I couldn't be more impressed with this laptop, other than the off center screen.

Next step: ThinkWiki shall aid me in getting Ubuntu setup on this machine and purring like a small kitten.

Impatient (and other things)

I don't really have a particularly programming themed idea for a post today, however I'll have one up very soon (this weekend), discussing tackling web payments and using OOP to simplify. I have some code I've been meaning to post, though I think my PayPal object may not see the light of day (with about 20+ member variables, written for 4 without using __get and __set, I think I'll pass for the time being).

I'm rather impatient about waiting for my ThinkPad T61 "Unholy Powerful and Impossibly Indestructible" edition. The Lenovo website estimates a ship date of the 26th! I can't wait that long, I need my magnesium-alloy roll-caged crack now!

Oh well. In the mean time I've been entertaining myself with Lenovo's corporate blogs (in particular "Inside The Box"). I find it frightening that I make a quick humorous post with a man showing off the durability of the laptop (that I borrowed from Inside The Box), and one of the blog authors comments on that post.

I haven't exactly been advertising or pushing my name...

However after a quick investigation to Google, I can see one possible entry, however that doesn't seem likely as I'm not seeing anything like this through my analytics account. So that leave only 2 possible answers:

  1. He was looking for information on Plesk workarounds (that article tends to be popular).
  2. He is a terminator from the future hell bent on concludifying me.

I am inclined to believe that it is not #2 as there are very few "Daniel Cousineau"s in this world (especially in Texas), and that would turn out very poorly for me. You know, health and longevity wise.

Why I’m Buying a ThinkPad…

Playing Catchup On Quotes

I'm a sucker for good quotes, so without further ado, my favorite quotes to catch this blog up. In the future I'll post quotes that I find particularly good or inspirational.

They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.
Benjamin Franklin

I have never let my schooling interfere with my education.
Mark Twain

If we don't believe in freedom of expression for people we despise, we don't believe in it at all.
Noam Chomsky

Take away the right to say 'fuck' and you take away the right to say 'fuck the government.'
Lenny Bruce

Religion, to me, is a bureaucracy between man and God that I don’t need.
Bill Maher

All tyranny needs to gain a foothold is for people of good conscience to remain silent.
Thomas Jefferson

You can choose a ready guide in some celestial voice
If you choose not to decide you still have made a choice
You can choose from phantom fears and kindness that can kill
I will choose a path much clearer
I will choose free will
Rush

QBVII

So I've been on a pseudo Leon Uris binge lately (pseudo in that this is my third Uris since Christmas, depressing considdering I used to knock out 2 novels a week).

I absolutely adore his writing. It's historical fiction, always somehow rotating around the Jews and/or Israel (in the 40's). He likes to present two sides of a story, or more accurately, two characters at odds with each other. He spends the first part of the book detailing the lives and backgrounds of each character, each in a positive light, before dropping the characters on the proverbial battleground.

The character depth and development Uris has is quite amazing and rare in books these days.

I do however dislike how he ended "A God In Ruins." What was a good book became very rushed and extremely preachy at the end. While I respect his opinions, I have a distaste for authors that blatantly push their opinions on you. An author should be sublime with his indoctrinations, he should cause you to feel the emotion he feels and hopefully have you come to the same decision as he did. Sadly, all he did for the last hundred pages was all of a sudden push gun control like it was crack, despite the fact that the novel had no emotional construct for such decision (e.g. a beloved character killed by loose guns, etc.). I'd like to say it's my personal views on gun control that cause me to have this rift with the book, but sadly I cannot.

Otherwise he is an amazing author, "The Haj" was an amazing book, and I have to finish QBVII.