Chris Page Joins New Venture – Lockerz LLC

Jul 22
2009
Night shot of Pittsburgh, PA - our new home city!

Night shot of Pittsburgh, PA - our new home city!

I’ve been quite busy lately!  Amber and I decided to leave Morgantown, WV to pursue better opportunities wherever we may fall.  We bunked up with family for a few weeks… a grueling thing with a 2 month old.  Thankfully, it didn’t take too long to stumble upon the next big thing!  Spending so much time increasing my online presence has paid off – as I received a call a few weeks ago from Lockerz CTO, Peter Meulbroek.

Peter and I exchanged a few phone calls – I could tell there was something “right” about the vibe I gained.  Three weeks later I drove into Pittsburgh for a lengthy yet fun and relaxing 5 stage interview – their idea is spectacular and the team was very talented and cool with a work hard and play harder mentality, perfect.  I realized “I’m going to make this happen”.  Thankfully the team at Lockerz shared that realization, and I’m very proud to announce that as of July 27th 2009, I will begin my first day as a ground floor Lockerz technical team member!

This proves it… I’m a startup junkie!

Things are moving very quickly, with only a week to relocate, and it reminds me of one of Amber’s favorite sayings:  “Good things take time, Great things happen all at once.” – this seems to hold true for me, a man of extremes to say the least!

Everybody involved in the process made it feel absolutely “right”.  I’m super psyched about the challenging workload ahead, and Amber and I both have never been so happy with the direction life is taking us!

Go check out Lockerz.com!

<a href=

Upgrading from PHP 5.2 to 5.3 in Ubuntu – Part 1

Jul 05
2009

( I’m publishing this partially done so that it acts as a reminder for me to FINISH it… bare with me! )

Overview of Important Changes

variable class naming

Previously in PHP, only method and function names could be variables.  Ie:

$func = "print";
$func("Hello World");
class Foo {
  public static function Bar()
  {
     echo "Hello World";
  }
}

$method = "Bar";
Foo::$method();

Now, in PHP 5.3+, variable class naming is also supported – making possible this syntax:

class Foo {
  public static function Bar()
  {
     echo "Hello World";
  }
}

$class = "Foo";
$method = "Bar";
$class::$method

This new class variable naming should provide a much desired level of ambiguity for PHP developers, I know for my MVC framework, it could really change the Typhoon PHP Typhoon->run() method in a positive way.

late static binding

This is a more advance PHP OOP topic – that almost came off as a bug in previous versions of PHP. I’ve personally ran into it myself on occasion, and am happy to see a solution available in PHP 5.3. In previous versions of PHP, static calls resolved to the inherited class. In cases where one needed a static call to resolve in it’s own scope, unexpected results were common. Ie:

class Foo {
    public static function who() {
        echo __CLASS__;
    }
    public static function test() {
        self::who();
    }
}

class Bar extends Foo {
    public static function who() {
         echo __CLASS__;
    }
}

Bar::test();

Output:

Foo

The solution, “Late Static Bindings”, solves this using the static keyword:

class Foo {
    public static function who() {
        echo __CLASS__;
    }
    public static function test() {
        static::who();
    }
}

class Bar extends Foo {
    public static function who() {
         echo __CLASS__;
    }
}

Bar::test();

The static keyword resolves to the calling class and produces the expected output:

Bar

Additions to Standard PHP Library (SPL)

Circular Garbage Collection

Lambda Functions (Anonymous Functions)

Closures

Overriding Internal Functions

New Reserved Words

Namespaces

Jump Labels

Changes to Functions and Methods

Extensions

Phar

php.ini Changes

Deprecated Methods

Install php 5.3 on Ubuntu

mkdir download && cd download
wget http://snaps.php.net/php5.3-200906131830.tar.gz

Ubuntu + Compiz

Jun 12
2009

This is actually from awhile ago ( almost a year ), but I thought I’d share. It’s my desktop pc, running Ubuntu 8.04 and Compiz Fusion engine.

To be honest, it was a fun exploration for the novelty, but these days, the most I really use from the effects engine is the magnifier to help people standing over my shoulder focus on whatever I’m demonstrating.

