Testing Sanity

The core task of software development is sanity testing.

  • warning: Parameter 2 to gmap_gmap() expected to be a reference, value given in /home2/thepalls/public_html/cgpsoftware/includes/module.inc on line 483.
  • strict warning: Non-static method view::load() should not be called statically in /home2/thepalls/public_html/cgpsoftware/sites/all/modules/views/views.module on line 879.

cgp's blog

Posted by cgp
My brother is getting married soon and they are putting together a page to collect money for a set of gifts rather than the traditional set of wedding gifts because they are pretty set in that area. The idea works out pretty well - here is what it looks like:
What's been clicked:


Props to Ben Nadel's "Creating A Sliding Image Puzzle Plug-In" article. I ripped out the div-creation-styles routine right from there (but gutted the puzzle portion of it)

I've been following Ben a couple years now, and pretty much everything I've seen him put together is top notch, so it's worth a visit.

The fun stuff happens here:
...
function pieceClickHandler() {
   console.log($(this).data('index'));
   $(this).toggleClass('unbought');
  }
  
function init() {
  jImg = $('#myImg');    
  jContainer = jImg.parent();
  arr2DBoard = []; 
  initPuzzle(100);
}
...

The "action" can take place in the "pieceClickHandler". init() takes care of the setup. I probably could have coalesced it into a single function call, but *shrug* - not sure if it's necessary or not.

An editable demo contained here.
Posted by cgp

Drupal deployments & workflows with version control, drush_make, and Aegir.

I'm not familiar with Aegir and this is a complicated issue, I was thinking about more granularly (is that a word) deploying modules using cvs and this technique which is a little more lightweight (and probably cheaper), but I could see where the other approach would have it's strengths.

As with any technology or process choice, there are pros and cons to each.

Clearly, again, the one take away from all of this is that drush is awesome.

Posted by cgp
I did a fun little ditty here that does a combination of autocomplete and history. Using the jQuery UI (1.8) framework, it seems to work pretty well. Basically, the text box tracks what you enter into it in a cookie. Cookies can range in size from 2k-4k, so this is probably adequate for my purposes. Chrome has a 4k limit. I guess the advanced version would be to use local storage. (checks the HTML5 support list)
Use the up arrow to invoke the history:
Tags:
Modify History and Autocomplete:
(not tracked by cookies)
(tracked via cookie)
(clear the cookie)

Testing Jquery UI

24 May 2010
Posted by cgp

Mootools

05 Nov 2009
Posted by cgp

Ok, so the moral of the story here is this: Don’t determine what version a browser is based on the methods available. I don’t think I was clear about this in the past because I’ve never implemented it myself. What you’re supposed to do is detect whether or not the native functionality exists, if it does, then use it. If not, then either recreate it the functionality or raise an exception (unsupported).

I always thought testing the capability of the browser (instead of using browser version strings) meant conditions like this all over the place before you used the function:

Training Pace

22 Oct 2009
Posted by cgp

I apparently need to slow down (big surprise)

  1. Calculate Your Training Paces
  2. Calculate Training Pace
Tags:
Posted by cgp

I wrote a heart rate calculator. This has been done, many, many times.

function HeartRateCalculator(resting, max) {
this.resting = resting;
this.max = max;
this.reserve = this.max - this.resting;
this.lower = (this.reserve * 0.6) + this.resting;
this.upper = (this.reserve * 0.8) + this.resting;
this.target = (this.lower + this.upper) / 2;
}


It basically looks like:
function HeartRateCalculator(resting, max) {
this.resting = resting;
this.max = max;
this.reserve = this.max - this.resting;
this.lower = (this.reserve * 0.6) + this.resting;
this.upper = (this.reserve * 0.8) + this.resting;
this.target = (this.lower + this.upper) / 2;
}


Resting:
Max: (You can calculate this here)

$(function() {
$('#calcTHR').click(function() {
var resting = parseInt($('#restingHR').val())
var max = parseInt($('#maxHR').val());
var heartRateCalculator = new HeartRateCalculator(resting, max);
var heartRateHtml = "Target Heart Rate = " + heartRateCalculator.target;
$('#results').html(heartRateHtml);
});
});