MattErickson (ME)
Jan 4, 2018
Categories: business
Tags: stand-up, agile, and ceremony

Stand-up Failure

Standing in a room, asking myself the three question

  • What did I do yesterday?
  • What will I do today?
  • What is something in my way?

Jan 25, 2017
Categories: personal
Tags: personal, o'erick, and o'keefe

My wife rocks

Most of you are thinking “well, there is always a reacher and a settler, right?” Yes, I agree. And I stretched for the moon. Over the coming years I think we will see some real battles that will be fought for people who deserve to have every right to be, do, and succeed as their neighbor. I don’t sit on one side of this fence, I am not with her, I’m not in on the ‘Black/Blue Lives Matter’ movement(s). But without taking a side I can still support all of them. All of these movements have so much in common, love, common decency, following the golden rule, care about eachother. I don’t think any of this should be hard for us but apparently I am wrong.

Jan 17, 2017
Categories: Development, HTML, JavaScript, and Angular

Welcome back!

Ok, maybe I’m saying that to myself. In either case, long time no talk, internet! Today we have a quick trick to kill styling in angular-material, which is a framework for angular 1 or 2 that I have enjoyed link to angular-material. So, here’s the thing, we (at my work) have a large code base that already has a multi tenent implementation of different themes set and we didn’t implement that using material (wasn’t available 4 years ago). So when we started pulling in pieces and including javascript we started noticing things like a:not(.md-button) and .md-default-theme popping up around, to our surprise. Up until recently it hadn’t been a problem… well, you guessed it, it became a problem. We had a few buttons from our old bootstrap days with btn btn-link that should have been a specific color for a theme and they were being overridden. Took some digging but there was some dynamically generated CSS that was being shimmed into the <head> of the HTML. We found a way around this though, straight from the docs, check it out: Disable Theming. Note: this __JUST__ became a thing in version 1.1.1!!! Upgrade, for God’s sake!

Upgrade to angular 1.5 and input vs. model naming

Jul 27, 2016
Categories: Development

So, here is the thing ng-model and name on input are two things you should be comfortable seeing if you are in the angular community. Well, let me tell you something… You will get some seriously weird behavior if those two items are the same. The form on scope will get weird validation state and your values will be all sorts of FUBAR. Keep these two magic strings seperate and don’t cross the streams.

Going to ngConf!

May 3, 2016
Categories: Business and Development

Well, as I sit here at barrio in terminal 2 of the MSP airport I realize just how big of an opportunity I am bring being presented with. Being a full stack dev looking to separate myself from the crowd I found front end development interesting, opinionated, fun, and fulfilling more than other parts. I like to think I bring clarity and simplicity to both code and ui’s through my creations. With all the excitement in the world fueling my passion I could only go so far without supporting casts like my wife, my boss, his boss, her boss and ultimately the CEO of my work and the company as a whole. I want to take this trip to better me, as a developer, as a name, as a person, as a leader, and as a valuable employee. Much is to be learned and hopefully i can sponge it all. Wish me luck!

Apr 6, 2015
Categories: (ME), Development, and Javascript

Sup?! Over the past few weeks/months I have been incredibly busy, as you can probably guess from my lack of attention to this site. That doesn’t, however, translate into getting nothing done. My

GitHub account tells a different story. As does my BitBucket account but that one is where I host all my private repos, sorry.


Angular I have immersed myself in the javascript culture, community and life. It has been eye-opening to the patterns, problems and struggles that are out there. Beyond just writing angular I have taken a shine to UX creation. The patterns and ideas behind UX fascinate me. It is a very soft… and hard science. It deals with how you feel about the page, how you interact with it, what this color, transition, spacing does to your person. But on the other end of the spectrum these ‘feelings’ don’t just get measured by your warm and fuzzies, they must be calculated to decide if what you are presenting is working. Depending on the platform that can be in orders placed, clicks into links, or time on a page.


Yes, software. Did you expect anything less vague? I have created software for less than 10 years now and my understanding has changed immensely. I still remember struggling with a shuffle algorithm for a blackjack game I wrote in college, now i would just do a `gem install cards`, kidding, but not entirely. Software in academia is very different then that of the real world. You don’t need to beat the horse to show that you know how to implement a stack, a queue, a list and all there related functions. Usually you don’t need to think about how your `O(n)` will turn out for this function or how performant your sql query will be. There is scoping around everything. If you have an admin page that takes 10 seconds to run a giant query for all payroll reports but the corner office wants that report all at once, you make it so.

Adventures in Angular

AiA I know I have mentioned it before but, man,

Adventures in Angular, nerdy or not, is really fun to listen to. I wish there were more. I listen to one on the way to work and one on the way home which usually ends up depleting my stash of things to listen to very quickly.

Dec 26, 2014
Categories: Business, Development, Javascript, Random, and Web
Tags: development, food.eat, ruby, and ruby on rails

I have been planning, plotting, schema…ing(?) about Food.Eat since my original post. I have made some progress but I have not nailed down exactly how I want to handle user authentication/authorization. Mostly, I think this is due to my choice in the loosely scripted PHP backend. With that knowledge tucked in the back corner of my head I made a desicion this morning based on some information from listening to one of my first podcasts Adventures in Angular I am going to not only learn but also use Ruby on Rails for my backend.

Ruby on Rails is a full stack web application framework that is relatively young by comparison to many languages in use today. It is fast, nearly pseudocode (spoken language-ish).

Similarly to using ruby as a new language on Food.Eat I also made the decision to go with angular 1.3.X for performance reasons and am also following John Papa’s Styleguide which, in my opinion, made my angular code much easier to read (Example).

If you would like to see any of the workings as I move forward, please, star, fork, help out, or just think “huh, Matt types things and I have no idea what they mean or he is talking about”.

GitHub Code Repository

P.S. Sneak peek

login1 login2

Dec 16, 2014
Categories: (ME), Business, Development, Javascript, and PHP

Recently I decided I was going to look into a simple app that I wanted to build. The app for a first pass will be a simple angular/slim php backed app that will use a smartphone’s camera capabilities. The idea behind the application would be that as your day goes on you want to track all the things you eat. We all know the jig, get out the phone, boot an app, enter some arbitrary feeling information on your food you are about to eat. Well that is where I am going to attempt to differentiate, I want just a simple snap-shot picture. Take a picture and chow on! Heck, share it on instagram anyway, why not upload it to my server too? That’s it. The point of it is that each day you can see the amount and what you consumed. I believe the barrierless feel of it will make it easier to use than many “health” tracking apps.

From this point in the game I am architecting how my database is structured and planning out the implementation details. I am most likely going to host the code in a public repo on github because I feel this idea isn’t revolutionary, just unique. The easier I am able to make it the better off I will be in the long run. Of course, I will be withholding specific pieces of information like database passwords and adsense pieces.

Food.Eat GitHub Repo

Dec 10, 2014
Categories: Development, Javascript, and Web

This morning I sat down at my computer to start work. Pull up our bug tracking system to see what is going on. Well, bug in the software, looks like something in angular. Pull up the page in the specified environment and hit f12. Woh, woh, woh, what is this ‘angular hint’ in my console?!?

Angular Batarang

Angular batarang is a google chrome plugin that helps working with and debugging angular tons easier, well, it didn’t really before but it does now! The plugin updated and now it seems to work pretty slick. You now have easier access to angular scopes and angular hinting via angular batarang.



Notes As of this post there are some stability issues going on with the plugin that is causing some failures but once those get ironed out I anticipate angular batarang to become quite useful in the coming months.

Dec 9, 2014
Categories: Development, Javascript, and Web

