Archive of articles classified as' "Other"

Back home

Wow I’m behind…

7/07/2013

Occurs to me I have not posted anything here in a while now.  Been busy beyond words both at home and at work.  Let me see what might be interesting to share.  Stand by…

No Comments

Follow up to Make your own Macbook Docking Station thingy

11/09/2012

Cole Flourney has proposed a great little project on Quirky.com to build an aesthetically pleasing, integrated docking cable adapter, much like the W1PPS solution that failed at Kickstarter.  Please check it out and vote for the project!

The easy, simple and beautiful docking solution for Macbooks:

Visit The Project Page: http://www.quirky.com/ideations/297651

No Comments

Make your own MacBook docking station slash adapter holder slash cable sorter thingy

24/08/2012

Problem:  New Macbook Pro, two offices, lots of peripherals/monitors/etc to plug in and disconnect at least twice a day.

I plug in four to five different items into my new MacBook Pro with Retina Display every morning when I get to work.  All of these get unplugged at the end of the day, or alternatively when I leave to go to my other office on the other side of campus, in which case I’m plugging/unplugging stuff four times in a day.

Aside from the tediousness of it, there’s also the issue of keeping the two display adapters in the proper order so my external displays aren’t swapped back and forth every time I plug in.

This is a pain to manage several times a day

This is a pain to manage several times a day

Potential solutions:

Henge Docks:  Their MBP w/Retina product isn’t out yet

Twelve South BookArc Pro: MBPr solution also not out yet, and though it includes a cable holder, it doesn’t give you a way to keep the cables in the proper port order.

Kickstarter W1PPS:  This looked cool but failed to get funded

Matrox DS-1 Thunderbolt Dock:  $250 and not out yet. Also only handles one display (only one Thunderbolt out), so I’m still going to have at least 3 cables (Magsafe, 2 TBs).

Belkin Thunderbolt Express Dock: $400! and not out yet.  Also only handles one display (only one Thunderbolt out), so I’m still going to have at least 3 cables (Magsafe, 2 TBs).

Homemade solution: InstaMorph Moldable Plastic

IMG_0596

6oz container of Instamorph pellets

The instamorph pellets at room temperature

The instamorph pellets at room temperature

Check out the pictures below of the 0.1 version of my homemade dock thingy:

The dock thingy inserted into the MacBook Pro

The dock thingy inserted into the MacBook Pro

I have some gaps between the adapters I need to seal up, and the MagSafe slips out too easily, but otherwise this is a good version 0.1

I have some gaps between the adapters I need to seal up, and the MagSafe slips out too easily, but otherwise this is a good version 0.1

Yes, its hideous, but it took a total of 5 minutes of work.  Turns out the hot water outlet on the office coffeemaker is the exact right temperature needed to soften the pellets.  Just pour the pellets into a ceramic cup (don’t use paper or styrofoam unless you want the plastic to stick to the cup), then fill the cup with hot water.  Once the pellets turn clear, they are ready to be formed.   Poor the water out of the mug and then extract your mass of plastic.

I “cooked” too much plastic (about half the 6oz container) so I broke the glob in half and put the rest back in the bottle.  I rolled the remaining part out with my hands like you would have in elementary school when making a snake with art clay.  Then I wrapped it around the cables, being sure to press down around each adapter end and especially in between them.  After that’s done, you let it cool until the product turns white again.  If you mess up, just re-heat the product and start all over again.

This only took about 1/4 of the 6oz container, so I have plenty of pellets left to make one for my other office and will still have 3oz of Instamorph to piddle around with.

12 Comments

Reports of the web’s demise have been greatly exaggerated…

1/05/2012

The Financial Times just announced they are pulling their iOS app and will focus exclusively on their HTML5 web app for delivering content to mobile devices. This is cause for mild celebration for Web Developers such as myself.

I briefly toyed with iOS app development a couple of years ago (back when you still didnt need to advertise your app to get noticed in the App Store).  Having no formal training, and coming from a scripting language context, trying to learn Objective-C and at the same time understand “desktop” or “client” based programming paradigms was just too much.  I made the decision that professionally it was a better use of my time to become a better Web Developer than to try to strike gold with an iPhone app.

Turns out that was the right decision for me, but I have often wondered since exactly what the future of the traditional browser-served web?  Facebook recently announced that 51% of their traffic is from mobile devices.  And it seems like everybody with a website of any consequence has released a native app for mobile.

I’ve used some of these apps. You have too.  Typically its some news outfit that just had to have an app.  Nevermind it is just serving up a UIwebView window with their mobile site embedded in it.  These companies are still banking on being “found” in the App space.