Pretty cool none the less! Read up at Compiz Fusion and Ubuntu

Setup a webcam security system with Ubuntu Linux and Motion

May 17
2009
Snap from Office Security Cam

Snap from Office Security Cam

So, now that I’m in Morgantown – my home is too small to comfortably work on side gigs and personal projects – especially now that my family is getting bigger with the baby!  I’ve been using the office space I leased out more and more.  While exploring video conferencing with Matt last week, I had the thought “wouldn’t it be cool to have a security camera in the office?”.  So I did just that, and it’s actually quite easy for Ubuntu linux users.

What you need:
  • Ubuntu Linux ( I was using 8.04.1 at the time of installation )
  • one or more USB web cameras
What you can do:
  • Motion detection – record video/and or frames if there is motion.
  • Snapshot intervals – take time interval snapshots regardless of motion detection.
  • Live video IP stream in mjpeg format.
  • Specify recorded video to be saved in your choice mpeg, avi, flv, swf format.
  • When motion exists, have frames and videos draw a box around the specific motion for more obvious recognition of subtle movements ( this actually shows the shadow of the janitor near the door around 6 a.m. every morning – I wouldn’t have noticed otherwise! )
  • Easily send all data to a backup server in a variety of ways – I keep it simple by saving data to my Dropbox directory, a wonderful cross-platform data syncronization and sharing utility.
Steps:

1.  Plugin your webcam.
For me, the Logitech QuickCam® Pro 9000 worked right out of the box, and was only 105$.

2.  Install Motion – software motion detector, and turn it on.

sudo apt-get install motion
sudo motion

3. Configure Motion

Everything really works out of the box with this – but isn’t quite organized to my liking, and probably not yours either. Global configuration is located inside /etc/motion.conf ( You’ll notice there are multiple threadN.conf files in this directory – which can be used for custom configured individual cameras if you are setting up more than one ).

Note: Be sure to restart the Motion server everytime you make a configuration change.

sudo /etc/init.d/motion restart

Take a look at the files, they are well documented. Below are a few helpful configurations to get your data organized quicker:

#/etc/motion/motion.conf

# Locate and draw a box around the moving object.
locate on

# Draws the timestamp using same options as C function strftime(3)
text_right %Y-%m-%dn%T-%q

# Text is placed in lower left corner
text_left SECURITY CAMERA %t - Office

Organize the filesytem to save data by date, instead of all in one directory.

# File path for snapshots (jpeg or ppm) relative to target_dir
snapshot_filename %Y%m%d/camera-%t/snapshots/hour-%H/camera-%t-%v-%Y%m%d%H%M%S-snapshot

# File path for motion triggered images (jpeg or ppm) relative to target_dir
jpeg_filename %Y%m%d/camera-%t/motions/hour-%H/camera-%t-%v-%Y%m%d%H%M%S-%q-motion

# File path for motion triggered ffmpeg films (mpeg) relative to target_dir
movie_filename %Y%m%d/camera-%t/movies/hour-%H/camera-%t-%v-%Y%m%d%H%M%S-movie

# File path for timelapse mpegs relative to target_dir
timelapse_filename %Y%m%d/camera-%t/timelapses/hour-%H/camera-%t-%Y%m%d-timelapse

4.  (Optional)  Setup a backup solution

a. Easy solution, get and install Dropbox — instructions on the Dropbox site.  Then update your motion.conf to save to your Dropbox directory:

#/etc/motion/motion.conf
...
target_dir /path/to/dropbox/security_camera
...

b. A more granular solution is to take advantage of hooks configurable in motion.conf. Using these, you can create bash scripts to do anything your heart desires ( like trigger a silent alarm on motion detection outside business hours ). Available hooks: on_event_start, on_event_end, on_picture_save, on_motion_detected, on_movie_start, on_movie_end.

If you have wput installed, you can easily upload files to a remote backup server with these hooks:

#motion.conf
...
on_picture_save wput ftp://user@pass@server %f
...

However, this solution is somewhat less secure, as it uses FTP. In a future post I will detail how to secure this up using encrypted transfer and phrase free keys. ( Stay tuned! )

