Categories Tags


Holy smokes, it seems like just yesterday that I purchased IcePets.  But alas, it is not.  Today, my anniversary of owning, I come to you humbled by the overall tenacity of each and every one of the IcePets members.  You could have bailed a while ago, back when the site started becoming fairly static, but you didn't!  You had faith in us, and a love of the site which I am in awe of.  I know it has been several years (3 or more) since any huge features were added to the site, and that a battle system was promised very early on in the development.  However, each day I return to the forums happy because I see "10 unread" messages.  From the outside it may not seem like a lot, but it helps to refuel my passion for the project on the days that I start working on it and feel exhausted just thinking about all of the work that there is still to be done on the recode before we can actually have decent growth.

I don't know about you, but every day when I check on Virtual Pet Directory, I always look to see if the total active user count has gone up or down from the day, or days before.  I'm happy to say that over the two years that we have been tracking the user activity on there, it has remained around the same.  We have had some spikes, 257, and we have had our dips, 90, but now we currently stand 8 users more than we had two years ago, 118.  The total number of users isn't anywhere near our competition, but that doesn't matter.  From the outside, it would appear as though we are a site that is hanging on by a thread.  But that is not how I see it.  I personally see it as a site which is currently in a holding pattern, anxiously awaiting the recode which has been in the works for a little while now.

The biggest thing that amazes me about the members is how much of a community it is.  New members are welcomed in with open arms, old members are welcomed back with excitement as if a long lost friend has recently returned.  And most importantly to me, tell us that IcePets is a community where they feel safe place for them to post even if they are normally a quiet individual.  To me, this speaks wonders of the community.  Although small, we are a powerful community who just love to hang out and play together.

I would like to take this opportunity to also thank all of the staff who have given up countless hours of their personal time to help us grow.  I know that I haven't always been the easiest person to deal with, but we got through it and are stronger for it.  But, I will openly admit, if it wasn't for you, the site would likely be dead despite all I would have tried.  I can code, I can organize and on occasion, I can even chat on the forums.  But the one thing I cannot do is use your countless years of experience with the community to really understand what it is the users want.  You guys make my work look easy.  Throughout the years, some faces have changed.  We have lost some powerful members from the staff team due to real life commitments, but just when things look gloomiest, a different staff member steps up and takes the reigns.  For staff members who have had to leave the team, I am honoured to have worked with you.  And for the staff members who are still working with us, thank you for your continued support, it is greatly appreciated.

Thank you all for your continued support of IcePets.  If we band together and stay strong, we can make it through the current drought, and reach the promised land which is otherwise known as "the recode".

Thank you for reading.

Posted in icepets


My anniversary for owning is coming up fairly soon (August 8th) and all I can say is wow has it ever been a ride so far.

I had been working as a freelancer with them for a little over a year, so I knew exactly what I was getting into.  Some very bad legacy code which was pieced together (and still holding fairly strong) with super glue and duct tape.  When going through the code, I noticed numerous back doors into the site that a previous programmer had built in for "security reasons".  AKA, in case they were banned, they would be able to make their way back into the site.  Those were patched, and the user was banned.  But here I was, owning a site and working with a bunch of people who I now call my friends with no idea the full vision.

So, my first order of duty was to bring the recode up into the foreground because the site wasn't really moving anywhere fast because I knew if this site was to be anything, the recode would bring a definite life to it.

