Outsourcing, why should you? Part 1.

Filed under: Web Development — rasim

outsourcingA few years ago I was working in a custom software development company. I really wanted to be a programmer back then and thought that it would be the best place to learn. While it was true and I learned a lot about programming, I learned another very valuable skill – time management and outsourcing.

Many big technology companies, such as even Microsoft, Google and IBM outsource. Many small shops and individual entrepreneurs do too. It became a part of life, a way to make more or even any money. Are you doing it? If not, keep on reading, I will try to explain why outsourcing may be a good and feasible solution.

I always paid extra attention to details and tried to complete the project as perfect as possible. I was really picky about every small detail and went through hell with outsourcing at first. Nobody in the third world country can do the job better then me, I thought. Now I have a completely different opinion. There is a lot of talent in the world, and it’s all for sale. Cheap.

While I can spend a countless number of hours to learn something new, it’s not always worth it. Yeah, it’s cool and nice to know it all, but do I really need it? Unless it is something that I use a lot, like php or css or javascript, etc., I don’t think I need it simply because I may not ever use it again. Besides, it may be better to focus on a few skills and perfect them instead being mediocre in everything. Sometimes I even outsource what I can do myself fairly quickly.

So, back to being a programmer… I wanted to be one… I became one… I started to do my own websites… I needed to design them… Was it time for me to learn photoshop/illustrator? Even though I did learn quite a bit about design and do some myself, it is something that can be easily outsourced as well.

Looking back into one of my first big project – I spent 3 months developing and working on it every day after work and on weekends. I spent almost no time with my wife, kids, family, friends… I would have done it differently if I was to go back…

Now lets take a look at one of my later projects. It took 3 month for my programmer to develop it and about 1 day for me to write a specification document and make a mock up. It took me another day to test it and to make him fix remaining issues. One more day to fix the text/messages/notifications since he wasn’t fluent in English. That was it. Meanwhile, I had a lot more time to focus on something more important, spend more time with my wife, kids, family and friends, get a little exercise here and there, etc. The whole project cost me $500 and it is as perfect to my standards as it can get.

Now when I look back into my first project – it would have cost me only $500 to get my weekends and evenings back. Is it worth it? Definitely. I have put around 150 hours a month into that project. 500/(3 x 150) = $1.11 an hour. That’s how much I saved working on it myself. If I would have worked at lets say McDonalds all this time, I would have made at least $3,000 more, enough for 6 more projects of the same size. :)

Of course there are issues with outsourcing. There are a ton of claimed programmers/designers who should not even be allowed to touch a keyboard. There are a ton of barriers for working with people you never met like trust. However, I believe that there are way more benefits than risks and most of the issues can be avoided if you do it right.

That is it for introduction. Keep checking and I will guide you through the complete project cycle through outsourcing within the next few posts, from specification document to launching your new website.

Sort multidimensional array in php

Filed under: Web Development — rasim

Haven’t wrote anything here for a while, been really busy lately plus I just got a house, so I have way more work than I can handle. I’ve been reading a bit on SEO and started to put some things into action by starting to build my mini network. While building a few new sites, I started to create content using separate databases and php multidimensional arrays worked great for what I needed. The only problem is sorting multidimensional array as needed. :)

So at the end I came up with an array like this:


$profile[0]['user'] = 'a user';
$profile[0]['name'] = 'user a name';
$profile[1]['user'] = 'c user';
$profile[1]['name'] = 'user c name';
$profile[2]['user'] = 'c user';
$profile[2]['name'] = 'c name';

etc…

Here is the function that sorts this array:

//sort multidimensional array
function sort_multi($arr, $arr_key) {
  //loop through array
  foreach($arr as $key_1=>$val_1) {
    //new array with the $arr_key element's value that needs to be sorted
    $temp_arr[$key_1] = $val_1[$arr_key];
  }
  //Sort array while maintaining index association
  asort($temp_arr);
  //put back into multidimensional array
  foreach($temp_arr as $key_2=>$val_2) {
    $final_arr[] = $arr[$key_2];
  }
  return $final_arr;
}

Now I can sort by user:


$sorted_by_user = sort_multi($profile, "user");

or by name:


$sorted_by_name = sort_multi($profile, "name");

You can use arsort() inside the function to sort the array in reverse order if needed.

Generally I avoid using more complex operations with multidimensional arrays and do it on the database level if possible as it is easier and can be more efficient especially if there are millions of records.

Php dynamic year

Filed under: Web Development — rasim

dynamicyearIt is pretty easy to insert dynamic year or date in a php page. I don’t understand the developers that hard-code the years, especially on e-commerce websites. I had to redo a few of them. A lot of times it would be a long list of years without even a loop. I’ve seen over 100-line code listing years and it actually take a lot more work to create a list than write a for loop.

These are some of the places where I think years should be dynamic:

1) Dynamic Copyright Year. Do you like updating your copyright in the footer every year? Do you ever forget? Solutions is very simple:

copyright &copy; <?php echo date('Y'); ?>  yoursiteurl.com

2) Date of birth – dynamic year. This will print years of birth from 5 to 100 year old.


//From hundred years ago
$start_year = date('Y')-100;
//To five years ago
$end_year = date('Y')-5;
//loop through the years, low to high.
for ($i=$start_year; $i<=$end_year; $i++) {
//your logic here, for now we'll just echo it out
echo $i."<br/>";
}

3) Credit card expiration, dynamic year. If you don’t do this, you may get a call a few years after finishing up the project. Just kidding, but it sucks to change hard-coded values when customers call and complain that they can’t check out because of the credit card expiration year.

//From current year
$start_year = date('Y');
//To a few years in the future, ten in this case
$end_year = date('Y')+10;
//loop through the years, current to future.
for ($i=$start_year; $i<=$end_year; $i++) {
//your logic here, for now we'll just echo it out
echo $i."<br/>";
}

That’s it. It took me about 5 minutes to write this whole post, including the code. I am pretty sure it takes longer for some developers to copy-paste just the years of birth and even longer to find the place and change it a year later.

Let me know if you need any other dynamic date or year examples. Just thought since it is the end of the year, you may have to change the copyright year in a footer. :)

test .htaccess

Filed under: Web Development — rasim

A number of times I had to check why .htaccess was not working on a localhost or a server. Different machines have different setting and whether it is a wamp server, windows or linux box, I always check .htaccess file itself first. The easiest way to check if .htaccess settings get picked up is to create one with minimal settings. I like to have it redirecting to some other website as a confirmation. Below is the example of the content, just copy and place it in your .htaccess to see if it works:

Options +FollowSymLinks
rewriteEngine on
rewriteRule ^test\.html$ http://www.hackcorp.com/index.php [R=301,L]

Now go to test.html on your server and if your .htaccess gets accessed by the apache, you should get redirected to this site – http://www.hackcorp.com/index.php. If not, start looking into your apache settings. Make sure that the basic settings are set correctly, such as mod_rewrite module is enabled in httpd.conf and AllowOverride All is set on the directory in the httpd.conf.

Wheather it is a simple error of misplacing .htaccess or wamp and windows not seing the file, the first step of checking if the settings get picked up is often overlooked.

P.S. Don’t forget that apache server needs to be restarted every time you make a change. :)

Please let me know if this post was helpful or if you would like to see more details on the topic.

EWA Network