Monthly Archives: January 2014

What makes a leader

I have been in the software industry for over six years now. I have seen some good leaders. I also have seen some bad leaders. Having always been under some type of manager in my careerI have noticed a trend of what really makes a good leader. I have alway been under a person who code could wether they were still coding or not doesn’t matter. As long as they could code that is what type of person I am talking about. The first trait I think about in a great leader as they have an ability to bring everybody on the team up or even past their standards.

The hardest thing to do as find time to train others. As a Sr. engineer you are always feeling the time crunch. You feel that if you spend the time training somebody that is time spent away from getting productive things done. While that is true at first over time you will start gaining that time back. For example if you have a Jr. engineer starting and he is not familiar with the framework you are working in. That person could spend hours if not weeks learning. Even through the learning they may not be learning the same way as you did. Instead it’s smart to spend time training as you go. So you start them off with a small ticket and help them through it. Then start giving them more complex tickets. While doing this you will see that person start to grow and ask less and less questions. This will not only allow you to have your time back but will also make the team more productive. This is because you have somebody else who can do the same type of tasks you do. This will happen over time. I have seen some project leaders not able to do this and everybody else on the team suffers because of it. Time to get new features done are slower because each person has to go through the learning process in a different way. The biggest trait through is communication skills.

A great leader is able to communicate very well. They are able to send a message out and have it be so clear that nobody has to ask questions. Not only are they able to communicate through text wether it be email or instant message they are also able to communicate verbally. For example maybe you are running into a super complex issue. They are able to come over without knowing the solution and work through it in a way that both will understand. It’s becoming even more important these days to have great communication skills. It can really make a difference on wether a project is successful or a failure.

I really feel that you can tell if somebody has leadership skills when you first meet them. Sometimes it takes longer but over time it will start to stick out. If you are a bad leader people may not say anything but they are able to tell. If you are a good leader you may get approached more for advice or help. If you are always to busy to share your knowledge then you are not a good leader.

New Relic free edition

I have used both the paid version and free version of new relic. My experience with the paid version was limited though. I used it on the job for a couple of months. I also used the 14 day trail they give you with my own projects. Even though the paid version gives you more features if you are a small business or website you don’t really need the paid version. The free version actually gives you enough information to be very useful. After talking with new relic support one thing they told me they want the free version to be useful. So they try to pack as much as possible into the free version but still be able to make money on the paid version for larger applications or businesses. The setup process could not be any easier.

Basically to set it up you just have to follow their documentation. Which in my opinion really well done it’s step by step. For example if you add it to a PHPapplication you just need to follow these instructions. It should take less than 10 minutes to setup. After you have it setup everything starts working right away. You start getting real time data within a minute. Also if you have it already installed on your server the setup process for other domains or subdomains is even easier. It would take less than a couple of minutes. It basically involves editing your .htaccess file. That is for PHP of course I believe the setup with a rails environment is about the same except you are adding it to you Gemfile. I have also had the experience of setting it up with an Android application. Again the setup process is very easy. They have instructions for different environments like Eclipse. The total time for the setup again is less than 10 minutes. So you are not having to put a lot of time getting it up and running. Not only is the setup easy but you also get a lot of really good features for free.

The best feature in my opinion is getting to see the transactions timed. For example you can see the load times for each request. It even breaks it down by the script name. This will allow you to target specific actions in your controller to refactor. It will also keep an Apdex score. This can be useful to see how well your site is responding to requests. You can do your research on what the scale is. Another feature for your website monitoring is it will send you an email alert if your site or application is down. You get these alerts right away when it goes down and then when it’s back up. You will also get a report with the downtime and how long it was. There are other tools that will do this but I have not had as good of a experience with them. On the Android or mobile side you get to see interactions with your application. So when the user hits a specific activity you will see how long the application is taking to respond. This is very important as each device the response time will be different. Some phones have better processors and respond faster. It’s important to know that some users may not be having a good experience. That is something that Google doesn’t provide either. Other information it tracks is OS versions and devices. Less important statistics as Google also tracks those.  The last free feature that I find useful is server information. It will give you your memory usage, CPU usage, processes running and space left on your disc. The best part of all these features as they call come with the free edition! The only downside is that this information is only retained on their site for 24 hours. After that is is gone. But again for free you can utilize their API and can download all that information locally if you want. The possible for free are endless. Although I do not have experience with their API it looks like a standard restful API.

I think new relic is worth checking out at the very least. I believe that it’s the tool of the future for server and application monitoring. I suppose it’s been around long enough to be called the tool of the present to. I have had no issues since I started using their service. Their customer service has been great and responded fast to questions too. Also you get to start with a free 14 day trial they don’t even ask for your credit card at least at the time I signed up they didn’t. Plus you get a free t-shirt just for signing up. I think the free version is enough to keep a small company or website satisfied. If you are a larger company I think their full version would be enough so you also have that option. You get all the features with the 14 day trial so you can see for yourself.

PHP order array by date

Ran into a really interesting way to sort an array by a date field. I thought I would share this as it wasn’t super common to find. I found the answer in this Stackoverflow post. The third one down to me was the best answer. The reason why I felt that was it used an anonymous function instead of having to create a new function. It’s very compact and easy to understand that way. With this knowledge you are able to sort by more than just date columns to.