5. Live feed

This comes working out of the box with Motion. Check out your live stream in your web browser by navigating to: http://localhost:8081

That’s it! Webcam security made easy :-)

Choosing the best platform for the job: CMS Solution, PHP MVC, Django, or Ruby on Rails

May 14
2009

I see this all the time:  “I’m building a website, but I don’t know what the best technology to use is?  This guy says PHP,  that guy says Ruby.  What’s better?”.  While there are definitely a handful of developers that will quickly jump to share my point, there are far too many that have biases for certain technologies and will quickly defend them with a bullet list.  Avoid those guys with biases – their tool belts are smaller.

Some things to Consider

Choosing the best technology really depends on what it has to do.  You wouldn’t hit a screw with a hammer?  Well, you can… but you shouldn’t.  Choose your website technologies based on what it has to do and what it takes to create and support it.  Some things to consider:

  • Budget and Market Cost
  • Continued Support and Development
  • Scalability – meaning, when new problems arise, will the solution be able to meet and defeat those problems?
  • Demographics – how well does the workforce powering your technology cater to your product’s needs?

Simple Sites

Say, perhaps, you want to build a small website to advertise a product or yourself.  It needs a few dynamic options, like a contact form, and maybe a shopping cart. I highly recommend exhausting service oriented solutions before going custom.

You could quickly find a web developer, blow a few hundred bucks, spend several weeks customizing and tweaking, and there you have it – no real support, you may or may not have a scalable back-end to manage it, and future expansions become expensive.  Or…

You could throw up a wordpress.com site for your landing page, link it to an inexpensive shopping cart service like e-junkie.com, and have significantly more bang for FREE by gaining access to thousands of plug-n-play plug-ins to extend your site with gallery applications, feeds, sharing tools, SEO management tools, as well as all the support of a service like e-junkie on call for your every e-commerce need.

See where I’m going with this?

More Complex Project

Lets envision you need something more complex than a personal page.  How about, a niche social network?  You want your own version of Myspace, and white label solutions just don’t have what it takes.  So you’ve raised thousands of dollars in angel investment, got your business plan, and are perplexed by the question of this post, “What technology?!?!”.  In this case, I would suggest considering the labor force and scalability behind each technology in correlation to what that is going to mean for your budget.

PHP Frameworks

While PHP has a huge work force, and many success stories, the language itself is rather controversial, as are philosophical differences in it’s “thousands” of frameworks.   A handful of frameworks are well-known, such as Symfony, CakePHP, Zend, CodeIgniter, KohanaPHP; though being an expert level PHP developer, I can tell you that many of the PHP frameworks, well, quite frankly, suck.  It’s new and easy to learn, and bloated with newbies making decent money, but not deploying consistent theory or solid code.  This is not always their fault, PHP lacks as a new language.

PHP also brings a lack of legacy support with each new version.  Consider the lifespan and size of your project.  Does this site need to run code for several years?  How difficult might it be to migrate old code to new versions of the language as they are released?  Just an example:  When  PHP5 released, it left thousands of web hosts outdated and incapable of updating without major financial and time expense due to the fact that PHP5 had changed syntax to introduce OOP, which broke PHP4.  To simply upgrade to PHP5 would break millions of websites without those webmasters first learning the changes in the language and making updates to their scripts.  Such scenario meant serious problems for web hosts that wanted to support latest technologies for new clients while maintaining legacy technology for existing clients.  PHP6 bodes better, but will still admittedly face similar problems.

As for the workforce, it’s just too easy to get into PHP.  The skill level required to create a PHP site is significantly less than that of other languages.  It’s the nature of PHP – Hypertext Pre-Processor, which, to many, is code (pun intended) for HTML on steroids.  Your average MySpace fanatic knows a bit of HTML these days, PHP is just the next informal step for many.  If you can find a skilled Object Oriented Programmer (OOP) – you’re well off, but the work force powering PHP is predominately less read into computer science theory and less likely to deploy best practices.  Why should they? – that’s all part of the beauty of the language.

