Rob Zolkos Software Development


2012 - Tools of the Trade

The tools of a software developer are as just important as the tools of a carpenter. They need to let the craftsman get on with the job and get out of the way. Here is a list of tools that assist in getting my work done.

A topic for another day is time management. I use two apps for this:

I’ll cover more about those in the future.

I hope thats shed some light on my main apps. I don’t think there is anything shocking in the list above. If there is anything you think I should try or would benefit in knowing more about, let me know in the comments.

Posted 08 April 2012 @ 12:02 pm Comments

And Now Jekyll

Here I am again. Instead of actually blogging useful information I’m changing blog engines and then blogging about the fact that I’m changing blog engines.

So….to what blogging engine have I changed? I’m glad you asked. Jekyll. It’s actually the same guts as the Octopress blog software I was running but a little bit more bare bones. In fact, I pretty much wrote the entire theme you are looking at from scratch over the Easter weekend.

I’m gonna leave it like this for a while. There is a few things I want to tweak here and there. But for the most part it is a nice, readable theme so I can now concentrate on writing some actual, you know, proper blog posts. With information.

Until the next shiny blog engine technology comes out….

Posted 07 April 2012 @ 10:33 pm Comments

Rails Default Scopes

I was refactoring some old rails code in a project today, and there were a lot of instances of the following:

f = self.where("country = ?", country).order("amount asc").all
g = self.where("country = ?", 'worldwide').order("amount asc").all

The issue is that everytime I queryed the db, I needed the records sorted a by ascending amount, so I had .order(“amount asc”) scattered through my code.

Of course, if I ever needed to sort a different way, I had to redo multiple lines. Not very DRY.

But Rails has default_scopes. This means you can define things like sort order or any other condition that will always be executed during a select, new or create action.

default_scope :order => "amount asc"

f = self.where("country = ?", country).all
g = self.where("country = ?", 'worldwide').all

A lot simpler.

Posted 16 October 2011 @ 11:24 am Comments

Wordpress to Octopress

I’ve made the switch from Wordpress to Octopress tonight and found the switch to be relatively painless.

I like the simplicity of just typing my blog post in vim and then deploying it up to the server. And of course it’s now damn quick.

Anyway, this is really just a test post disguised as a blog post.

Posted 12 October 2011 @ 10:06 pm Comments

Add barcode reading to your Rails app for under $5

Our internal Rails application needed a feature to scan in barcodes for consignment notes for our dispatch team. I looked around at barcode scanners and they averaged $150 to buy, and wireless ones were in the order of $500. And even then, there was still more data that needed to be captured than just the barcode (we needed to record the job number etc). I mulled it over for a few minutes and then wondered if an iPhone could be used. Sure enough, I found a great little app called BarcodeReader - WiFi. This $3.99US app scans in a barcode and can be configured to send that barcode to any website.

Over the next hour, I added an action to our web app that captured the barcode, and presented the user with a textbox to enter in the job number. Using an input box of type “tel” meant that it popped up a large numeric keypad to enter in the job numbers. Works perfectly and is very quick.

If you need barcode ability in your rails app and are able to use an iPhone or iPod touch, I highly recommend this approach. It is very cost effective and works well. I’ll post a link to a sample github project if required (leave a note in the comments if you would like to see this).

Posted 24 August 2011 @ 8:21 am Comments

Rails custom error pages and notification

A great post on setting up a Rails app with custom 500 pages and exception emails.

http://paulschreiber.com/blog/2010/05/10/handling-rails-errors/

Posted 13 August 2011 @ 10:26 am Comments

Rounding in MySQL

Needed to know this. And need to remember this.

sql SELECT ROUND( 1.4612, 1 ); /* = 1.5 */

Posted 12 August 2011 @ 3:36 am Comments

Search and replace on a single line in VIM

This will replace all occurrences of token_a with token_b on the current line. Came in handy today.

:s/token_a/token_b/g
Posted 04 August 2011 @ 3:47 pm Comments

60% Faster Rails bootup with Rails 3.1 with Ruby 1.9.3

Yesterday I had a few minutes spare to test out Ruby 1.9.3which has just hit ‘preview’ status. I was very interested to see what the startup time would be on Rails 3.1 as some effort has gone into not only speeding up Rails but Ruby. As I get more and more fanatical about testing my apps quickly, especially after watching Gary Bernhardts Destroy All Software screencasts, I’m finding that I’m continually looking for ways to speed things up. It seems that 1.9.3 will assist!

I ran a little non-scientific experiment. All I did was create a new Rails 3.1rc5 app and added the rspec-rails gem. I installed Ruby 1.9.3.preview with the instuctions here. And then created a small rspec spec file that did nothing.