But I’ve found myself actually NOT using these apps.  I delete them, and I simply bookmark their sites in mobile Safari.  Its just easier. And it leads me to this rather obvious conclusion:  NOT EVERYTHING HAS TO BE AN APP.  NOT EVERYTHING IS IMPROVED BY BEING “NATIVE.”

Apps should do something more than just provide content for reading.  I use this distinction all the time at work.  When educating new audiences about our web apps, I refer to a web application as a “web site that does something”.  Maybe web sites don’t need apps, period.  Its redundant and causes extra work on developers to support multiple platforms.

So, FT’s news today just brightened my day a bit. We’re getting more and more mobile-centric, though I assume that will peak some day in the near future.  However, there still is and probably always will be a significant (even if not dominant) role for the browser based web experience (particularly in enterprise).  To take it further, some web apps are simply to complicated to offer a full feature set in the mobile space, web or native.  That doesn’t mean you don’t bother with mobile, but it means that maybe all this “mobile first” stuff isn’t a universal constant.

To get more specific, PHP will continue to have a role to play in the “front end” web, and won’t just be relegated to a server side way to respond to requests for content content from native apps.

UPDATE: I noticed Victor Agreda, Jr. agrees in his closing paragraphs today on TUAW that we need more web apps and fewer native apps out there.

No Comments

Refactoring to Zend Framework

30/04/2012

Over the course of several weeks, I recently took an existing web app I had started from scratch 5 years ago and refactored it into a full stack Zend Framework application.  This involved several steps essentially to organize the code in a similar fashion to ZF’s project layout, then incorporating certain components, and then finally finishing it off.

The application was simply too complicated to convert in one fell swoop or to start a new ZF project and then go feature-by-feature rebuilding.  I was already using components from the ZF library for a lot of things (DB, cache, registry, etc.) so the refactor really consisted of converting from my series of root level page-controllers to ZF’s front-controller pattern.

I’ll share the code below for the most useful step in the conversion:   Using PEAR class naming convention, I was able to create controllers using the Application_Controllers_Name naming convention.  These controllers then extended Zend_Controller_Abstract (actually I created a custom abstract controller of my own that extended ZF’s).  This gets you most of the functionality of the framework while not having to convert all the way over to the full ZF stack.

To finish this intermediate step off, you need a way to route requests to the proper controller.  I wasn’t ready to implement the ZF front controller pattern, which would have required a bootstrap file that extends Zend_Application_Bootstrap and ends up calling the dispatcher and router…. too complicated for my code at this intermediate stage.

So I wrote the following index.php file that handles the routing itself.  You’ll need your own custom bootstrap file.

/**
 * Self-Routing Front Controller for partial ZF implementation
 *
 * @author      Chris Renner
 * @link        http://www.chrisrenner.com
 */
 
define('APPLICATION_ENV', 'production');
 
/**
 * Define path to root dir (i.e. location of index.php)
 */
define("ROOT_PATH", realpath(dirname(__FILE__)));
 
/*
 * Define path to application directory
 */
defined('APPLICATION_PATH')
    || define('APPLICATION_PATH', ROOT_PATH . '/Application');
 
/**
 * Define root directory and application directory
 */
define("DOCUMENT_ROOT", $_SERVER['DOCUMENT_ROOT']);
define("RAW_PATH", str_replace(realpath($_SERVER['DOCUMENT_ROOT']), '', ROOT_PATH));
define("APP_PATH", str_replace('\\', '/', RAW_PATH)); // have to switch the backslashes to forward slashes to not break on windows
 
/**
 * Set include paths for classes, etc.
 * Entries represent all paths that application can look for files such as classes, template files, includes files
 */
set_include_path(get_include_path . PATH_SEPARATOR . realpath(ROOT_PATH . '/library/') . PATH_SEPARATOR . realpath(ROOT_PATH));
 
/**
 * Get bootstrap instance and execute
 * sets up config, app settings, db connections
 */
require_once 'Application/Bootstrap.php';
$bootstrap = Bootstrap::getInstance(APPLICATION_ENV);
$bootstrap->run();
 
/**
 * set defaults
 */
$controllerName = 'Index';
$actionName     = 'index';  // if no action supplied, will default to indexAction
$moduleName     = null;
$moduleStr      = null;
 
if(!empty($_REQUEST['controller'])) {
    $controllerName = $_REQUEST['controller'];
}
 
if(!empty($_REQUEST['action'])) {
    $actionName = $_REQUEST['action'];
}
 
if(!empty($_REQUEST['module'])) {
    $moduleName = $_REQUEST['module'];
    $moduleStr = 'Modules_' . $moduleName . '_';
}
 
$controllerClass = 'Application_' . $moduleStr . 'Controller_' . $controllerName;
$actionMethod = $actionName . 'Action';
 
/**
 * Instantiate default request object if none provided
 */
$request = new Zend_Controller_Request_Http();
$request->setActionName($actionName);
$request->setControllerName($controllerName);
 
