Clinton Paquin

Tech Blog

Want to get where you're going? Don't wait, start now! Clinton is rooted in PHP, MySQL, jQuery and web development standards. He is a rare bread of web development professional that focuses on back end and front end development; specializing in dynamic content such as internal pipeline (intranet) tools and user driven content. He has experience with performance optimization, scalablity, accessibly semantic code and utilizes PHP/MySQL server side technology complimented by non-obtrusive DOM manipulation with jQuery to make the magic happen.

Engineer-to-Engineer Recruiting

Published:

Engineers are tired of being spammed by recruiters and rarely respond to their emails. An email from the person you’d be working with is much more compelling.

http://blog.sourcing.io/

Rubberband - A jQuery plugin for adding responsive breakpoint events.

Published:

Ben Plum is sayin what I been thinkin, this is pretty sweet.  Credit to Brett Terpsta’s daily web excursion for the tipoff

Sometimes you need to know when a responsive page changes. Rubberband allows scripts to act on media query changes in real time by making use of the browser’s internal media query matching system, window.matchMedia.

http://www.benplum.com/projects/rubberband/

I am Clinton

Published:

As if you didn’t already know that the Simpson’s were awesome.  I had forgotten about this clip, but you should know by now that “I am Clinton”

http://www.youtube.com/watch?v=yJi3R1C22H8

Semantic Versioning 2.0.0

Published:

Everyone who does deployments should read this (and silently wonder to themselves why they didn’t read it sooner)

http://semver.org/

Instapaper: Ready for your testing: the new Instapaper web beta

Published:

instapaper:

When the betaworks team sat down with Instapaper’s creator, Marco Arment, back in April to get a download of his ideas and to-dos for improving Instapaper, the first thing on his list was to update the Instapaper website. Well we’ve done it, and it’s now ready for you to check out and test.

Had a chance to login and poke around a bit.  AWS, web fonts, Compass, and responsive design.  These guys are heading in the right direction and deserve kudos.

http://blog.instapaper.com/post/57817543037

Beanstalk: How we migrated Beanstalk to Rails 4 and Ruby 2

Published:

beanstalkapp:

In October 2011 the groundwork began to migrate Beanstalk to Rails 3, the latest version of Rails at the time. In a few weeks it became apparent that the migration would take much more effort than we originally anticipated and the work had been scrapped. Since then the idea to migrate to newer…

Long no doubt, but this is the kind of thing developers deal with all the time. Migrating legacy code ain’t no picnic

http://blog.beanstalkapp.com/post/56162575030/how-we-migrated-beanstalk-to-rails-4-and-ruby-2

Writing Testable JavaScript

Published:

I have an ifttt.com recipe to get updates from the A List Apart.  I’m a backend developer, and there is a lot of chatter over there from the design world that I filter out.  However, the other day they a great article titled “Writing Testable JavaScript" by Rebecca Murphey.

She starts the article off with the problem all frontend developers** have had:

We’ve all been there: that bit of JavaScript functionality that started out as just a handful of lines grows to a dozen, then two dozen, then more. Along the way, a function picks up a few more arguments; a conditional picks up a few more conditions. And then one day, the bug report comes in: something’s broken, and it’s up to us to untangle the mess.

Where she really hits it on the head is not in the solution, but with the problem:

we’ll have a very hard time writing unit tests until we start writing testable JavaScript

I concur, now I need do a better job at practicing it.

** I’ve never really considered myself a front end developer. My passion lays in PHP/MySQL and reusable MVC framework code.  However, the back side of the nickel is pretty boring if Lincoln isn’t on the front.

http://alistapart.com/article/writing-testable-javascript

5by5 | The Changelog #89: Doing incredible things with linux containers and Docker with Solomon Hykes

Published:

I’ve never had time to get deep into Linux containers, I’ve just used VirtualBox VM’s where I need them.  However, some guys I work with have lately been getting pretty heavy into Vagrant and Puppet*.   Overall, I see the value of Linux containers.  Having a precise environment anyone on your team can spin up is valuable.  Being able to deploy a simple binary is pretty awesome too.  I’m just not to the point yet where I’m ready to abandon good ol’ fashioned Homebrew on Mac OSX, Capistrano, and Github

* Here is a fun tutorial on getting started with Puppet and Vagrant

http://5by5.tv/changelog/89

Coming back

Published:

I left Tumblr almost a year ago, when they refused to offer extended RSS feeds. Mostly because I have a surf blog here with 5 years worth of content that I couldn’t get to. It pissed me off and I left. I also got tired if thinking I would write more tech tutorials to share. Truth is that I’d love to write more tech tutorials, but I like to surf and program more. Look for more stories on those two topics from here on out.

Give it five minutes

Published:

5 minutes really isn’t too long to wait when you’re frustrated.  If/when you feel your blood pressure start to rise just go grab a cup of coffee or do 20 jumping jacks.  

Jason Fried’s recent article hit home for me today, and I’ve been waiting for a good chance to talk about his well written article.   It’s easy to take a defensive stance on a subject, especially when you consider yourself to be an “expert” in the area.  When someone  challenges your stance, a true “expert” will take the opportunity to absorb the argument, digest the content, and formulate an intelligent response.  Snapping back with the first “you’re wrong” response you can think of not only makes you look like the bad guy, but it doesn’t provide you the opportunity to admit you’re wrong.  

Being wrong isn’t such a bad thing, and neither is taking five minutes to admit it!

http://37signals.com/svn/posts/3124-give-it-five-minutes

Montana State University satellite surpasses goal; NASA taps MSU to queue up for another launch

Published:

10 years ago I had the opportunity to work on the MEROPE project, the VERY first satellite designed, built, and tested in Montana.  Good to see that the project is still rolling and is actually very successful!  Here’s hoping they keep up many years of continued awesomeness.

http://www.montana.edu/cpa/news/nwview.php?article=10907

javascript - setTimeout with zero delay used often in web pages, why?

Published:

Do you need to do live polling on events for your site on a time interval?  For example, pull a new set of results from a twitter feed every 10 seconds.  If the call/calculation takes awhile to complete, your user might be left with the feeling that the action they performed (clicking a button) didn’t do anything.

The crux of the problem is that the browser places all its “TODO” tasks resulting from events into a single queue. And unfortunately, re-drawing the “Status” DIV with the new “Calculating…” value is a separate TODO which goes to the end of the queue!

So, to fix your problem, you modify your onClick handler to be TWO statements (in a new function or just a block within onClick):

  1. Populate the status “Calculating… may take ~3 minutes” into status DIV

  2. Execute setTimeout with 0 timeout which calls “LongCalc” function. LongCalc function is almost the same as last time but obviously doesn’t have “Calculating…” Status DIV update as first step, and instead starts the calculation right away.

I stumbled onto this link on stackoverflow.com, it gives a full breakdown on the problem, the solution, and why you would want to do this.  Read up, it’s a nugget of knowledge that can really save your bacon (and make you look like a much smarter developer than you really are)

http://stackoverflow.com/questions/4574940/settimeout-with-zero-delay-used-often-in-web-pages-why

WAMP reset phpMyAdmin password

Published:

Ever mess up your root user password for MySQL when working locally?  Well, hopefully you’re working locally and didn’t lose the pass to the production server, but just the same here are some steps for the MySQL password setup

  1. Install wamp server 
  2. Start->run->cmd-> 
  3. Type cd\ and press enter 
  4. Locate your mysql directory(like this is my default directory C:\wamp \bin\mysql\mysql5.1.36\bin) 
  5. After like this you should have do C:\wamp\bin\mysql\mysql5.1.36 \bin> mysql -u root -h 127.0.0.1 -P 3306 -p press enter after you got Enter Password don’t put anything simply click enter button 
  6. After like this mysql> 
  7. simply type mysql>use mysql; mysql>show tables; mysql>select * from user \G; 
  8. You can set your new password: mysql> UPDATE mysql.user SET Password=PASSWORD(‘xxxx’) WHERE User=’root’; (where replace ‘xxxx’ with your new password) (eg.mysql> UPDATE mysql.user SET Password=PASSWORD(‘muthu’) WHERE User=’root’;) 
  9. Finally type mysql> FLUSH PRIVILEGES; mysql>exit; 
  10. Check your settings: mysql> mysql -u root -p enter password:***** press enter button…..

Wordpress Custom Taxonomies

Published:

Custom Taxonomies in Wordpress have been around since release 3.0, special thanks to the gurus at Wordpress for this inovation because you can do some fun stuff with them.  Taxonomies are essentially an extension of Categories.  

Background and Basic Case Study

Let’s say you have a blog and you want to create some basic categories to assign to your posts.  You can create these categories then assign your posts as you go (Happy, Sad, Mad).  Categories allow you find all posts that are marked within the category, or better yet get a full RSS feed of everything in the category (maybe someone wants to subscribe to my “Happy” feed, but not the “Sad” feed).

So, what if you want to create a category that you don’t want to be accessible with normal Category functionality?  For example, what if I wanted a “category” (like “f$cked up”) that didn’t have RSS feed access?!  Enter taxonomies, categories that don’t behave like categories.

Today I set out to write a custom taxonomy that I could include on posts then provide a custom RSS feed for.  The only way people would be able to find the feed was if I specifically provided them the URL.  The taxonomy might have some special rules, for example the posts might only be a certain length (default Category RSS feeds are full length).   