Not to say a quality website can’t be developed in PHP, but I haven’t worked with any particular PHP Framework that really nailed it for me as a perfectionist.  You’ll find many like me in the PHP work force:  “just another php framework author”.  There seems to be an abundant number of us that find it difficult to produce quality code in popular frameworks, causing us to resort to building our own.  Mine is coined Typhoon.

Though, don’t get me wrong, I LOVE PHP and have developed numerous websites in the language.  I also look forward to the great new benefits in Version 6.  When you come down to picking PHP for your choice as a platform tool, just be sure the scope of your project is small to medium sized, speed of development being important, and ongoing support of the project being minimal.  Past that, the coding standards recognized by the PHP community are just too flexible and inconsistent for me to feel comfortable  spending significant time and expense on a bigger PHP site.

Django

“Developed four years ago by a fast-moving online-news operation, Django was designed to handle two challenges: the intensive deadlines of a newsroom and the stringent requirements of the experienced Web developers who wrote it. It lets you build high-performing, elegant Web applications quickly.” – from the creators of the Django Project

Now Django is a cool framework built in the Python language, and perhaps the premier web framework of Python. Unlike PHP, Python is a general utility language. It’s usage can be found in many aspects of computer science from desktop applications, to video games, to web development – and it has been around awhile.

Lets keep in mind the quote above though.  It was developed by-and-for the newsroom.  As such, it caters VERY well to companies that have a similar infrastructure.  While you can develop many applications regardless, that fundamental purpose gives the framework an overall flavor that may not be quite as flexible in every problem domain.

The built in content management system (CMS) feature of Django is really quite a gem.  It’s effective at allowing developers to rapidly generate applications for non-technical people to manage.  Would I use it for a social network?  Probably not as my first pick.  Would I use it for news syndication site?  Hell yes.

Python has been around since the early 90′s and has had sufficient time to incorporate advanced computer science theory and stabilize.   The workforce powering Django applications is also significantly more well-read than the PHP workforce ( I say this loosely, of course ), as the Pythoon workforce has been around longer in general.

Django can sleep safe at night knowing it was built on a stable language that doesn’t anticipate significant change year after year, making it a great platform for websites requiring long term support and development.

Ruby on Rails ( Soon to merge with MERB in Rails 3 )

Talk about some BUZZ!  I’ll admit I did not want to learn Ruby on Rails at first.  I love learning technology, but when Rails was just gaining it’s hype, I was getting deep into PHP and tended to stay in the PHP world.  Mistake at the time, on my part.

Rails identifies itself as a “web framework”.  Unlike Django, Ruby on Rails was developed to tackle many more of the standard problems developers face on a much broader sense of web development.  This by itself should not be translated as “Rails is the creme de la creme” for your web project, but it does make it a strong candidate to initially consider.

When to Consider Rails

  • You have a project with many developers, possibly several contractors that will come and go as needed.
  • You need fast scalability and flexibility due to a multi-faceted problem domain, ie:  niche social networks tend to start simple and then tack on lots of complex features.

Some Pros

In terms of computer science, 9.9999 times out of 10, problems we face in development are problems we’ve answered time and time again, either in theory or practice.  Thankfully, the Rails community innately conforms to the DRY Principle ( don’t-repeat-yourself ).  The community also drastically alleviates extra invention faced by developers, simply by embracing, building upon, and reinforcing community accepted solutions.  The now famous Rails motto:  “Convention over Configuration” sets a tone where the community expects eachother to follow a standard set of approaches versus relying on the individual’s limited resources to reach the same conclusions others have already reached.

Not only is it a motto, it’s an obstacle for “do-it-my-way” programmers, as it’s rather difficult to make a Rails application without doing it the “Rails way” – things will just not go smoothly if you attempt to break standards.  As developers tend to think differently about the same problem domain, Rails lends itself as a great framework to conform the result of their different approaches to the same represented solution.  In identifying conventions and standards, developers of the rails community spend significantly less time “re-inventing the wheel”, and more time knocking out features and drinking beer.

Some Cons