if($moduleName) {
    $request->setModuleName($moduleName);
}
 
/**
 * Instantiate default response object if none provided
 */
$response = new Zend_Controller_Response_Http();
 
/**
 * Instantiate new instance of the controller
 * which extends Zend_Controller_Action
 */
if(!class_exists($controllerClass)) {
    throw new Exception("Controller $controllerClass does not exist");
}
 
$obj = new $controllerClass($request, $response, $_REQUEST);
 
/**
 * Execute the requested action, pass in the $_REQUEST
 */
try {
    $obj->$actionMethod();
} catch(Exception $e) {
    $bootstrap->handleException($e, $request, $response, $_REQUEST);
}
 
/**
 * Print response if not null
 */
if($response) {
    echo $response;
}

This is not drop-in-ready code, it is shared to give you an idea of how to route your controllers outside of the full ZF stack. This code creates the request and response objects and passes them into the applicable controller Index controller is called if no controller is specified.

Be sure to add “Application_” to your autoloader scheme so that when the code constructs the class name, it can find it in your include path.

Also I need to note, this code doesn’t take into account pretty URLs, so you’ll have to re-jigger this to your own needs if you’re using .htaccess to re-route requests. The above code works with index.php?controller=Foo&action=Bar urls. In fact, my application, being an enterprise web app for one, and also being on a server that doesn’t permit URL rewriting, retained the ugly url syntax, and fortunately for me I found a ZF router for just such scenarios on Rob Allen’s blog from a long time ago. You DON’T need Rob’s router for my intermediate code, but if you’re not going to convert to pretty URLs then you will.

This code helped me get my application to a point where I could do the final conversion to ZF relatively painlessly. Good luck.

No Comments

Dear Oracle

29/03/2012

Been a while since I posted.  I’ve been extremely busy.

One of the things occupying my time lately has been a marked increase in the need to interact with Oracle databases.

DISCLAIMER:  this is a rant and I didn’t stop to research, so I cannot guarantee there are no false assertions below.

Coming from MySQL, I find Oracle infuriating for several reasons.

1. Sequences:  Why are sequences such a giant pain?  Why can’t I generate sequences on the fly when I designate primary keys?  Why does this not work in any way like Autoincrement in MySQL?  Get started on that ASAP please!

2.  Why is it so hard to make changes?  OK, so I picked the wrong data type for a column, so I need to change it, right? Not so fast.  If you already have data in that column for any row, you get an error when trying to change it.  Drop the column? Again, better hope the col is empty.  I get that Oracle is trying to enforce data integrity, but this behavior crosses over into frustration.

3. Limit clause (or lack thereof).  Why does the BEST relational product not have a limit clause? This makes pagination queries a giant hot mess, and it wastes resources when you know you’re just looking for one row.  This seems like a no-brainer.  Tell me where I’m wrong.

Is Oracle the best choice for enterprise-class relational data storage? Yes!  Does that lessen to any degree the amount of frustration one has trying to develop for the web with Oracle ? No!

No Comments

OMG, PHP is Losing to Ruby, Python?

1/03/2011

Sorry for the hyperbolic headline, that’s just to get your attention. Now that I have you here, lets have a serious discussion.

The TIOBE Index was just updated with the February programming language rankings, and the PHP community seems to be a mild panic about dropping two spots in the rankings (from 3rd to 5th) and now falling behind Python (4th) on the list. The Python and Ruby camps are pretty happy with their results, and many seem vindicated as the results seem to have only amplified the PHP bashing out there.

Being the contrarian that I am, I could not just take the TIOBE results at face value.  Sure it shows PHP search traffic decreasing relative to the other terms, but what are we actually measuring here.

Are we measuring the installed base? Are we measuring the number of programmers/users?  Are we measuring the number of applications?  The answers are no, no and no.  TIOBE measures search engine traffic, period.  TIOBE’s methodology is limited to the volume of searches for $language . “programming”.  For example, they would have pulled search volume for “Java programming”, “PHP programming”, “Ruby programming” and so on.

To be sure, this approach is consistent across the languages, but there’s a significant amount of measurement error here if our goal is to determine the popularity of each language.

I went to Google Trends to look at search results of PHP against Ruby and Python, and yes indeed there is an alarming drop in PHP search volume going back to 2004 (see below).  However, the Ruby and Python search volume is by comparison nearly off the chart scale except for the blips in the last few months for Ruby.  We’ll have to wait and see if the Ruby spike is a trend or an anomoly, but looking at the historical data we can say the observable trend is zero growth in Ruby or PHP “popularity” as measured by TIOBE’s methodology.

Google Trends_ php, python, ruby

Search volume for PHP, Python and Ruby Since 2004