usort($array, function($a1, $a2) {

$v1 = strtotime($a1['date']);

$v2 = strtotime($a2['date']);

return $v1 - $v2;;

// $v2 - $v1 to reverse direction });

Web hosting solutions

What is your first thought when you think web hosting? My first thought has always been confusing. There are so many hosting providers and so many options within those providers. To name some I have used personally hostgatormyhosting and hostmonster. I started using shared hosting and at first I thought it was a great deal. For a low price you are able to host unlimited sites and databases. Also you are able to access your files as if you owned the server yourself.

Overtime I noticed that shared hosting kept on getting worse and worse. I kept having downtime for issues I did not create. Since I was on shared hosting their wasn’t much I could do about it to. I kept on contact support in hopes they would be able to fix it. I have used shared hosting over the past six years. I have had many good days hosting but have also experienced a lot of really bad days. I started my hosting with hostmonster. I thought their service was really good. I was only paying around six dollars a month to. So for that price you can’t really go wrong right? I noticed very little downtime with my shared hosting. To be fair at the time I didn’t have any real users using my website. So I wasn’t keeping track of downtime I would only notice it if I was on the site myself. I also noticed very little slow speed. Again with the same scenario of not monitoring it closely. I was very impressed with their service over all. After some time I wanted to expand my development skills and at the time hostmonstor didn’t have Ruby on Rails hosting. I seen that hostgator included Ruby on Rails hosting with their shared hosting plans. Also the price at the time was very reasonable only again like six dollars a month. I thought what could go wrong. Well at first it was alright and I didn’t have much downtime. I was able to get my sites up and running pretty quickly too. After being with them over a year I noticed my site kept going down. This would probably happen at least once a week. Most of the time when I contacted support they said it must be something with my code. After debating with them for awhile they would restart the server and we would move on. After working with them for another three or four months I decided that I had enough. I have users depending on it being up and could no longer justify the lower price. I was looking around to other shared hosting and noticed VPS hosting. At the time I wasn’t too familiar withVPS hosting but I had heard you get full control over the server and only pay for what you use. I then decided to move to VPS hosting.

I could have just upgraded my account at hostgator and went on their VPSplans. But they were crazy over priced. I guess they don’t want VPS customers? So I did some research and found myhosting. I was surprised by how low priced they where. Also they offered hosting in Canada or the US. I chose the US but it’s nice to have the option available. Also the VPS setup could not have been easier. You need to know a little bit about a linux server but not a ton. As long as you go with their business package a lot of it is click and go. I have really been impressed with their custom service also. Also they have a guaranteed uptime of 99.9%. Thus far they have kept that promise and actually have had an uptime of 100% the last three months. The price I pay currently is only twenty dollars a month. So about double or a little more than double than what I way paying but for much better service. I think the value in it is well worth it. It will allow me to grow my sites traffic. Users really appreciate sites that have 100% uptime. They get really upset and at times leave if a site is down to often.

To sum it up my advice for any small website or small business go with VPShosting. I would recommend myhosting based on my experience with them but would also recommend to shop around. It’s important to find something that will work for you site or your company. If you have a site that does not have a lot of users or maybe isn’t critical maybe it’s just a blog like this maybe shared hosting would work. Again if you are reading this you know the site is not down. So if it always goes down people will stop looking at your blog. So again I think VPS hosting is the way to go. I also feel that the price for hosting will keep going down as processes improve and get faster. Also if you are nervous about managing your own linux box I would recommend trying it and see if you like it. Maybe start month and month and go from there.

Yii framework custom methods inside datatable row

I have been using the  edatatables extension from the yiiframework for a while now. I have noticed that you can do a ton of things with it. These things take very little effort. The extension is very powerful and was well done. Recently I ran into a situation that wasn’t apparent to me right away on how to implement a column with customized HTML. I wasn’t able to use the default column_name value since I needed to format it. The first thing I did was create a method inside the given model that would return the HTML. In the Yii framework models cannot call partials so I had to have the HTML within that models method. To me this looked out of place and felt dirty. Being a pragmatic programmer I decided to look into a better solution. I stumbled upon this solution while researching this. This solution did not seem to be common so I think this post could be beneficial to others.

The solution was to call an internal method within that controller and pass in the given data row. Through the internal function I am then able to render a partial and pass that HTML back to the actual row. When I called render partial in Yii I add the true parameter at the end so it doesn’t render it real time. Instead keeping it in a variable to return. This allowed me to remove the method from the model and move that HTML logic into the view layer. The code below show my implementation that involved adding the custom array to the columns definition and create an internal method to be called.


$columns = array( ‘column1’, ‘column2’, ‘column3’, array( ‘header’ =>         ‘Column 4’, ‘class’ => ‘EDataColumn’, ‘sortable’ => ‘false’, ‘value’ =>         array($this, ‘_latestPrices’), ‘type’ => ‘html’, ),
 );

protected function _partialViewBeingCalled($data, $row) {

$result = $this->renderPartial(’../shared/_myPartial’,array( ‘Data’ => $data, ), true);

return $result;

}

As you can see the solution is very simple. The hardest part was figuring out how the datatable would call the internal method while passing the data. After those updates I now have a clean solution that I can feel satisfied with.