Laravel was just breaking through the headlines on the PHP front when I had started working on the site.  But not only that, I was just working through the framework at the time and was entirely overwelmed!  There was so much going on, I knew it was all good and neat but just so much stuff!  But, I managed to power through it.  I started building the site up with Laravel 3.  A month later I heard that Laravel 4 was getting ready to be launched and it had some fairly substantial changes in it (aka - don't bother even trying to upgrade, just re-implement (copy and paste code) and build it up that way.

I was a little hesitant, but decided it had to be for the best.  That was when I was first introduced to "composer".  I had always dreamed of a way to easily incorporate other open source work into my projects, but never really knew a way.  This in itself was confusing!  Finally I managed my way through that hump and then came the next releases of Laravel (4.1 and 4.2).  These were fairly big.  By this point in time, I had already really started to focus on coding lots of the features. There were things I felt were clunky but it worked.  But something felt wrong.

When Laravel 5 came around, I decided to revisit the entire framework that I had thrown together to build IcePets version 2 (yes - a bit of a framework on top of the framework).  So, I started from scratch again.  This was ok because this time I knew it felt cleaner.

The last two years have been such a learning experience for me both technically and with leadership skills.  Looking back when I had originally thought about my very lofty goal of finishing the IcePets recode in a year, I realize how oblivious I was.  And, to be honest, I'm glad I didn't make that personal goal.  The technical learnings that I have picked up through the multiple iterations through the code, has slowed down progress on the site, but it has also opened my mind to way more options which I never even thought was possible.

I would like to say thank you to both the staff members as well as all of our loyal members who stick with us through this recode.  The best thing about the recode to me is the excitement it brings to me each and every time I think about it.  There are so many opportunities for us to morph the site into something substantially better than it currenlty is.  Once the recode is done, I think you will love the site and it will be a great place for all of us to bond as a community!

Thanks for reading!

Posted in icepets


I've heard and seen the following so many times.  "Why should I use a framework when I can just code my own framework?".  Or, "using a framework slows down the application, and I need it to be speedy.  So I need to use raw PHP".  Yes, those two statements are 100% accurate.  You can build your own framework, and technically yes your code would hypothetically speaking be faster if you wrote barebones PHP.  

However, script speed isn't the only thing you should be worried about!

There are several PHP frameworks out there that are being fairly actively worked on. Let me ask you a question.  What do you think would work better?  An application/framework that is being developed by one individual who has a certain set of skills?  Or, would you rather use a framework that is being actively worked on by a bunch of software developers around the world who are actively talking about ways to improve?

To me, the answer is simple.  Use the framework.  I have been developing software for over 10 years now, and I still find myself learning from those around me.  Be it through code reviews from co-workers, or from merge requests and issues logged from other people on GitHub.  Yes, I have a fair bit of knowledge but everyone picks up things differently.  Could I make a decent framework?  Possibly, would it benefit from other people's input?  Probably.

The fact that something is "open source" doesn't mean that there is nobody monitoring check ins and updates for it.  Take Laravel for example.  When I wrote this post, there is a total of 294 people who have contributed fixes to the framework.  However, they have core maintainers.  It is these people (who are normally core to the project and have proven themselves already), that are reviewing every check in that someone does and making sure it meets the standards that they wish to enforce.

"I like to know everything about what is going on in the application".  My answer to that is who cares?  Do you know how the operating system that your application is running on works?  Do you know the inner workings of PHP converts the code you write to code that the computer can understand?  Likely your answer to both of these is "no", so why do you need to know each and every inner working of the application too?  Yes, it helps when you are trying to design and write the code (to some degree), but it shouldn't change your mind.  Treat the code that they give you like an extension on the PHP language.  But more than that, let it help guide you on what some best practices are / may be when you actually start building your application.

"It is all written by other people, so there could be bugs."  Yes, this is true.  Just like PHP can have bugs.  Code has bugs no matter where you get it from so don't let that be a deterrent.  Is your code 100% bug-free?  Probably not.  So why not let others handle the core of the framework while you reap the benefits when they have bug fixes available?  Lots of frameworks use unit tests in order to test and validate each "unit of work", so they work on proving their code works.  And if a bug is found, more unit tests can be added to ensure that they don't crop up again.

If you write your own framework, are you able to search Google for your specific issues that you have?  Likely not because it is fairly hard to give enough information if you built a framework because you need flatten it out as much as possible.  With a framework, you are able to Google the framework name you are using and your particular question.  Or, post on the framework's forums.  Both places will likely get you a much better answer and, depending on how active the community is you could have a response in a matter of minutes.  Sure there are moving parts, but there are also more people willing to help to lubricate them.  So why not?

"But there is so much to learn if I use a framework". Yes, yes there is. Learning curves aren't necessarily a bad thing. They are a way that you become a much better and much more rounded developer. They help you to flex to expand what you know which in turn allows you to make better decisions going forward.

"What do frameworks buy me?" Most frameworks come with at minimum an easy way to interact with your database. By profession, I am a database developer. So I don't mind writing SQL queries. But if I'm given the option to have them auto-generated based on a object, why wouldn't I take it? It's 1 less thing that I have to manually do. It's these small efficiencies you gain through the development of an application that allow you to:

  1. Create the site quicker
  2. Make the site more robust
  3. Make most more easily maintainable code

Not writing SQL queries isn't enough for you? Then how about the fact that for the most part, the use of a framework will not necessarily force best practices on you. But, they do their best to help push you in the right direction! I've seen so many sites which have code that is a nightmare because essentially every layer is tangled together. You have the database being directly summoned by the front end and huge "if-then-else" statements that start forcing more and more levels of indentation which can get confusing. I'm not saying you can't do this in a framework. But, after using it a bit, you will quickly realize that it is not the right thing to do. The "Model View Controller" architecture has been around since the late 1970s and is still a prominent setup. Because it pushes you to ensure that every section does it's own work and that is all.

Sure frameworks can cause an extra little bit of processing time in your application, but that is nothing a little extra RAM, a better CPU or even, an SSD cannot solve. If you are able to determine that those are your bottlenecks that is. For the most part we are talking milliseconds which isn't much time at all. Your system could be processing someone else's request at that time. However, you will make up for it in the amount of code throughput you can have as you work on your application.

If you ask me why do I use a pre-existing framework, the answer is simple:

  1. Support of a Community - I trust the developers around the world to come up with solid frameworks and the communities that back them.
  2. Time Efficiencies - I don't like to write a lot of the boilerplate code that you need to when writing from scratch because they take time and don't provide a lot of value.  Let the "magic" happen.
  3. Code Maintainability - I want my code to be maintainable in the future. Yes, it is possible outside of a framework. However, it is a lot harder.
  4. Learning - By reading through the code that exists in the framework, I am able to pick up a few "neat tricks"

Hopefully this helps to guide you in your decision of whether or not to use a pre-existing framework or to make your own a little bit easier!

Posted in programming


So, I was doing a consultation this week regarding some database work and got to hear a little horror story from the owner of a site.

Please Note: The owner of the site has next to no programming experience.   The only experience they have is dealing with the code that they were originally sold.

The owner of the site contacted me because they felt there had to be another way of handling this particular situation.  What the problem boiled down to was the fact that they had 1 large table that had more than 256 columns in it!  And better yet, the columns that were actually needed depended 100% on the "earlier" content of the table (i.e. the first few columns).  To me, I immediately saw this table and was appalled.  I thought to myself, well this obviously needs to be a mapping table, and treated as such.

After talking with the owner for a bit, apparently this was their first inkling too.  However, the programmer "swore up and down that it could only be done this way".  Hearing that saddened me a little.

Now, you maybe wondering why this blog post is called "My Way or the Highway".  That's because one thing that I have learned in my years of programming is the fact that there truly is no "one right answer".  In fact, every time I work on a programming problem, I myself come up with 3-5 alternatives before narrowing the problem down into which solution I'm going to take.

In order to develop applications, you need to take a few things into consideration and most importantly, leave the ego at the front door.  In my opinion, this holds true for more than just programming exercises.  Someone else to bounce ideas off of may help you see the problem in a way that you never even thought about before which could lead to a better overall application.

After peering through the code a bit more, it was clear to me that the reason why "it was the only way this could be done", was because they wanted to be lazy when handling access in other pieces of code.  All they really needed to do in order to make this mess manageable was to wrap the database call in some sort of data access layer.  When they do that, they would be able to handle any updates/inserts that are needed and still send back all of the data that was required to process the data instead of that and then so much more.

In short, when programming, try your best to keep an open mind and focus on other alternatives and please don't take the solution that "is done fastest" because that normally leads to pain points and wasted resources in the future.

Had this programmer done what the owner, who was speaking from what logically made sense to them, listened to them and re-evaluated their statement, then I wouldn't have likely needed to be brought into this discussion at all.

I've been programming for years now and I still realize that I know just a tiny bit of the broad spectrum that coding provides.  So, that is why I always ask others for their opinions and leave my ego at the door because at the end of the day, I want the best product out there.  Not a decent product that is filled with patches that is being held together with bandaids and chewing gum.  You only get that solid result from reaching into the depths of programming experiences both that you had, and that everyone else has had in order to get the best results!

Thanks for reading!

Posted in programming


Today I needed to figure out how big a bunch of tables were in a database (we were in the process of pruning it and wanted to spend the correct amount only pruning what was necessary).  Luckily this is actually fairly straight forward!

-- DB size.
EXEC sp_spaceused
-- Table row counts and sizes.
    [name] NVARCHAR(128),
    [ROWS] CHAR(11),
    reserved VARCHAR(18), 
    DATA VARCHAR(18), 
    index_size VARCHAR(18),
    unused VARCHAR(18)
INSERT #t EXEC sp_msForEachTable 'EXEC sp_spaceused ''?''' 
FROM   #t
-- # of rows.
FROM   #t

Hope this helps you as much as it helped me!


Posted in sql-server



Capitalizing the first character of each word in a string (i.e. “the final countdown” → “The Final Countdown”).



C# has a built-in function for this. Its called ‘toTitleCase’, hidden deep within the System.Globalization namespace.

So how do you use it?

using System.Globalization;
// Get the instance of the TextInfo class to use to (no constructor), comes from the current thread
TextInfo info = (System.Threading.Thread.CurrentThread.CurrentCulture).TextInfo;
string sample = "hello world";
// Print to console the title case
// Outputs: Hello World

The ‘ToTitleCase’ function returns an instance of a string which will have all of the first characters in words changed to upper case, and leaves the rest of the text as is. This means that if a word is in all capital letters it will remain that way. A simple work around for this is to call the string object’s ‘ToLower’ function before we send the string into the ‘ToTitleCase’ function.

For example,

using System.Globalization;
// Get the instance of the TextInfo class to use to (no constructor), comes from the current thread
TextInfo info = (System.Threading.Thread.CurrentThread.CurrentCulture).TextInfo;
string sample = "HELLO world";
// Print to console the title case
// Emits: HELLO World
// Pre-lowercase everything
// Emits: Hello World


The PHP version of this function is a fair bit easier to get to.  PHP’s function is called ‘ucwords’.  However, similar to the C# version you should always have the string sent in in lower case if you want it to only make the first character of each word upper case (it only changes the first character and doesn’t touch the others).

// Outputs: The Final Countdown
echo ucwords('the final countdown');

Posted in programming


I was implementing an image resizer and I kept running into a problem where I kept getting error messages saying that the image file was in use even after I disposed of the object in memory (the last step was to remove the unresized image).

Calling object.Dispose() is just a suggestion to say “whenever you want, we don’t need this in memory anymore”. However, because it doesn’t get rid of it immediately, meaning that it is still being referenced which means that the file won’t be able to be deleted immediately.

In order to get around this, you need to call the garbage collector yourself to force the application to get rid of the object from memory.

The code:

string dest = @"C:\";
FileInfo imageFile = new FileInfo(file);
Image image = ResizeImage(Image.FromFile(file),size);
// Save the file to the file system
SaveAsJpeg(image, dest + imageFile.Name, 100);
// We don't need the image in memory any more (suggest it to be deleted)
// Call the garbage collector
// Delete the old file

Posted in php