This observation doesn’t change the alarming drop in PHP search volume, but what good is this metric in a vacuum?  The following chart shows search volume for Java, C++ and PHP respectively.  Notice a trend?

Google Trends_ java, php, c++

Search volume for Java, C++ and PHP since 2004

All three of these languages are experiencing significant drops in search volume since 2004 (that’s as far back as Google Trends goes).  In fact, Java’s decline looks to be twice as bad as PHP’s.  Where are the Java developers jumping out of windows?  Does this mean each of these languages is fatally flawed and on its way out to be replaced by up and comers like Ruby and Python.  Of course not.  There’s a correlation among the drops in these three languages, and I would hypothesize that there’s an external variable that is depressing search volume here.  The alternative explanation is that Java, C++ and PHP are each, by coincidence, experiencing major drops in popularity.  I think that’s a far less likely possibility.

I would also wager that in the case of PHP, the proliferation of frameworks mean fewer people are searching Google for “PHP.” Instead, we are all busy searching for “Cake PHP”, “Symfony” or “Zend Framework”.  Google Trends shows fairly low search volume for these three terms, so this is not an answer, but it could be a small contributing factor.

The real question is what’s going on with search in general?  Is overall search traffic down this much?  Surely not.  Are people getting their programming language knowledge in other ways?

Ultimately I am reassured as a PHP developer that although something is going on out there, its not hitting just us.  Further, PHP is still in the top 5 on the TIOBE index, and its pretty rare company up there with three of the five being older, more established “enterprise” scale/desktop languages.  We’ll have to watch the TIOBE index over the next few months to see if the Python spike is a trend or a blip, so I’m not going to spend a lot of time worrying about it right now.

As technology professionals we can’t be afraid of change, so if there is a death knell sounding for PHP, we have to be able to accept it and move on. Having said that, there’s no bell tolling yet… I just don’t see it.  PHP’s only recently begun to see serious enterprise adoption, and the trend is accelerating, not decelerating.  Even if PHP wasn’t cool anymore it would be a decade before all this enterprise adoption was undone in favor of other platforms.

I’m all ears if you have any explanations, and please try to back up with data if you can find it.

Update: Kevin Schroeder has now weighed in on this as well.

12 Comments

Looking forward to PHP Community Conference

18/01/2011

Eagerly anticipating event details for the 1st PHP Community Conference. A little background is available on Ben Ramsey’s blog.

Best of all, its local for me :D

No Comments

In Development (and life) we should learn to embrace failures…

3/11/2010

i’m enjoying my time at ZendCon 2010. I spent all day Monday in Christian Wenz’s PHP Certification Bootcamp. This was an extensive overview on the kinds of questions that appear on the PHP 5.3 certification exam as well as some exam strategies and “gotchas” to look out for. My exam was was scheduled for Tuesday night, and as the Bootcamp wore on I became more aware of my knowledge limitations as a PHP developer.

So Tuesday evening came and I went to take the Exam. After the Bootcamp, which was 5.3 focused, I would have liked to switch my exam from PHP 5 to the 5.3 test, but the exam proctor informed me this was locked in from my prior-indicated preference.

To make a long story short, I FAILED. A bit insecure at first, I spent the night processing this now fact and woke up with a healthy perspective.

I remember a Nike ad from 1998 with Michael Jordan where he stated all the shots he’s missed in his career, including how many game winners he missed, and he simply said at the end “Failure is how I succeed.”

In development as well as life in general, it is important to understand our limitations, our weaknesses, and our opportunities for growth and improvement. If never tested, we can never grow. Fear of failure is simply a fear of growth and improvement.

Other thoughts on this is that being a PHP developer is not my life, its a part of my life. I’ve been doing this stuff for four years and I had a life before PHP and a life after. I still think the ZCE is important for the community as it lends legitimacy, and it is still a personal goal of mine, but it does help me to remember that faith and family are bigger pieces of my life in a absolute sense, and my professional life is really an expression of my larger self and not the other way around.

I now understand where my weaknesses in PHP are, and therefore where to focus going forward. What failure has provided in this case is information I can now act on.

Anyway, its not typical for me to dump my soul on this blog or anywhere on the interweb, but I figured I’m probably not the only one here at ZendCon that failed the test and therefore probably also not the only one processing the outcome.

Chris

1 Comment

Learning PHP

13/09/2010

Its quite possible you found this blog while googling around for information on PHP.  If that’s true, and you’re a newbie trying to learn PHP, I’d like to direct you over to a new post on Six Revisions entitled Learn PHP: Get Started Using PHP by Elias Zerrouq. After a brief history of the language, the article goes on to describe what PHP is, how it works, and the basic steps one must take to begin working with PHP, including installing and/or setting up a development environment, picking a source code editor, and writing your first few lines of code.

No Comments