Getting Technical

When you initiate a new Taxonomy you are basically cloning the existing Post Category or Post Tags logic.  However, with Post Categories you are provided an additional field for parent because post categories are hierarchal. But what if you want to add additional fields to the interface?  That’s where it gets a little harrier.  I suggest following up with a more in depth example.

Give Credit Where It Is Do

Ready to learn more?  Give props to Paul Menard’s article that makes this as painless as possible!

Zend Form removing validation

Published:

Ever need to remove form validation? Why would you want to do that you might ask … let me tell you!

Let’s say your sign up form requires you to enter a password, and just for good measure (cause that’s how we roll) you ask them to confirm the password they entered.   If they forget to enter the password, then you really don’t need to remind them that the confirmation doesn’t match (do you?!).  So be nice, remove that validation, and just let them know that they forgot to enter a password.

if (empty($data['password'])) {
$this->form->getElement('password')->clearValidators();
$this->form->getElement('password_confirm')->clearValidators();
}

$this->form->password->setRequired(false);

Start, stop, start, stop

Published:

Interruptions break your workday into a series of work moments. Forty-five minutes and then you have a call. Fifteen minutes and then you have lunch. An hour later, you have an afternoon meeting. Before you know it, it’s five o’clock, and you’ve only had a couple uninterrupted hours to get your work done. You can’t get meaningful things done when you’re constantly going start, stop, start, stop.

The obvious way to combat this is to get a door on your office, and make a priority to prioritize. You block off time for your wife, kids, family, and friends … Now it’s time to make time for you and the work you need to get done.

Which adapter adapts better to your adaption?

Published:

Ask any developer that is just starting out with PHP and they’ll tell you how great the core set of functions are to interface with databases.  Ask any developer that has been in the game for awhile and they’ll tell you about how the improvements that were introduced with the PDO (PHP Data Object) improved life ten fold.  

The PDO provides a nice abstraction layer (along with all kinds of other goodies) to make database interaction even easier, but it still leaves some things lacking.  I’m not going to to talk in detail about those today, but I am going to tell you where you can go from here to find a better solution.

When I first started programming with PHP (circa 2004) none of this goodness existed and life was a lot of copying and pasting.  Then the PDO came along and then PEAR wrapped it with DB and later the improved MDB2 implementation.  When I came to the party MDB2 was en vogue and I wrote my own wrapper for MDB2 to do some extra logging.  It worked great for me for many years and life was good.  However, when I started doing development in Zend Framework I was introduced to a couple of different new design patterns for interfacing with databases.  Enter the Zend_DB_Adapter_Abstract and the Zend_DB_Adapter.  Let’s take a look at each and you can decide which way to roll.

Zend_DB_Adapter_Abstract

There are a couple of ways to use the Zend_DB_Abstract. You can setup a driver class (typically an abstract or interface level) and build up on it.

class Users extends Zend_Db_Table_Abstract { 
/** 
* explicitly set the table you are interfacing with
* if you don't do this, it will use table that matches the name of your class
* in this case the table would be 'users'
*/
protected $_name = 'users';
 /** 
* Specify what DB drive you want to use to interface to the DB
* The Default Adapter uses PDO
*/
function __construct() {
Zend_Db_Table_Abstract::getDefaultAdapter();
}

function getUsers() {
$select = $this->select();
$select->where('id = ?', $userId);
$userRow = $this->fetchRow($select);
}
}

Alternatively, you can just call the specific version of the abstract adapter and specify the that you want at run time:

Zend_Db_Table::setDefaultAdapter($dbAdapter); 
$bugTable = new Zend_Db_Table('bug');

Zend_DB_Adapter

There are a couple of implementation options when using the Zend_DB_Adapater. You can explicitly specify which type of DB you are interfacing with:

$db = new Zend_Db_Adapter_Pdo_Mysql(array(
'host' => '127.0.0.1',
'username' => 'webuser',
'password' => 'xxxxxxxx',
'dbname' => 'test'
));

Or you can just use the Factory

// We don't need the following statement because the 
// Zend_Db_Adapter_Pdo_Mysql file will be loaded for us by the Zend_Db
// factory method.
// require_once 'Zend/Db/Adapter/Pdo/Mysql.php';
// Automatically load class Zend_Db_Adapter_Pdo_Mysql
// and create an instance of it.
$db = Zend_Db::factory('Pdo_Mysql', array( 'host' =gt; '127.0.0.1', 'username' =gt; 'webuser', 'password' =gt; 'xxxxxxxx', 'dbname' =gt; 'test' ));

Conclusion

There are a lot of different methods of using DB adapters with Zend. Don’t let it wear you down, just find the adapter that adapts best to your problem (or use the factory, it’s always a good fallback).