Thursday, April 24, 2014

Wrote a simple 3-equal-column responsive layout.

I was working on a much larger project for work that had multiple modules with varying amounts of content. The modules just didn't look very good with their uneven heights, so I wrote a small jQuery script to loop through the DIVs and get the height of the tallest DIV, then make all the DIVs that height. It worked pretty good, and then added a call to the function on resize

The boxes also needed to stack for mobile, which just required changing the float to "none" in the media query. 

  $(document).ready(function() {
    function set_height()
  $('.col').height('inherit'); // reset the height
  var max_h = 0; // variable to hold the max height
  $('.col').each(function(i, obj) { // loop through column DIVs
var h = $(obj).height(); // get the height of the col
    if(h >= max_h) 
{max_h = h;}  

Thursday, April 17, 2014

Going for day 3 in a row rehearsing with 3rd different band..sort of

I rehearsed with the 1969s on Tue, April Samuels and Neil Brincks on Wed, and tonight I will rehearse with the band yet-to-be-named, featuring Chad Litersky and Neil Brincks.

The songs I'm playing with April and Neil are some of the same songs I'm playing with Chad and Neil, so Neil and I should have these down pretty soon.

Monday, April 7, 2014

Central Market crab cakes. 99 flavors but crab ain't one. #CentralMarket

Central Market has some really good stuff, but be ready to pay out the a$$ for it. That being said, many times it does feel like it's a good value, because some of their stuff is that good, and when I have the cash I'm willing to spend more to get more.

I had their crab cakes yesterday. They were pretty damn pricey, as is everything else, but the bigger problem was that I didn't taste any crab in them. They were a minced up mush of lots of flavors, but crab really wasn't one of them. I had to pick an dig to find something that looked like crab, and even though I think I may have spotted a piece, I didn't really taste any.

To be fair, I bought some pork eggs rolls, and some jalapeno poppers that were both excellent. 

Sunday, April 6, 2014

Working on Bertolf covers. 2 versions. 1 close to original, and another my own style. Fun stuff. #Bertolf

Check out Bertolf on Spotify. He's a songsmith of the highest order. I decided to try and record a cover and mimic him as best I can. I just about have the copy version done. In my head it sounds pretty close, but I'm guessing if he ever hears it he will not think so, but hopefully he is flattered and appreciates the effort.

I will record a second version and mix it up a bit.

There's a lot of YouTube stuff on him, but I can't find much info in English. When I translate pages they just don't make that much sense to me. Something is definitely lost in the translation. I've heard him speak English on one video, and he seems to speak very good English, but all the live stuff and interviews are in Dutch.

Wednesday, April 2, 2014

Yes, I did reinvent the wheel. I spent about 3 hours creating a Captcha type form validation script.

I had a custom form in a WordPress page that submitted to PHP form handler. I needed some type of Captcha style validation function. All the plugins I found used form plugins, and all the PHP scripts I found required me to insert PHP into the form itself, which I could not because the form code was in a post/page that does not allow server-side code. I know there are other plugins for that purpose also, but that had me looking at installing three different plugins to accomplish what I felt I could do myself.

Well, it took me way long than I though. I probably spent about 4 hours on it, but it looks like it works.
The form was getting a lot of spam from bots, so it wasn't a huge security issue, but just the annoyance to the client having to check 20 posts to get one legit one.

The form has an AJAX JS validator and also validates on the server-side using PHP, so I wanted I created the Captcha script in both places.

I needed to generate a random image and then get its value.

I used JS to randomly pull an image path from an array, and then assign that to the SRC of the random IMG.
This worked fine, but getting that value from PHP on POST end was a little tricky.

I had to also use a hidden input an assign its value the same random image path as the actual image, so on the server side I am comparing the user input string to the value of the hidden input string.

I had to use some fancy PHP string manipulation to trim down the path to get just the number in the file name. That number is the number that is in the image, and the number the user will try and match.

$match_ran_num = strip_tags( trim($_POST['match_ran_num'] ));
$randomImgValue = $_POST['randomImgValue'];
$randomImgValue = basename($randomImgValue);
$randomImgValue = basename($randomImgValue, '.jpg');
$randomImgValue = ltrim($randomImgValue,"randomImg_");

if($match_ran_num != $randomImgValue){return;};
On server-side I just kicked out of the function if the stings don't match. This took a little while, but was pretty straight forward.

Client-side, I edited the function that was already checking for any empty fields. Once it looped through all the form fields successfully, I checked the value of the input text to the generated image path. Once again having to trim down the random path to get to the number that was part of the image file name.

var randomImg_num = formData[19].value;
randomImg_num = randomImg_num.substr( randomImg_num.indexOf('_' ) +1);
randomImg_num = randomImg_num.substr( randomImg_num.indexOf('_' ) +1);
randomImg_num = randomImg_num.substr( 0,randomImg_num.indexOf('.' ) );

if(formData[20].value != randomImg_num)
alert('The number you entered does not match the number displayed.');
return false;
As I am writing this I just can't figure out what took me so long, but I did go down a few rabbit holes along the way. I didn't start out the hindsight clarity I now have.
I was an interesting work-around to using the tried and true Captcha that we all know and love.
Now I just need to wait and see if the random images are distorted enough, and if I made enough of them. Hopefully it's a done deal, but we'll see.

HTML email testing is a pain, but Litmus is the chit. The Interactive Testing feature is so money.