Why must we do this So, due to some business limitations, and much to my chagrin, I am supporting IE8 at work. I don’t even want to talk about it. BUT with that we also want to not be “bossy” in the way we show users errors in our angular code. Brings me to the point; custom angular directive to polyfill the 1.2 -> 1.3 gap in modelOptions! (also not happy to change the core of angular in this way).

Angular Code time! Get the angular module (or create)

var module = app.module('myNeatDirectives');

Create the angular directive. We use ‘input’ because we don’t want opt in function here, we don’t even want opt out now (that can be added). We also restrict to ‘E’ which is element (i.e. <input type=”text” />). We require ngModel (<input type=”text” />) but throw the ‘?’ on there for optional inclusion. Finally setting the priority to 99 so it runs after the angular binding happens.

module.directive('input', ['$sniffer', function ($sniffer) {
    return {
        restrict: 'E',
        require: '?ngModel',
        priority: 99,

Next up, the bread and butter. We check if the input is of type radio or check box, no need to do special bindings there: return; Then we use angular’ built in $sniffer to check for event bindings, in a similar fashion to how modernizr would work, unbind any bound events from the element.

link: function (scope, elm, attr, ngModelCtrl) {
            if (attr.type === 'radio' || attr.type === 'checkbox') return;
            if ($sniffer.hasEvent('input')) {
            if ($sniffer.hasEvent('change')) {
            if ($sniffer.hasEvent('keydown')) {

Now we bind up our blur events and update the model.$viewValue on the blur callback.

elm.bind('blur', function () {
                if (ngModelCtrl.$viewValue === elm.val()) {
                scope.$apply(function () {

There are some cases (search boxes) that you may want a specific keypress to trigger events. I wanted enter to also set the value, so boom. Made it happen.

elm.bind("keydown keypress", function (event) {
                var charCode = event.which || event.keyCode;
                if (charCode === 13) { //enter key is 13
                    scope.$apply(function () {
//and close the rest of the curlies and squares

Nov 23, 2014
Categories: Development, Featured, PHP, and Web
Tags: google api, google calendar, google calendar api, google php api, and PHP

Google Api v1/v2 is dead, move on

Please note the Google PHP Api changes regularly and none of this code is future proof as the google api client is still in beta

Recently I undertook a php application that was using a ‘zend’ google calendar api. Well as of the 17th of November 2014 the google api v1/2 (used internally by zend) shut down. I used this as a learning opportunity to impl google api v3.

So here is the code that I have come up with that has worked pretty well for me. It is very similar to zend.

First we setup our google client from the client implementation on Google Api Php Client, you will need the client in your application somewhere and will need to require the AutoLoad.php in order to use it. (Not shown below)

Code it out

$user = 'useremail@gmail.com';
$gclient = new Google_Client();
$gclient->setApplicationName("My Apps Name");

if (isset($_SESSION[$user.'_service_token'])) {
$key = file_get_contents($privateKeyLocation);
$auth = new Google_Auth_AssertionCredentials(
	$config->google_email_address, //this is my service account email **crazy_string_here**@developer.gserviceaccount.com
	array('https://www.googleapis.com/auth/calendar'),//Google calendar permissions
	$key //contents of my .p12 file i downloaded from console.developers.google.com
$auth->sub = $user;//This is saying our service account will be acting as the sub user
if ($gclient->getAuth()->isAccessTokenExpired()) {
$_SESSION[$user.'_service_token'] = $gclient->getAccessToken();

At this point we have setup all of our google_client code so we can add our implemented “add calendar event”. First Instantiate the calendar service.

$cal_service = new Google_Service_Calendar($gclient);

Now we need to set up an event, give it a “summary”, location, and a start and end datetime in format



$event = new Google_Service_Calendar_Event();
	$event->setSummary("Event Title");
	$event->setLocation("123 Fake St. Dover, ME 41426");//Address City, State Zip
	$event->setDescription("You have a new event on your calendar!");
	$endTime = clone $aDateTimeObject;
	$endTime->add(new DateInterval('PT1H'));//1 hour calendar event
	$start = new Google_Service_Calendar_EventDateTime();
	$end = new Google_Service_Calendar_EventDateTime();
	$createdEvent = $cal_service->events->insert($user, $event);

At this point we have a calendar event returned to us and can use


to get the event ID if we want to store it so it can be updated/deleted later in similar fashion like so:

$cal_service->events->delete($user, $createdEvent->id);

Hopefully this was enlightening for you and with all the recent changes (and shutdowns) of the google api this can help you transition your application more quickly to the new version.

Nov 21, 2014
Categories: Business, Development, Javascript, and Random
Tags: Angular, development, front-end, and javascript

Long time, no talk, internet! Recently, we have been extremely busy at work getting market ready launch of a new product ‘redeem.’ Leaving me very little time to write about anything (in a blog sense, plenty of coding). I have plenty to say and very limited time to say it in.

1) Google api v1/2 shut down on the 17th. I inherited a site dev for a nation wide in home computer repair company. It is a bit on the academic side of structure and code but it works. I have since converted much of it to PDO (php) and angular. Well there was also a framework living in the depths, Zend, which internally uses(d) Google api v2. See the tie back now? 48, grueling, hours later the site now uses Google api v3 in native php.

2) I have stepped into a role as a go to front end dev in angular, js and css/less. Which is more about teaching and less about coding, meaning I should NOT forgo “useless” Jasmine tests I did. Market ready, as I mentioned is this release. Code freeze is today. 20 units over our average and we made it. Now bug fun. Hopefully I will be able to take a breath of this harsh early winter Minnesota had served up.

Sorry for the lack of sweet code. I will follow-up shortly with a blur model update directive in angular when I get a minute, not on my phone, to write a party.

Almost forgot! I have listened to a podcast that I have enjoyed, adventures in angular, if you haven’t heard of it, check it out, good information to be had.

Until next time,


Aug 5, 2014
Categories: (ME)
Tags: erickson, matt and lauren, o'erick, o'keefe, personal, rings, wedding, wedgewood, and wedgewood rings

I am getting married!!!! Not even too far off too, August 15th 2014. Lauren and I have been dating now for about 5 years and engaged for about 1. Here is the story, as told by Lauren,

When it happened Friday, June 21, 2013

How we got engaged

After moving back to Minnesota, Matt and I hoped to squeeze in a quick trip to California before Matt started his new job at Hallmark Business Connections. Since I was busy planning the road trip home, I asked Matt to take care of planning the vacation. Little did I know, Matt was about to take that responsibility and run with it. As the date of the trip grew closer, little bits of information slipped out and eventually Matt had to come clean with me. He brought me out to the garage where there were four little books: travel guides for France and Italy and two pocket dictionaries. I couldn’t believe it! Matt actually pulled off a surprise! And it was the best one of my life–well, maybe the second best.. I quickly brushed up my French, packed a bag, and we were off! On the second day, we were scheduled to take a private scooter tour of Paris and Montmarte. The day came, and there was rain in the forecast so Matt started acting wonky and blamed it in being nervous about driving a scooter on the slick cobblestone roads of Paris. Lucky for us, the rain held off until later in the day so our tour guide, Pablo (best tour guide ever by the way) arrived promptly at 9 am and started taking us around Montmarte. We stopped at the Moulin Rouge, the I Love You wall, and Les Deux Moulins (a cafe made famous in Amelie) before winding up the hill to the Sacre Coeur. As we were walking up the steps to the beautiful cathedral, Matt fell back and started whispering something to Pablo. This was a bit suspicious, but we got to the top of the stairs and just curved off to the left to a little gelato restaurant. Pablo said he was going to bring our helmets back to the bikes because there was a lot to see in this area so we wouldn’t need them for a while. He came back carrying our backpack and with the excuse that there wasn’t room for it in the storage compartments with the helmets. I completely fell for it. Matt quickly snatched it up and we took our gelato back over by the steps of the cathedral.. At this point, Matt started mumbling something about playing a game and how “never has he ever loved someone so much.” He opened up the backpack, pulled out a lumpy sock, got down on his knee and asked me to marry him (IN FRENCH!). I was ecstatic — definitely way too excited to pose for pictures! Of course I said yes and a group of students on a field trip burst into applause. From there on out, Pablo sounded like an adult from the Peanuts cartoon because I was so euphoric. Even though I may not remember much of what he said, but I will absolutely never forget that day (or the rest of the trip of course).

To avoid being SUPER verbose about it all the real reason behind this post is about the cool ring Lauren found me! It is made by a gentleman in Wisconsin that markets under Wedgewood Rings. The rings are reasonably priced and he sells via etsy (his shop here) so they are backed with a good platform of feedback. I received mine in the mail yesterday and I am stunned. It is perfect.

This slideshow requires JavaScript.

Aug 4, 2014
Categories: Business, Development, and Web

After quite some time on the same theme I decided it was time to update. The old theme had some severe limitations in post style, ad additions, analytics, headers, footers. You name it, it was a problem. This theme is based of “Spacious” which i have, so far, found quite easy to work with. I haven’t found anything too out of the ordinary with it so far and everything seems to be working as expected.

I am using a twitter and a github widget on the front page as well as a custom theme widget for the front page layout. The rest of the blog is mostly as you would expect it to be, blogy.

Old Site Look

Jun 6, 2014
Categories: HTML5/CSS3, Javascript, and Web
Tags: Hack, IE, IIFE, javascript, and jquery

We all love IE, right?!? WRONG! Well now with jquery bumping out the browser detection we have to have some way to deal with IE and gracefully degradating our features. I found a pretty neat way of dealing with browser detection that I have integrated at a very root layer for my javascript.

(function (window, navigator) {
    window.Browser = {
        IsIe: function () {
            return navigator.appVersion.indexOf("MSIE") !== -1;
        IsIeMobile10: function () {
            return navigator.userAgent.match(/IEMobile\/10\.0/);
        Navigator: navigator.appVersion,
        Version: function () {
            var version = 999; // we assume a sane browser
            if (navigator.appVersion.indexOf("MSIE") !== -1) {
                // bah, IE again, lets downgrade version number
                version = parseFloat(navigator.appVersion.split("MSIE")[1]);
                return version;
}(window, navigator));

Let’s pick this guy apart, shall we? First off, we wrap the whole thing an Immediately-Invoked Function Expression, or IIFE (if-ee). This lets us get some immediate functionality as soon as the JS is hit, it also, based on the params passed into the function, have local references to object that live on the js page scope so there is much faster retrieval time.


(function (yellowSubmarine) {
    yellowSubmarine.on('click', function(event) {
        console.log("do click things");

This will set the var `yellowSubmarine` to the jQuery function. Pretty normal javascript pattern. Moving on.

We grab `window` and set a new variable on it named `Browser`. This is where we will store our helper methods to figure out if we are dealing with IE or not. `IsIe`, `IsIeMobile10`, `Navigator`, and `Version` are all helper functions that can now be called off of `window.Browser` or just `Browser` from JS. If we have a piece of functionality that we want removed that isn’t capable of being detected by any other technology that has been implemented we now have a simple and concise way to detect and turn it off!

For example; in the previous post I wrote about the custom select box and mentioned that it will not work in IE8-10. Here is how i chose to disable it using the example code above:

$(function() {
    if (window.Browser.IsIe() && window.Browser.Version() <= 10) {
        var selectBoxes = $(".custom-select-box");
        for (var i = 0; i < selectBoxes.length; i++) {
            $(selectBoxes[i]).removeClass("custom-select-box full-width").attr("style", "width:100%").find("select").removeClass("form-control").attr("style", "width:100%");

No regex, easily readable. One line, two condition if statement. Doesn’t get much better than that in terms of detecting and fixing IE. This fix was to ‘gracefully degradate’ IE10-IE8 (our supported browsers) by just disabling the custom styling. DONE!

Jun 5, 2014
Categories: Featured, HTML5/CSS3, and Web
Tags: CSS, Dropdown, HTML, Select, and SelectBox

UI/UX and dev is always a delicate balance. We had a recent request come in to style our dropdowns as the rest of our form fields. We are using bootstrap so our inputs are fairly customized. Here is how I did it, I will discuss the issues and caveats after the basic code for “modern” browsers.

HTML structure

        <option value="1">Value 1</option>
        <option value="2">Value 2</option>
        <option value="3">Value 3</option>
        <option value="4">Value 4</option>

This is all in less.

Style the containing label:

.custom-select {
    position: relative;

    &:after {
        .fa; //Font awesome icon
        .input-group-addon; //bootstrap mixin
        border-bottom-left-radius: 0;
        border-top-left-radius: 0;
        padding: 10px 13px;
        width: auto;
        height: 100%;
        content: "\f107"; //down arrow
        font-family: FontAwesome;
        position: absolute;
        right: 15px;
        top: 0px;
        pointer-events: none; //Do not block the propagation of the pointer event

Now to style the select box itself which is really just hiding the arrows and coloring it.

select {
        outline: none; //hide the outline
        -webkit-appearance: none; //hide the arrows
        -moz-appearance: none; //hide the arrows
        appearance: none; //hide the arrows
        cursor: pointer; //change the cursor
        .placeholder(); //mixin for placeholder values
        color: @input-color; //theme var
        font-weight: normal;

        option {
            color: @input-color; //background for the options
    /* Targetting Webkit browsers only. FF will show the dropdown arrow with so much padding. */
    @media screen and (-webkit-min-device-pixel-ratio:0) {
        select {
            padding-right: 18px;

Relatively simple, but there are some key pieces that need to be in place for this to work.

  • pointer-event: none; This is very important or the overlaid addon would catch the pointer even and we wouldn’t “click through” to the underlying select box. This is NOT SUPPORTED by anything less than IE11. (IE10 is still going to cause you fits here).
  • `outline: none; //hide the outline
  • -webkit-appearance: none; //hide the arrows
  • -moz-appearance: none; //hide the arrows
  • appearance: none; //hide the arrows
  • cursor: pointer; //change the cursor Also very important so we don’t see the stupid OS generated select boxes that change from one to the next.

You will probably also notice that I don’t touch any of the nasty hacks that could happen for IE8-10. This is because I used a bit of javascript to grab these boxes and just remove all custom styling. It is much easier than hacking it and we have decided it to be graceful degradation. I will discuss this in a different post.

Your output should look something like this:


Unlike some examples i’ve seen out on the internet here is an actual WORKING example of how this is supposed to look and behave in modern browsers.

Sep 27, 2013
Categories: Beer Brewing and Homemade/DIY

Since I have started homebrewing there has been one thing that I don’t like. Bottling. Cleaning, sanitizing, adding sugar, bottling, capping, waiting… oh the waiting! I hated it.

Recently I received 4 sanke kegs, tubing, and a 6 port manifold from my uncle, Dazzling Dave… who received it from my OTHER uncle Pete who owns Detello’s Pizza & Pasta.

The problem I had was that the keg’s spears did not have the retaining rings/clips. Luckily after some internet searches and searching I found a 5 pack of retaining rings on amazon. Cheap enough and works perfectly, there is a bit of finagling to get the sanke fittings to sit correctly with them but c’est la vie.

For reference I will share what my steps were in cleaning and filling.

  • Remove spears
  • Soak spears and kegs in clean water with oxyclean for a few (3-4) hours
  • Dump and rinse thoroughly
  • Sanitize however you see fit
  • Run BLC through any lines that would touch the beverages
  • Sanitize lines
  • Siphon beer into kegs
  • Chill and fit spear, C02, and tap lines
  • Turn on C02 to your preferred carbing pressure
  • Enjoy sanke keg beer

Kegs in the fridge

Sep 27, 2013
Categories: Business and Development

The other day I was pinged by a professor from my college about a potential opportunity to give back to the community who has nurtured my technical growth. She introduced me to two individuals who are growing a newer program in minnesota: Technovation Challenge. This challenge is aimed at middle and high school females in an effort to give them opportunity to show off their technical savvy and a chance to learn a new skill. We will be using MIT’s App Inventor which is a drag an drop, block based programming language which lowers the barrier to entry for youth/adults in general. I am very excited about being a part of this program and helping Minnesota continue becoming a technology hub in the midwest.

More info can be learned IridescentLearning.org and on twitter @technovationMSP or @Code_Savvy and their main site Code Savvy.org

Apr 29, 2013
Categories: Design Pattern and Development
Tags: Design Pattern, MVC, and MVP

MVC vs MVP. MVC, as I said in a earlier post is Model View Controller. The controller is used primarily for the interactions from the model to the view/user. It (the controller) is responsible for getting the correct view out to the user.

Lets explore MVP a touch and then we will go into the differences. MVP, Model, View, Presenter. Model, just like MVC, is what holds the data, no manipulation occurs at this level. View, the user interface, but as Mike Potel from Taligent (IBM) says separates this view from the MVC view is that nearly all common day operating systems and software languages provide most of the controller functionality and the “controller” idea is now unnecessary for the most part. Lastly, the presenter, the data and view intermediary. The presenter is more like a stepping stone for the view and the model, it’s job is to serve the view with the model so it can bind to the data.

The main differences here are relatively clear; the view in MVP has business logic and will delegate to the presenter. It (the MVP view) also has data bindings to the model. The MVC design pattern uses the controller to server the views and does not allow direct access to the model for the view.

Summation: MVP seems to be a more natural method of how programming is going, even if people continue to use the MVC acronym when they mean MVP. In my opinion, after this research, I believe many people are just oblivious to this separation. I can see that in a more responsive design with a heavy ajax view that the MVP pattern would be much more useful than going clear cut MVC.

Thanks again for reading,


Happy Birthday Meyer

Apr 26, 2013
Categories: Business and Development
Tags: coders, ethics, programmers, and psychology

So, today, as most days, during compilation or time I take to rest my brain from strain I was reading through some of the G+ posts on development, technologies, and programming and came across this post. It is an excerpt from Jerry Weinberg’s book The Psychology of Computer Programming.

1) Understand and accept that you will make mistakes. The point is to find them early, before they make it into production. Fortunately, except for the few of us developing rocket guidance software at JPL, mistakes are rarely fatal in our industry, so we can, and should, learn, laugh, and move on.

2) You are not your code. Remember that the entire point of a review is to find problems, and problems will be found. Don’t take it personally when one is uncovered.

3) No matter how much “karate” you know, someone else will always know more. Such an individual can teach you some new moves if you ask. Seek and accept input from others, especially when you think it’s not needed.

4) Don’t rewrite code without consultation. There’s a fine line between “fixing code” and “rewriting code.” Know the difference, and pursue stylistic changes within the framework of a code review, not as a lone enforcer.

5) Treat people who know less than you with respect, deference, and patience. Nontechnical people who deal with developers on a regular basis almost universally hold the opinion that we are prima donnas at best and crybabies at worst. Don’t reinforce this stereotype with anger and impatience.

6) The only constant in the world is change. Be open to it and accept it with a smile. Look at each change to your requirements, platform, or tool as a new challenge, not as some serious inconvenience to be fought.

7) The only true authority stems from knowledge, not from position. Knowledge engenders authority, and authority engenders respect – so if you want respect in an egoless environment, cultivate knowledge.

8) Fight for what you believe, but gracefully accept defeat. Understand that sometimes your ideas will be overruled. Even if you do turn out to be right, don’t take revenge or say, “I told you so” more than a few times at most, and don’t make your dearly departed idea a martyr or rallying cry.

9) Don’t be “the guy in the room.” Don’t be the guy coding in the dark office emerging only to buy cola. The guy in the room is out of touch, out of sight, and out of control and has no place in an open, collaborative environment.

10) Critique code instead of people – be kind to the coder, not to the code. As much as possible, make all of your comments positive and oriented to improving the code. Relate comments to local standards, program specs, increased performance, etc.

The most amazing part of all of this, in my opinion, is that this book was written in 1971. Remember that year? I don’t, wasn’t even alive yet, but do you know who does? Intel. Intel introduced the first microprocessor November 17th, 1971, the Intel 4004. Apple hadn’t released a computer yet.

Keep the commandments in mind in your work and I promise that you will be a better developer and be of more worth to everyone around you.


Apr 26, 2013
Categories: Development and Java

MVC. Model, view, controller. The building blocks of a extensible, reusable, wonderful code base.

Model: The data. Does NOT depend on the controller. Not even a little! It doesn’t modify the data, it doesn’t do anything except hold the data in some way shape or form (E.G. hibernate or another ORM to take care of database interaction on the model side)

View: Is a bit trickier. The view in a strict MVC is the layer that the user interacts with. It can or can not depend on the controller but should always be independent from the model. In cases where the view depends on the controller the view often is combined with the controller, a lot of android applications will mesh these two layers slightly where the button clicks will get attached in the controller for the activities.

Controller: Depends on both model and view, unless of course the view is one in the same with the controller. The controller uses information from the model to send (or display) data to the user and interprets any user interactions that happen.

Moving into the point, that I know I have failed at in the past:

The model represents the data, and does nothing else. The model does NOT depend on the controller or the view. Example that is WRONG!!!!

static class MeController() extends BaseController {
  private static MeView s_view;
class Person() extends BaseModel {
  private String m_name;
  public void setName(String name) {
    m_name = name;
    MeController.m_view.refresh(); //THIS IS NOT OK!!!
  public String getName() {
    return m_name;

Proper MVC use of a model:

class MeController() extends BaseController {
  private MeView m_view;

  public void DoClickButton(int personIndex, String name) {
class Person() extends BaseModel {
  private String m_name;
  public void setName(String name) {
    m_name = name;
  public String getName() {
    return m_name;

So, here, we see the main difference in this code: the model in the first example tells the controller to refresh the view. Now this model cannot be used by any other class unless every interaction with a person is meant to refresh that one list every time. Not only is the model not reusable for different classes but if we decide to give the user an option to have a grid or a list, which is becoming more and more common in web development and mobile, we cannot because we are attached to the list in the controller by hard coding.

So this takes care of re-usability of the model but what about the controller. This is all dependent on using a specific view. If we decide that this version of jQuery is not effective on mobile or what ever the case is we need to find all references to m_view.refresh(); and change it to (trivial but blocking) m_view.reload();. This is where separating the view and the controller comes in. If we open up the MeView and add this:

class MeController() extends BaseController {
  private MeView m_view;

  public void DoClickButton(Person person, String name) {
    m_view.changeNameButtonClick(person, name);

class MeView() extends BaseListView {
  public changeNameButtonClick(Person person, String name) {
  private void refresh() {
    //do refresh for this specific view type

class Person() extends BaseModel {
  private String m_name;
  public void setName(String name) {
    m_name = name;
  public String getName() {
    return m_name;

It may seem like it is slightly redundant to pass the person around the controller and view but with this setup we can swap in a new view that implements a new technology and don’t even have to bat an eye at how the controller will react. It will just work.

So for the finale, the answer to all of your Pastafarianism problems is MVC. If done correctly you can separate the model from your view and have three distinct layers that can be unit tested, compiled, and swapped in and out with different tech stacks without a huge head ache.

Hopefully this has clarified the struggle for many college CIS/CS majors.


Apr 2, 2013
Categories: Random
Tags: multiverse, not programming, universe, unrelated, and video

So, this video, to me at least, is very interesting. The universe -> multiverse idea is crazy. P.S. linked from LaughingSquid

Feb 19, 2013
Categories: Business
Tags: development, interview, social skills, and software engineer

Today is the first day in my career at Vecna that I get to give an interview.

I have given interviews in the past, hiring for my earlier companies, ByME (all technical employees) and Illume (the sole other engineer). But I have never done anything in this respect here at Vecna. I view this as a great opportunity to further my skill set as a leader, innovator, and a resource for myself and my employer. I have given great thought on questions I will ask and things I want to carry out in getting to know the people that I will talk with. I have to conclude that, considering they are MIT undergrads, I can put a solid foothold on the fact that they will have basic understanding of OOP (Object Oriented Programming) and it’s patterns. However, I can NOT necessarily say that these people will make good coworkers in our environment.

Who doesn’t want to work with someone who they enjoy talking to, someone who they would like to bounce an idea off (work related or otherwise) and see what comes back. Some of my favorite people with whom I have had the pleasure to work with are not just brilliant minds in software engineering but also; moonlighting at a homebrew emporium, an avid small skit actor, a car enthusiast, and a lover of all things scotch. These people peek interests that I, at one point or another, have interested in or admire.

I want to give off perception of respect and openness to the person so they will feel that they can truly share what they love in their life.

There is much that The College of St. Scholastica taught me but the thing I value above any lessons taught by my teachers is that of the Computer Club. I learned how to lead, to be a well-rounded person, to have fun. This is very important and I think a lot of the technical world forgets how to do it some time. If you get the chance to bring some fun into your workplace in some form DO IT!

Feb 12, 2013
Categories: Authors

Early Life:

I grew up in White Bear Lake, MN where I attended White Bear Lake Area High School. While there I played tennis all four years and I graduated in May, 2007.

CSS (College of St Scholastica):

When it was time to go off and get an education, I headed for the frozen north and the College of St. Scholastica. I had chosen CSS because I was looking for a small private school, they had given me generous scholarships, and I was recruited to play Division III tennis. I started as a pre-medicine student but after the classes lost their allure I was advised to try out marketing/advertising. Well I was hooked right away and I knew what I wanted to do. In the small amount of free time that school and tennis allowed me, I joined the CSS Computer Club, where I met Matt. I served under Matt as the club’s Minister of Propganda and helped Matt to radically change the club for the better.

The Real World

After graduation, I had to face the music and start acting like a functioning adult. I began with an internship, at Cortec Corporation, in my hometown which turned into a full-time job. I have continued to work there as a Marketing Assistant, writing print materials and planning trade show appearances.

For Fun:

I love hanging out with my girlfriend, Jackie. We cook, go to concerts spend a lot of fun time with friends and family. I also love discovering new music and odd food, camping with the Boy Scout troop I’m involved with, and of course playing tennis.

Feb 12, 2013
Categories: Beer Brewing, Homemade/DIY, Other, and Wine Making
Tags: beer, diy, fun, new, and wine

Recently (in the last year or so), I have become quite enthralled in the process of beer brewing. This has not only led into wine making but also other DIY projects. Just last week I made my first attempt at making homemade ginger ale! With all this being said let me introduce you to the new section of MattErickson.ME. The Homemade/DIY Section (that doesn’t include coding).

Although, I know this is very different from coding and software they aren’t far from the same. I say this, and believe it, because what drives me most about my job is the creation, I get to take nothing and build something. It is my empty canvas (art, not HTML5 :P), it is my winding road, it is my cutting board.

So, here is where I would like to share my experiences with you and document fun, new ideas that you may someday like to try as well!



Feb 8, 2013
Categories: Development
Tags: collaboration, oh god what have I gotten myself into, and tucker

Hello World!

Get it?

…It’s a programming joke…

…you know…like the first program you learn to write?

Sheesh, rough crowd.

As you may already have read in Matt’s most recent post, I’m the new guy around this site. My name is Tucker, I work in marketing/advertising as a jack-of-all-trades from copywriting to event planning. I’ve always been interested in technology and tinkering around but rather than learn cool computer stuff in college, I chose to take philosophy classes and play tennis.

Nice to meet you too.

So the background behind this collaboration is pretty straightforward, Matt and I have been buddies for a little while now and I am always pestering him with questions like: “I want to learn coding, how do I do it?” or, “What language should I learn?” or even, “Does this rash look contagious?” After a while he said, “Hey why don’t you post on my blog? That way you can document your learning, and I can help you as well as anyone else who reads it.” That’s our Matt, always looking to help others.

Well I said, “Hey that sounds keen!” Or something like that, and now you get to watch Matt and me transform the caterpillar that is my extremely limited and rudimentary coding knowledge into a beautiful coding butterfly. I hope watching me struggle through coding is informative or, at the very least, entertaining for you.

Have a safe weekend! (TC)

Feb 7, 2013
Categories: Development, PHP, and Web
Tags: PHP, Wordpress, and WP

First, I wanted to welcome a new contributor to the site, Tucker Combs! Tucker is, by profession, a marketing/advertiser. With that said I know that, from our days together in college, he has always had passion for technology and what developers love, creating. I want to welcome and thank him for joining in on helping us solve some of the struggles we go through learning technologies.

Now, on to the meat and potatoes of today’s post. Recently, the theme that I have based my site off (Living Journal) updated. While that wouldn’t have been a big deal because I incorrectly made my child theme by just copy-pasting the entire theme, I wanted the latest and greatest. So I attempted to update and move to a correctly made child theme. Needless to say I was left with the ‘White Screen of Death’ for a WP-Admin screen. After lots of reworking I was able to recover by starting from scratch with a local copy. However, I am dissatisfied with some things in this theme as a whole, one of which being the lack of ability to add a Google Author tag to the byline (the date posted by ‘name’ above these posts). So I looked through the function.php file to find out what exactly I am doing and how it does its thing. Well, here is what I found:

if ( ! function_exists( 'livingjournal_posted_on' ) ) :
 * Prints HTML with meta information for the current post-date/time and author.
function livingjournal_posted_on() {
	printf( __( '<span class="sep">Posted on </span>
<a href="%1$s" title="%2$s" rel="bookmark"><time class="entry-date" datetime="%3$s">%4$s</time></a>
<span class="byline"> <span class="sep"> by </span>
<span class="author vcard"><a class="url fn n" href="%5$s" title="%6$s" rel="author">%7$s</a></span>
</span>', 'living-journal' ),
		esc_url( get_permalink() ),
		esc_attr( get_the_time() ),
		esc_attr( get_the_date( 'c' ) ),
		esc_html( get_the_date() ),
		esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ),
		esc_attr( sprintf( __( 'View all posts by %s', 'living-journal' ), get_the_author() ) ),
		esc_html( get_the_author() )

So there is a plus right away:

if ( ! function_exists( 'livingjournal_posted_on' ) ) : 

!! That means that because I now have a correctly made child theme my function.php file loads BEFORE the parent theme and I can overwrite the function! So I took it on myself to make it happen and here is how:

function livingjournal_posted_on() {
  printf( __( '<span class="sep">Posted on </span>
<a href="%1$s" title="%2$s" rel="bookmark"><time class="entry-date" datetime="%3$s">%4$s</time></a>
<span class="byline"> <span class="sep"> by </span>
<span class="author vcard"><a class="url fn n" href="%5$s" title="%6$s" rel="author">%7$s</a></span>
<span> : <a class="url fn n" href="%8$s" title="%9$s" rel="me" target="_blank">Google+</a></span>
</span>', 'living-journal' ),
	  esc_url( get_permalink() ),
	  esc_attr( get_the_time() ),
	  esc_attr( get_the_date( 'c' ) ),
	  esc_html( get_the_date() ),
	  esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ),
	  esc_attr( sprintf( __( 'View all posts by %s', 'living-journal' ), get_the_author() ) ),
	  esc_html( get_the_author() ),
	  esc_url( get_the_author_meta( 'gplus_author_url' ) ),
    esc_attr( sprintf( __( 'Find %s on Google+', 'living-journal' ), get_the_author() ) )

So that is nearly the same as the original minus a little tweak; the last two params and the Google+ link in the last span. To explain this we can expand on printf and php arrays a touch. printf is fairly straight forward in that it takes a list of objects, we will focus on just strings for now. So an example would be:

printf("%1$s %2$s", 'Knock Knock', 'Who\'s there?');

Piece by piece:

Note ” are not the same as ‘. Double quotes get used for evaluating params


is asking for: **%1 param** **of type $** **string s**. The second would be self-explanatory from there.

'Knock Knock'

is the string literal, similar to ‘Who\’s there?’ but because we have a single quote within a single quote we must ‘escape’ it with a backslash. The only other explanation you may need is that I use a google plus authorship plugin to add a ‘gplus_author_url’ to the author meta data. As a last note most author data have two methods associated to them:




. If you want to simply print the value to the page the_author_object works but you must use the getter if you’d like to use it inside the code. Thanks for reading and hopefully I helped, (ME)

Jan 8, 2013
Categories: Java and Web

So, recently, I undertook the task of writing a quick project. From the ground up. I decided on a tech stack that I was familiar with and fit the criteria that was set forth by the project; struts2, hibernate, maven, java. Setup was fairly simple due to my knowledge of maven, but that is not what you are here to learn.

Hibernate So the first thing I did was setup a HibernateUtils class to ensure I always had an open session to access the database.

Note: this class is fairly easy to find with a google search.

public class HibernateUtils {

  private static final SessionFactory s_sessionFactory = buildSessionFactory();

   * Builds a hibernate session factory for interacting with the db
   * @return the session factory
  private static SessionFactory buildSessionFactory() {
    try {
      // Create the SessionFactory from hibernate.cfg.xml
      return new Configuration().configure().buildSessionFactory();
    } catch (Throwable ex) {
      // Make sure you log the exception, as it might be swallowed
      System.err.println("Initial SessionFactory creation failed." + ex);
      throw new ExceptionInInitializerError(ex);

   * @return
  public static SessionFactory getSessionFactory() {
    return s_sessionFactory;

Now is the part you were waiting for, parameters.

So lets say I have a list of objects with names in my DB. I want object with name “world”. The **_INCORRECT</strong>_ would be as follows:


Session session = null;
session = HibernateUtils.getSessionFactory().openSession();
String hqlQuery = "FROM " + MyObject.class.getName() + " obj WHERE obj.name = '" + name + "'";
returnedObjects =  (List<MyObject>) session.createQuery(hqlQuery).list();


Clearly this is wrong, we should NEVER use any input possibility as a parameter in a query directly. We could have all sorts of funky characters that could break our query (e.g. *, ‘, “, &, ;, etc.). So what ever will we do? Simple, we use it as the built in setParameter in hibernate!

Session session = null;
session = HibernateUtils.getSessionFactory().openSession();
String hqlQuery = "FROM " + MyObject.class.getName() + " obj WHERE obj.name = :name";
List<MyObject> returnedObjects = (List<MyObject>) session.createQuery(hqlQuery).setParameter("name", name).list();

This is just one example of how to use this parameter setup, there are several more. We can explicitly tell hibernate what type we have like this:

List<MyObject> returnedObjects = (List<MyObject>) session.createQuery(hqlQuery).setString("name", name).list();

We can also have multiple parameters like if we want all active objects with name “world” (indexed by 0):

String hqlQuery = "FROM " + MyObject.class.getName() + " obj WHERE obj.name = ? and obj.active = ?";
List<MyObject> returnedObjects = 
  (List<MyObject>) session.createQuery(hqlQuery).setParameter(0, name).setParameter(1, true).list();

Even better, we can use objects to match! This is extremely useful if you have a large object with many parameters being set.

MyObject searchObject = new MyObject();
String hqlQuery = "FROM " + MyObject.class.getName() +
  " obj WHERE obj.name = :searchObj and obj.active = :searchObj";
List<MyObject> returnedObjects = 
  (List<MyObject>) session.createQuery(hqlQuery).setParameter("searchObj", searchObject).list();

Needless to say, you should always choose some type of parametrization when writing HQL. I prefer Name Parameters (the :theValue) for clarity and ease of use.

Dec 26, 2012
Categories: Development, Git, and Linux
Tags: aliases and Git

So, it has been a while but I have been working hard so we all know that you can’t really blame me for that!

So today I want to run down my git configuration and how i make my life easier by using aliases… which if you haven’t guessed yet, I LOVE!

So here we go:

This is all in my ~/.gitconfig file

(Notes will be denoted by ‘##’ and are meant to explain the NEXT line)

  name = Matthew Erickson
  email = matt@matterickson.me
  branch = auto
  diff = auto
  interactive = auto
  status = auto
  ##Shows all aliases
  aliases = !git config --get-regexp 'alias.*' | colrm 1 6 | sed 's/[ ]/ = /'
  ## Pretty log (don't forget a -n XX to only show XX amount of commits)
  lg = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset 
%s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative
  ## Formats a patch without using whitespace
  format-patch = format-patch -w
  ## Same as above but for term diffs
  diff = diff -w
  ## Quick status
  st = status
  ## Quick rebase
  rb = rebase
  ## Creates a new branch tracking the current one
  bk = checkout --track -b
  ## Quick branch
  br = branch
  ## Quick Checkout
  ck = checkout
  ## Quick pull w/rebase
  puller = pull --rebase
  ##is supposed to push for the branch refs
  pushup = "!f() { git push -u ${1:-origin} HEAD:`git config branch.
$(git name-rev --name-only HEAD).merge | sed -e 's@refs/heads/@refs/for/@'`; }; f"
  ##fetch and rebase on master
  up = !git fetch origin && git rebase origin/master
  ## Shows the top contributers and how many commits they have w/o merges
  who = shortlog -n -s --no-merges
  ## Cleans up git configs (should not be done while in a working state)
  cleanup = !git remote prune origin && git gc && git clean -dfx && git stash clear
  ## Shows new info from last command (usually after a git pull or git puller)
  new = !sh -c 'git log $1@{1}..$1@{0} "$@"'
  ## Shows branch tracking information
  track = "!f() { ([ $# -eq 2 ] && ( echo \"Setting tracking for branch \" $1 \" -> \" $2;
git branch --set-upstream $1 $2; ) || ( git for-each-ref --format=\"local: %(refname:short) 
remote: %(upstream:short)\" refs/heads && echo --Remotes && git remote -v)); }; f"

Nov 18, 2012
Categories: Development, Featured, HTML5/CSS3, and Web
Tags: galaga, game, and html5

This project is also available on


Special thanks go out to:

Weapon Upgrades: SeongJae Park

Sound Effect: Haebin Yoon

Recover The Original Motion: JongYoon Lim

Boss Stage: Lee WonJae

Nov 10, 2012
Categories: Development, HTML5/CSS3, and Web
Tags: game, html5, and pong

Unsupported Browser
Click to start…

Player 1 (Left Paddle): W for up, S for down Player 2 (Right Paddle): Up arrow and Down arrow

This project is also available on


Oct 10, 2012
Categories: Business and Development

As many of us do as software developers/engineers/hackers I have been to, answered and asked my share of questions on stackoverflow in my career. They also now have an invite careers section of their site. I joined recently and have since completed my profile to a point where they see fit to grant me some invites.

Not really much else to say but: Accept Careers 2.0 invite =)

Oct 10, 2012
Categories: Development

Wednesday September 12th. I had 2 meetings this day, one was with the tech lead of the project to make sure I knew what I was going to be doing and a broad spectrum overview of the goal for the next release, the second was with the PM (project manager) to explain the timeline with myself and the other engineer and lay out our project dev plan.

The plan that was laid out for us gave us ~4 weeks until release. I thought well that should be a pretty good time line based on what I’ve done so far. Well Thursday came and something happened to me similar to my college experiences (on occasion) I had supernova focus. Much to the surprise of the PM and my coworker on the project with me, I finished not only the API but also the full service and parser that is not going to test for 4 more weeks! O.o


Oct 10, 2012
Categories: Development

September 11th

Let me start off this post by telling you a short story of my family and the date. Today is September 11th, 2012. Eleven years ago today, the United States had a terrible event occur by extremists from a religious group. I could go into my thoughts on this but no one actually wants to hear that, and that is not why you are here so onto the story.

I have three sisters, the middle, in age, of the three had a child when she was sixteen years old. When the child was born my uncle and his wife decided to adopt her. Fast forward a few years, my uncle was working as a radio show host in the south tower of the world trade center and his wife worked as a video editor (I believe). Well on the night of September 10th, 2001 Taylor, the little girl whom they adopted, came down with a stomach bug and was not able to go to daycare. This meant one of her parents wasn’t able to go to work, my uncle drew the short straw and stayed home. Later that morning the tower that he would have been working in fell. . .

These are the problems that we should care about and these are the problems that matter. Not the one I will do a short bit of complaining about here:

Actual Post about Software Project Moves

On September 1st I left on my vacation back to Minnesota for my fathers wedding. I left work and knew my supervisor was going to be in charge of any bugs or issues that arose from my work that I had been doing over the last few weeks. I received a few emails with questions and comments while I was out of the office but nothing that a sentence or two couldn’t explain. Well, this morning I came into the office with a cup of coffee in my hand and a smile on my face ready to get back to work to be met with some news that, as of this point in the day I am still unsure of the polarity, good or bad. I have been reassigned to a different project and will be changing supervisors.

I look forward to the new challenges that await me on this new project and wish my past team good luck (although I will most likely still pester them as I always have).

Oct 10, 2012
Categories: Business

Staying in touch with old coworkers and employers

A few days back I was contacted by an old coworker that I used to work with at a company who, since my departure, had taken a turn for the worse and closed their doors. Well, at least that is the last I had heard. One of the founding investors was trying to revive the idea/company and wanted to bring me back on as a consultant. I was thrilled at the idea to help out and said I would help in any way I could.

Keep Any Documentation that is Legally available to you

During this phone conversation I have/was referring to many of the documents that I had written during my tenure at the company to remind myself of the ideas and the processes that I was building. These documents have proven to be invaluble to both myself and the now newly running company


  • Resume boosters: what company will look poorly on you helping out a past employer (no need to mention compensation)
  • References: the better info you share the better they will think about you later, even if it is just a bar talk with someone you will some day meet…
  • Care: where you work and who you work for should matter to you even AFTER you work there
  • Money: most of the time they will pay you well

Oct 10, 2012
Categories: Development and Java
Tags: business rules, drools, java, and jboss

So, today, again, I was working with jboss’ drools engine writing some more rules. My rule went something like this:

rule "Do stuff"
    $obj : Class(name == "")
    $obj.somethingElse.setValue("More Stuff")//I did more stuff

So according to the docs this should work fine….. well mine is broken. And non the less the //I did more stuff is what broke it. For reference, I am using Drools 5.1.0.M1, which, I know, is NOT the docs that I am pointing you to but I would assume that commenting should be the same!


Oct 10, 2012
Categories: Linux and OS
Tags: bash, linux, terminal, and terminal title

So I was trying to pull a log file from a sys admin at my work’s computer the other day with scp.

Fail. Fail. Fail. Fail. Have a linux admin try from my computer under his account worked fine. Turns out that something in my .bashrc was causing output when logged into another computer and breaking scp but doesn’t break ssh… Go figure?!? Anyway, passed that I found a fairly sweet command that I now have living in my .bashrc file:

trap 'echo -e "\e]0;$BASH_COMMAND\007"' DEBUG

Still working out exactly how it is doing what it is doing but I know the outcome: When I run a command in my terminal, the title of that terminal/tab changes to the command I just ran! Very useful when you are tailing 5 different log files and just want to find that dang web-services log without having to actually read what the log is telling you!

Oct 10, 2012
Categories: Web
Tags: ajax, autocomplete, custom object, javascript, jquery, jquery-ui, and json

Back story

So as of now you should probably already know what jquery is (javascript wrapper library to make it significantly easier to deal with and read) also JSON objects (much like maps [key: value]) and ajax (ajax wiki -_-). Well in this tutorial we are going to slam these all together.

Technicals and Code

The code below will give you a straight forward look at a jQuery autocomplete text box. It is an input box and some jquery code to setup the box. Super simple… moving on.

    source: {'abc','def','ghi'....}
  <input id="name">

Next we will only focus on the jquery aspect and add the ajax calls to our php/struts/asp whatever method

jQuery("#name").autocomplete( {
 source: function (request, response) {
     url: 'ENTER YOUR URL HERE',
     data: {
       searchTerm: request.term
       //'searchTerm' is what you are going to pull from the request
     type: "POST",
     success: function(data) {
   });//end ajax
 }//end source of autocomplete

This is still fairly straight forward. Once the custom JSON gets thrown into this mix is when we really start to feel like we are doing something. Lets start by looking at the JSON we build to send BACK to the page so we know what kind of data we are dealing with, then we can get rid of the ‘GREAT SUCCESS’ comment

JSONArray array = new JSONArray();
JSONObject object = null;
for (CustomObj obj : m_objects) {
  object = new JSONObject();
  object.put("name", obj.getName());
  object.put("value", obj.getValue());
  object.put("year", obj.getYear());
//end Java
//skipping autocomplete start and moving straight to success callback
success: function(data) {//data is the object that is returned
  response($.map(data, function(el) {
  //el is an element within the data object also known as our custom json object
    return {
      name: el.name,//corresponds with json object built above
      value: el.value,
      year: el.year
//end jQuery

The $.map is the function that really does the magic hear. It treats the response as a map and makes the new objects to return. In the return we build the object from the corresponding java JSON we built. We are mostly there now. All we have to do is tell jQuery what it should do with the values, since, by default it expects a label and a value.

jQuery("#name").autocomplete( {
}).data("autocomplete")._renderItem = function(ul, item) {
  return $("<li>")
    .data("item.autocomplete", item)
    .append("<a>" + item.name + "</a>")

This is a fairly straightforward function. It takes the data from the autocomplete._rederItem function and replaces it with our own function. The item in this case, referred to in the with item.name, the .name refers to the object we created in the success callback. You could use anything you desired there (in our example here we can use .name, .value, or .year).

Hopefully this can help someone some time, thanks for reading

Oct 10, 2012
Categories: Development
Tags: eclipse, hacking, hot-key, quick, and typing

Note: This information is meant to be generic to Eclipse as a whole but for reference I run ubuntu 10 and eclipse Helios Service Release 2

Eclipse In the company I work for we use

Eclipse as our primary IDE for development. Eclipse is a project by “The Eclipse Foundation”. It is an IDE that has MANY, many plug-ins that range from official ones such as the JBoss plugin to make using jboss technologies like drools rules easier to work with to from within eclipse to AnyEdit which is something I use to remove trailing spaces and tabs from my code (for checkstyle purposes)

Hot-Keys By using Eclipse efficiently you can decrease the amount of time you spend on tedious things and increase your productivity significantly Firstly, moving quickly without letting your hands leave the keyboard can speed you up more than you would expect. So lets look at some of those hot-keys, most of which are built into OS’.

Ctrl+c :copy
Ctrl+v :paste
Ctrl+x :cut
Ctrl+z :undo
Ctrl+y :redo
Ctrl+(arrow key [left or right]) 
will move the corresponding direction one word, if you are using programming standard camel-case variables this will move you one word and stop at the beginning or end of the word you are moving over.
Shift+(arrow key [left or right]) 
will move the corresponding direction one space and highlight the space you moved over.
Ctrl+Shift+(arrow key [left or right]) 
will work as you might expect, moving one word the corresponding direction AND highlight the word.
will open an ‘Open Resource’ window that allows you to quickly search your workspace. Inside of this search you can use ‘*’ to get a wildcard for any string forward or backward or ‘?’ for any char. Example: applicationContext-ws-stuff.xml could be found by searching app*con*ws-stuff* or even shorter as app*con*stuff* may give you a short list. Again if you are using camel-case you can use just the FIRST-LETTER of the word. Example: java file: TeacherToStudent.java could be found by typing TTS.

will open an ‘Open by Type’ window that works essentially the same as the Open Resource window
Ctrl+Shift+m and Ctrl+Shift+o 
these two hot-keys are nearly the same, +m will add any existing imports that are missing and +o will add any missing ones and then organize them based on how you have your code-style defined
a powerful key combo. This is the variable or method refactor tool in hot-key form!
another very useful hot-key this will open a small search window for the class you are currently in, you can search for variables or methods quickly and reach them even faster!
Shift+(home or end) 
this will highlight the space from your cursor (where ever it may be) to the end or beginning of the LINE you are on.
will correct the indentation of the file, if you have a line or section of code highlighted it will respect this highlighting and only correct indentation of THAT section or line of code!
will delete the line you are on, again if you have a section of code or space highlighted ALL of it will be deleted
An honorable mention, although not a hot-key, is the
'Replace with Local History' and 'Compare with Local History'
menu items. There have been many times when I changed a significant amount of code only to come back the next day to realize that everything is broken and I have no idea what the method/class I changed was supposed to do. Well this is where your butt will be saved. Right Click the class you changed->Compare/Replace With->Local History will bring up a new menu that will show you past changes (saying it has the history still stored). This has saved my butt in the past and I’m sure it will again in the future. I know a lot of these seem like they may be useless and trivial clicks but once you get used to using them you will be able to move so quickly through your files and eclipse that you will never fall out of ‘programming mode’ having to copy, paste things around a file.

Oct 10, 2012
Categories: Java
Tags: business rules, drools, java, and tutorial

So, I have had the luxury of working with just under a butt load of technologies at in my young software engineering career. One that I have enjoyed more than others has been Jboss’ own Drools Rules Engine. This engine allows you to quickly and “easily” integrate complex business rules into your application without muddling them into your actual application layer.

So the drools syntax can be a bit confusing at first glance but after you write a few simple rules and see how they work it is cake!
rule "This is a short description of the rule"
$derp : MyObject(name == "Matt")
Lets break that down line by line:
Line 1: rule “blah blah blah…” – This explains what the rule does, it doesn’t actually have to explain anything but must be unique to this rules engine or it will bomb out.
Line 2:when – indicates this is the left hand side of the rule (until we reach a then statement).
Line 3:$derp : MyObject(name == “Matt”) – This is actually where the rule’s business logic lives for determining if we should run the right hand side logic on this object. This line is VERY important. The ‘$variableName’ notation is common in drools but is notnecessarily, we can just use ‘derp’ as a variable but you can see why we don’t, forreadabilitysake. The ‘:’ item is a MUST, this is actually what assigns the object to the variable when the rules match. This is the part of drools that is kinda Quirky, if a new line is added. Say we insert a line AFTER line 3, we’ll call it 4a (for line 4 alternative):
MyObject(age > 23)
This line will ask the very same ‘MyObject’ if it ALSO has an age attribute that is greater than 23.
Before we move on I would like to look at a few ways this line can be modified to have the same behavior. Lets remove line 4a and append that logic to line 3:
$derp : MyObject(name == "Matt" && age > 23)
Simple enough. Here is another:
$derp : MyObject(name == "Matt")
and MyObject(age > 23)
This is nearly identical to 4a but with more explicit definition of what we want out of this rule. Drools, by default, treats new lines in the left hand side of a rule as ‘AND’ statements. So this can be left out or added as you see fit, I would pick one and stick with it though. Similarly we can change the behavior with an ‘||’ and an ‘or’. Ex.
$derp : MyObject(name == "Matt" ||age > 23)
$derp : MyObject(name == "Matt")
or MyObject(age > 23)
These are fairly self explanatory after learning how the and works.
Line 4:then – I’m sure by now you can guess what this does, indicates that if all left hand side arguments match: do this stuff.
Line 5:$derp.lastName.setValue(“Erickson”) – This is where the right hand side runs if all the left hand side arguments match. The ‘$derp’, here, is the same as the object that we set in the left hand side of the rule, this means we already have values in some of the object and don’t need to reset them… unless that is what the rules should do, of course. ‘.lastName’ is anattributefrom the MyObject type with a ‘setValue’ method that takes in a String.
Line 6: end – Fine!
Now that you have ‘read’ this you can probably go hack away at a keyboard and write something that may resemble a drools rule. But keep in mind; drools does not care the order in which you write your rules. It runs them much like a shotgun, all at once. So make sure you do not have any conflicting business rules!
Things I didn’t cover that you should probably read further into: integration, knowledgeBase class, and most likely much much more but this was mostly from memory.

Oct 10, 2012
Categories: Web
Tags: auto-validation, invalid.fieldvalue, and struts

Struts 2, a pull a rabbit out of your hat type magical technology, is used in many web app tech stacks.

struts rabbit

I found a very interesting tid bit in this technology that I failed to find a direct answer to on the infamous interwebs: Invalid Field Value for Field "XXXXXXXX" This error is auto generated by struts when a data conversion error occurs such as String -> Date. Not to fear! This error can be customized EASILY if you are using message property files! Just add one line: invalid.fieldvalue.XXXXXX (where XXXXXX is the field name)!

Post one done!