require 'spec_helper'
 
describe User do
end

But together with the time command I was able to see the following interesting stats.

time rspec spec/

With Ruby 1.9.2-p290 the load time was 6.632s. The same app on Ruby 1.9.3.preview loaded in 2.629s (a 60% improvement)

Thanks to various improvements (but I suspect primarily “the patch”, things are looking brighter for Rails bootup times. And that is a great thing!

Posted 03 August 2011 @ 6:01 am Comments

Samsung ceases reporting mobile/tablet sales numbers

As reported in the Wall Street Journal.

What are they afraid of?

Posted 01 August 2011 @ 5:03 am Comments

Switching to Apple. By an ex editor of Windows Magazine

Cult of Mac has a post by retired editor of Windows Magazine, Mike Elgan, on his complete switch to Apple. It’s an interesting read, especially when he hits the points most people do about switching. Except these days most people can’t actually say for sure why they are hesitant or resistant to even try to switch.

Many Windows users don't switch to Mac because they have an outdated belief that application choice is too limited and that Macs are too expensive.
Posted 28 July 2011 @ 4:48 pm Comments

Is everyone moving to Git?

My version control system of choice. Nice writeup in Info World. Whilst you’re interested in Git, definitly read The Git Book.

Posted 27 July 2011 @ 4:06 pm Comments

Apple iPad Unleashing Creative Destruction On PC Industry

Bob Evans writing in Forbes :

...what really stood out on the call was the realization that when it comes to the iPad and its impact on enterprise customers and on the PC industry itself, we are not really yet even at the end of the beginning—we are at most in the middle of the beginning.

Some excellent points. The whole ecosystem of these devices is what is so magical. Not the device itself. Its the software AND the hardware.

Posted 27 July 2011 @ 3:53 pm Comments

The Cucumber Book

The Pragmatic Programmers have a book entirely devoted to Cucumber on the way. Called The Cucumber Book, it will serve as a handy and more thorough tome on the topic than the rSpec book (which goes into some detail but not complete). I have bought a beta version of the book and it has already come in handy. Highly recommended for anyone looking at getting into this fantastic testing technology.

Posted 26 July 2011 @ 11:53 am Comments

Apple releases iOS 4.3.5

ZdNet has an article about the latest iOS release. iOS5 on device delta updates can’t come quickly enough. This is a security fix.

Posted 26 July 2011 @ 3:07 am Comments

Greater Market Share does not always mean Better Product

Use of a particular operating system on any platform is largely a matter of personal choice. Sometimes, that choice is made by a business or corporation on behalf of their employees, and other times, individuals can make the choice themselves. I’m often seen tweeting or facebooking the virtues of Apples operating systems and products, often citing increased sales statistics or my own experiences in my message that Apples products give me a better experience than any of the alternatives. However, I often see mention that Android must be better because it has a higher market share. Or Windows is king because it has a higher market share. Higher market share does not always mean better product. A number of variables play part in determining market share. There are many cases where a product with lower market share, is simply the better product.

I will use the analogy of the car market. Australias #1 selling car, the Holden Commodore, sold 45,956 cars in 2010 (in Australia). Ferrari, on the other hand, sold 6,573 cars last year (worldwide). That’s an almost 7 times increase between one model of car from one manufacturer compared to every single car sold from another. A classic example of a better product (in terms of experience, luxury, and in most cases performance) having a lower market share than a competing product.

It is not business rocket science for a vendor to saturate a market with cheap product and grow market share. Selling cheap android handsets is a clear example of this. Numerous reviews have showcased the horrible experience a cheap android product provides. Yet, people continue to quote Androids stunning market share growth as a clear example of a superior product. Not so.

A similar case can be made for the ongoing debate of whether Microsoft Windows operating system is better than Apples OS X. A windows PC can be bought for a mere $199. The same is not true of Apple hardware. It stands to reason that Windows market share will be higher. This does not mean that it is a better product. If you’ve ever had a blue screen of death, had to re-install due to a slow down, or the computer crashing or catching a virus (even though you already had an anti-virus installed), then you will know what I mean.

So, next time you hear “High Market Share means better”, have a think about all the factors that have contributed to the market share number. Product quality and overall joy of use may not rank high in contributing factors, and it may in-fact be a terrible product to use.

Posted 20 July 2011 @ 8:34 am Comments

Rails, testing, and peace of mind

I must admit, I probably didn’t test my code as thoroughly as I ought to have. Let me re-phrase that. I did test it. I just didn’t write complete test cases to ensure regressions weren’t introduced when new bits were added. As a result, maintenance always took longer than it should have, and bugs were introduced when changes were made. Even though I had read and studied the importance of testing very early in my software development career, it was only after continued frustration with things breaking that I got off my butt and actually started using testing practices like TDD, BDD and even writing tests for code that had already been written. I made it a goal to have the code as covered as possible.

Initially it took way longer to write code. Way, way, way longer. I did get frustrated. I questioned if this was really the way to go. But in the end, I got quicker at writing tests. I more often than not wrote the tests first. And things were good. If things broke, I wrote a test, fixed the bug, tested the entire app to ensure I didn’t break anything else. And things were good. I’m now very much an advocate for testing and consider it probably the most important skill in my software development bag.

I recommend reading the post by Ryan Bigg. It covers some other points in relation to testing, especially the economic and financial implications both personally and to an organisation when testing is not a priority.

I’ll follow this post up with some tips on how to add tests to a Rails project that has none. I think this is a very under documented process and one that will help many people that have existing projects that they understand very well, and adding tests will give them the confidence and knowledge to use tests when they start a new project.

Posted 29 June 2011 @ 9:53 am Comments

Change Photoshop brush size with keyboard

I prefer to use the keyboard for most tasks (as its infinitely quicker than using a mouse), and having opened Photoshop to edit a picture, I needed to reduce the size of the eraser. Normally I would use the mouse and go up to the brush settings and adjust the size down with the scroller. Way too long. So I googled around and found this great post at Tips & Tricks HQ - 25 Very Useful Photoshop Keyboard Shortcuts.

The keyboard shortcut [ and ] reduces the brush size. Quickly. And painlessly.

Clearly Photoshop experts out there know this, but for a humble coder like myself, this sort of stuff is gold.

Posted 21 May 2011 @ 6:08 am Comments

jQuery CDN fallback

I was looking through some source code today for a jQuery plugin and in the source of the example html page was a little snippet I thought would be handy to share. It basically loads the jQuery library from Google’s CDN (which is what I’ve been doing for a while now), but in addition to that, it tests whether this download was successful, and if not, loads jQuery from the server the application is hosted on. So it’s a great fallback for those rare times that Google’s CDN fails (which let’s face it is a rare, but not impossible occurrence.

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
<script>
  !window.jQuery && document.write('<script src="jquery-1.4.3.min.js"><\/script>');
</script>
Posted 01 April 2011 @ 8:04 am Comments

Photoshop pixel and point sizes for web

I was transferring a PSD layout the other day into HTML/CSS. I pride myself in getting the layout looking as close as possible to the PSD with minimal use of images and pushing CSS to the limit. The results are generally very lean pages that render beautifully, just as our designers intended, and just as the client has approved. However, in this case I was getting some weird result with font sizes. In the PSD the footer fonts were 18pt, which is what I used in my CSS. Refreshing the browser, the font appeared way larger than the PSD. What the…?? I had a quick look at the image size in photoshop and it was set to 72 pixels per inch. Aha! That was the problem. Our screens and all browsers display at 96 pixels per inch. Converting it was easy, and it reduced the 18pt font size down to 13.5pt. Which rendered perfectly in the browser.

The steps? Just change the pixel per inch setting in the image size dialog box. This will result in a change to the documents width and height, but if you then change the width and height back to their original values, then all will be good. See pic below.

Posted 15 March 2011 @ 10:18 am Comments

Lessons Learned : Knowing Your Customer

A few weeks ago, I finalised some new code for a new section of an existing website. I always code websites using web standards and always test on the latest versions of Chrome (v10), Safari(v5), Opera(v11), Firefox(v3.6) and Internet Explorer(v8). In the case of the latter two, I test both the current version and the upcoming version. So the site is also run through its paces on Firefox 4 and Internet Explorer 9. As for mobile, I test on iPhone and iPad too. As you can see, it’s a pretty comprehensive test. However we began getting customer feedback that they couldn’t log in to the new section of the site.

I looked through the logs and couldn’t even see that they’d made an attempt to login. Very weird. I went back to the tests and everything worked. Then some users were able to log in. But the majority couldn’t. We started to get some screenshots and feedback and discovered that it was a browser issue. Internet Explorer 7 to be exact. The jQuery login popup we had implemented didn’t render correctly on the old Microsoft browser. Hence it didn’t work, and no entry was made in the logs, as the customer wasn’t even able to submit the form.

I had a look at the analytics data for this group of users and found that 89% of them were using Internet Explorer 7. A browser not in my test suite but used by the vast majority of our users (of this part of the site). The fix was easy once we knew the problem. And all customers can now log in.

Suffice to say that Internet Explorer 7 is now part of our test suite. We don’t test that things “look” the same. We just test that the site “works”. Internet Explorer 7 has 5.7% of the worldwide market share, and Internet Explorer 6 has 3.8%.

But the main lesson learned, is that when developing for a closed group (like an intranet or a internet site that is locked to certain users), make sure you know the browser statistics data. Not only will it ensure that what you’re developing works, but it also provides the opportunity to give them a better experience through harnessing the power of that particular browser.

Posted 06 March 2011 @ 5:30 am Comments

Favicon in Rails

I was needing to update a favicon in a rails 3 app today, and for the life of me I couldn’t get the old one to leave the browsers cache. Anyway, after googling around for a little while, I found this snippet in the Rails documentation :

<%= favicon_link_tag %>

This was just what I needed. No longer needing to hard wire the favicon code and fully cache proof. As soon as I put this sucker in, refreshed the browser, up popped the new favicon.

Posted 22 February 2011 @ 1:45 pm Comments

Removing trailing whitespace in VIM

My text editor of choice is vim and after recently running though rails_best_practices I found that a lot of the files I had worked on in a certain project were filled with trailing white space.

This is the snippet I found on the Rails Best Practices site that I put into my vimrc file and all is now good.

" Strip trailing whitespace
function! <SID>StripTrailingWhitespaces()
    " Preparation: save last search, and cursor position.
    let _s=@/
    let l = line(".")
    let c = col(".")
    " Do the business:
    %s/\s\+$//e
    " Clean up: restore previous search history, and cursor position
    let @/=_s
    call cursor(l, c)
endfunction
autocmd BufWritePre * :call <SID>StripTrailingWhitespaces()

And this line in bash will remove trailing whitespace from any files that may have them (in osx). Replace .rb with.haml or any other file extension you have.

find . -name '*.py' -exec sed -i '' -e 's/\ *$//' {} ';'
Posted 18 February 2011 @ 9:07 am Comments

Websites are like fashion

Facebook is like fashion. It never ends.

I was watching..or re-watching….The Social Network the other night and my ears pricked up as I listened to some dialogue between a young Mark Zuckerberg and his equally young financier, Eduardo. They were celebrating the fact that The Facebook was about to “go live” and Eduardo asked if the site is “finished”. Mark shot back, “It’s never going to be finished. Facebook is like fashion. It never ends.”

Not quite sure if Zuckerberg ever actually said that, but it’s an interesting and bold point, not just for Facebook, but all web sites or web applications. I’ve always been a big believer that a website is a continual improvement process. Sure you can launch and leave it. But the site then becomes stale. It’s design becomes stale, its content becomes stale. And visitors stop coming back.

How many sites have you been to lately where the “news” section was last filled in 3 years ago. Where the site looks odd when you look at it in on your smart-phone? These are the sites that suffer from “launch and leave”. Like a neglected yard, the weeds start accumulating and people just see your site as a wasteland.

Often times, we as designers/developers, need to share the blame for this with our clients. We build sites to a budget that doesn’t take into account ongoing maintenance, post-launch reviews, or even educating the client on how best to keep the content on the site fresh. And I think it is up to us in the design/development community to lead the way in, at a bare minimum, communicating this message to our clients. Keeping them educated on the pitfalls of stale content, on the importance of re-visiting the site for design updates on an agreed interval, or reviewing that the site is keeping up with the goals it was originally designed to meet. Surely these points are something we should be looking forward to doing, not shying away from.

A young Mark Zuckerberg was right, and had he left Facebook as it was when it originally launched, it wouldn’t have over 500million regular users that it enjoys today. Websites are like fashion. Never finished. Never done.

Posted 18 February 2011 @ 3:34 am Comments

Genesis

I listened to a podcast a while back on freelancing with Ruby On Rails. In the first episode, it was espoused that one create a blog / portfolio site with ones own name as the url. So I diligently purchased the domain, and kept listening. Step two was to create said site using the technology one was using for clients. For me, that was Ruby On Rails. So no problem right. Not really.

But then the most amazing thing happened. Client work started coming in. And quick. And fast. Then the year finished, and 2010 started. Then 2011. Did it slow down. Nope. In fact, it got busier. I wrote some tests for a simple blog, and thats where development on my custom blog stopped. But I still needed a platform to type stuff out. Share some of my knowledge. Have fun. So I did what 98% of everyone else seems to have done. I installed Wordpress. Activated a basic theme. And started typing. It took all of 3 minutes. Not perfect. Not stunning. But hey, I’m here.

I don’t start something and not give it 100%. And sometimes I don’t start something unless I can foresee the end result is going to be 100% awesome. I’m constantly amazed I get anything done at all. But seriously, thanks for reading. I hope I keep you interested and entertained.

Posted 13 February 2011 @ 3:53 pm Comments

Check out the archives for older posts...