Archive for June, 2011

Just Finished Reading: 97 Things Every Programmer Should Know

Friday, June 10th, 2011

This is a very good book for providing high-level insight into both the technical and the procedural aspects of programming. By procedural I mean in general the software development lifecycle process. There are 97 chapters, each roughly a page in length on a topic every programmer should know. The short concise chapters actually made this a very easy and quick read.

The book did what I would want any book to do. It taught me a lot of things I didn’t know, and confirmed a lot of things I thought I knew. I enjoyed the chapters on tips for programmers interacting with and working with QA departments. I feel that it is very important for both teams to understand each others approach. I also felt like there was a lot of common sense in the book. The advice given in many cases was good practical tips that could be applied independently of organizational structure. Essentially, most of what I found could be practiced by both the cowboy coding freelancer and the programmer working within the confines of structured processes.

Lastly I’ll note that I thought it was pretty cool that some topics were covered multiple times from different perspectives. Not to the point of contradiction, but enough to indicate the context sensitivity of certain topics. Again, a good read. I certainly feel like I came out of the book a better programmer.

Using Badboy to build JMeter Test Plans over an SSL

Wednesday, June 8th, 2011

I’ve just recently began using JMeter to stress/load test a Coldfusion application. After reading some blogs on JMeter I got everything set up locally and created a proxy site to my application. But I quickly realized that the proxy is not supported for applications running under an SSL.

The JMeter forum revealed that an easy way to create test cases under an SSL is to actually create the test with a program called Badboy. Luckily for me I’ve been using badboy for automated regression testing for the past year or so. I had never noticed however, that once a badboy test is created there is an export to JMeter option. After exporting a test case I then learned that the badboy export has not yet been updated to support JMeter 2.4. However, it does support JMeter 2.3.4

So the steps for setting up an environment for creating JMeter 2.4 test cases for an application running under an SSL are:

  1. Download JMeter 2.4 (http://jakarta.apache.org/site/downloads/downloads_jmeter.cgi)
  2. Download JMeter 2.3 (http://archive.apache.org/dist/jakarta/jmeter/binaries/)
  3. Download BadBoy (http://www.badboy.com.au/download/index)

Note that both versions of JMeter are downloaded on the assumption that you will want to execute your JMeter tests in 2.4, but you will need 2.3 to make the test cases compatible with 2.4. If you are happy just using 2.3 then you will not need to download 2.4.

Once you have the necessary software do the following:

(more…)

Loading resizable fonts dynamically based on window size

Monday, June 6th, 2011

A reader asked concerning a post I wrote a while back on Resizing text with jQuery and window resize:

Can the text resize adapt to the window size when the page is loaded and also change when the window gets resized?

Essentially, in my previous post I had hard-coded a font size in the CSS of 30px. It would then resize as the window was resized horizontally. But no matter what size the window was when the page was loaded the text was always set to 30px. So I’ve wrote up a simple code sample below in jQuery illustrating how to set the font-size in a div based on the size of the window that the site is loaded in. The original code was fairly easy to refactor to accomplish this. Essentially I added the following function

getOriginalFontSize = function()
{
	var windowWidth = $(window).width();

	var thisFontSize = windowWidth / 50;

	return thisFontSize;
}

and changed the line

var originalFontSize = 30;

to

var originalFontSize = getOriginalFontSize();

So the final block of javascript looks like

(more…)

Just Finished Reading: Head First Python

Sunday, June 5th, 2011

I’m usually a huge fan of the Head First series of books. They are, in general, written in a way that is geared towards efficient learning. I almost always take great joy in some of their puzzles and subtle humor. This book, was no exception up to the chapter on mobile development with Python.

At some point in this chapter nothing seemed to work. I ended up doing a lot of research trying to understand how to do now what the book was instructing me how to do then. The problem was essentially that the Android API for Python had been updated and changed fairly substantially it seems since the book was written. While this is natural for APIs and programs in general it can really ruin the teaching / learning experience for someone really new to the topic.

The resulting issue was that each of the following chapters (which I believe was three) were very difficult to follow since they were building on the mobile app development chapter that had fallen to pieces.

In the end I learned a lot about Python outside of the Android API, but there may be better general python references out there to check out.

Django Error: ‘CSRF verification failed. Request aborted.’

Thursday, June 2nd, 2011

I just got this error when trying to execute a Django application locally. A quick search on the web revealed that I needed to include the following two lines:

'django.middleware.csrf.CsrfViewMiddleware'
'django.middleware.csrf.CsrfResponseMiddleware'

in the ‘MIDDLEWARE_CLASSES’ setting in the Settings.py of the application.

In my setup ‘django.middleware.csrf.CsrfViewMiddleware’ class path was already there, but ‘django.middleware.csrf.CsrfResponseMiddleware’ path was not. I added the latter and it seemed to have resolved the error.

I’m not completely sure what these classes do in detail, but it appears to revolve around security related to the local developing environment and obviously cross-site forgery. I also noticed in the ‘django.middleware.csrf.CsrfResponseMiddleware’ class there are notes that the class was deprecated as of Django 1.4. Once I saw this I removed the path from my Settings.py file, re-ran the application, and it appears to still work. I can’t really explain it, but adding it (at least temporarily) resolved the issue so I thought I would spread the wealth.

Just Finished Reading: Django – Visual QuickPro Guide

Wednesday, June 1st, 2011

I am pretty familiar with the MVC structure and have been writing Python for a while now mostly within the context of unit and integration testing. I started to think that maybe it was time to begin looking into web development with Python. In the past I’ve done a little work with python and CGI, but decided to look into Django as a framework for building Python sites.

I read a number of reviews on this book before picking it up and many of the complaints seemed to revolve around the fact that the book does not consistently build an application throughout the chapters. While true, I believe it adds to the learning experience in that it drills the basics of creating a Django application into your head. The book has 10 chapters and each chapter is a new application. While many of the applications are simply expanded versions of the application built in the previous chapter the author to go through again the process of creating the application. While probably annoying for the advanced Django programmer, the beginner leaves the book with the ability to set up a Django application in his or her sleep. Ultimately repetition is the best way to learn, and this book is full of repetition.

The writing style was clean and concise. No real issues with versioning. All of the code seemed to work as illustrated. Overall, I was looking to get a broad idea of what Django was all about, and on a high level what I could get out of it. If you’re at all advanced with the Django framework this book will probably bore you out of your mind, but if your a Django newbie I think you’ll find this book very informative.

If I had one criticism of the book, it would be that on a very basic level the book continued to be very instructive in how to accomplish certain tasks. I like the idea that I have to create a new application and set up a new database for each chapter. But I also think that it is good to force the user to begin doing it themselves without instructions. For example after chapter 6 or so the instructions should have indicated to the user that they should create an application named ‘thisApplication’ with a database named ‘thisDB’ instead of going through detailed instructions each time.

Overall good book, and well worth the time to read.