It’s memory intensive/innefficient.  MERB is merging with Rails 3 – which promises to improve performance, though in the meantime, I have several Rails applications running for small sites where I should have deployed PHP, I’m noticing I’m low on memory due to such, which ultimately costs me more money to keep my servers up to par with my Rails demands.

Windows users tend to have a more difficult time with Rails whereas the PHP community has gone through a few more lengths to make development in windows fairly painless.  Rails is significantly is better to develop on unix-based platforms, like Linux and Mac.  Windows users will need to go through extra hoops to keep up with dependencies largely created and maintained by the unix-based users – though, if you’re a serious web programmer using windows as your primary platform, you should consider weening off sooner than later anyways.

Rails isn’t THAT light weight.  It incorporates a lot of functionality and sub framework patterns that you just may never use on some projects.  Again, Rails 3 promises to improve in this area as well.

[Conclusion Pending]

Convert an XHTML form to a JSON object, then use jQuery’s AJAX methods to send the data to the backend

Jan 29
2009

I had a project at work that almost drove me insane tonight. When it comes to Javascript, forget what you know about other languages, and get in the mode of: “all objects are hashes”.

Case Scenario:

You have a form with lots of dynamically created input fields. Instead of a normal submit button post, you want to send the data to the backend using AJAX.

Problem:

After hours of Googling, you just can’t find information on dynamically populating a JSON object. You also want a clean and simple way to grab all that form data, put it in a JSON object, and then submit it with jQuery‘s wonderfully simple AJAX methods.

Example Solution:

XHTML from a dynamically generated form
I left some code out for simplicity, but just imagine it’s there. The inputs below are added dynamically, and can be infinite.

<form id="invite_users">
    <fieldset>
        <input name="users[0][name]" type="text">
        <input name="users[0][email]" type="text">
    </fieldset>
    <fieldset>
        <input name="users[1][name]" type="text">
        <input name="users[1][email]" type="text">
    </fieldset>
    <fieldset>
        <input name="users[1][name]" type="text">
        <input name="users[1][email]" type="text">
    </fieldset>

    <!-- ...etc...etc.. -->

    <a href="javascript:void(null)" id="#submit_form">Submit</a>
</form>

jQuery Goodness

Here is the sweet part. In this example, we just iterate through all the input fields dynamically, and place them in a JSON object — which is what jQuery’s ajax method uses to send the data back to the server.

$(document).ready(    function() {
    $("#submit_form").click(function() {
        var data = {}

        $("form#invite_users > fieldset > input").each(function() {
          data[$(this).attr("name")] = $(this).val();
        });

        $.post("post_form.php", data, function(returnData) {
          alert("Thank You!");
        });
    });
});

Easy enough?

But wait!  There’s an even better way.  With the above example, we don’t account for complex element types passed in the request ( ie, radio boxes, check boxes, file inputs ).  Once again, jQuery simplifies things even further with serializeArray():

    $("#submit_form").click(function() {
        var data = $("form#invite_users").serializeArray();

        $.post("post_form.php", data, function(returnData) {
            alert("Thank You!");
        });
    });

Hope this helps others out there! Leave a comment on your thoughts!

Generate any HTML tag with these two functions.

Apr 05
2008

I was working on a form generation API on Typhoon PHP Framework today and came up with two wonderful functions for generating any HTML tag using PHP.

Here are the functions, enjoy!:

public static function tag($element, $attributes = array()) {   
    $buffer = '<' . $element;

    foreach($attributes as $key => $val) {
        $buffer .= ' ' . $key . '="' . $val . '"';
    }
    $buffer .= '/>';

    return $buffer;
}

public static function blocktag($element, $attributes = array()) {
    $content = $attributes['content'];
    unset($attributes['content']);

    $buffer = '<' . $element;
    foreach($attributes as $key => $val) {
        $buffer .= ' ' . $key . '="' . $val . '"';
    }
    $buffer .= '>';

    $buffer .= $content;
    $buffer .= '</' . $element . '>';

    return $buffer;
}

Currently I use these in conjunction with Smarty helpers to create consistent markup across a project I’m working on. Any thoughts are appreciated!

Visit Other Sites!

Find me on other sites...

Archives

All entries, chronologically...

Pages List

General info about this site...