I created this page as a running repository of useful, miscellaneous web notes for later reference.


Javascript & JQuery

How to get the latest version of JQuery:

alert('JQuery: '+$.fn.jquery);   // Outputs JQuery: x.x.x

Useful info about Javascript and JQuery source maps — an explanation about what they are and how they are used:

http://elijahmanor.com/the-magic-of-the-jquery-1-9-source-map/

Parsley — A reliable and easy Javascript form validation library:

http://parsleyjs.org/

Get hostname in Javascript:

// For the host name only, use:

window.location.hostname

Server Notes, LAMP/WAMP

Latest WAMP install instructions — in less than 5 minutes you can deploy WAMP with MySQL server on localhost.  Not bad for quick local dev server.

http://forum.wampserver.com/read.php?2,123606


Symfony

A utility for Symfony to convert those awful annotations to YML files:

https://packagist.org/packages/sed/route-exporter-bundle


Helpful Symfony 3.0 base commit, to start new PHP Symfony projects:

https://github.com/itrascastro/Symfony-3-Base-Project
https://github.com/keefekwan/symfony2_forms

Best example of a form collection at work I think is here (many thanks to the programmers making these publicly accessible!)

https://github.com/sevnekish/user_manager


Symfony 2 performance tips:

http://labs.octivi.com/mastering-symfony2-performance-internals/

Form Type setDefaultOptions weird error:

http://stackoverflow.com/questions/31659102/symfony2-error-on-submitting-form-with-a-collection-of-forms-warning-spl-obj?rq=1


General Web Notes & Utilities

Free OST file viewer worked well, allows you to save a person’s Microsoft Exchange mailbox email file and open and view the contents without messing with the .ost file in Outlook!

http://www.ostviewer.com/

Waka Time — Free web development time tracking utility:

https://wakatime.com

Websites that show the latest hiring trends in the tech industry:
https://news.ycombinator.com/item?id=11202954

https://whoishiring.io/#!/stats/

A good simplified explanation and list about HTTP 2:

https://www.keycdn.com/support/http2/

Good article about the anatomy of a URL:

http://www.skorks.com/2010/05/what-every-developer-should-know-about-urls/

Steps for setting up DNS on a Ubuntu server:

http://mixeduperic.com/ubuntu/seven-easy-steps-to-setting-up-an-interal-dns-server-on-ubuntu.html


PHP/MySQL

PHP SQL injection – good article:

http://phpdelusions.net/sql_injection



Aaron Belchamber
22 years experience in marketing and building businesses

Senior PHP & Symfony Web Developer, Business Analyst, Marketing Director
Belchamber.us / TopDocsTalk.com
(904) 294-0803 • Jacksonville, Florida


The JQuery UI library’s Datepicker function is very convenient.  Here’s a way to override the date field if you want to allow the user to also input the time of day along with it without adding an extra field and deal with merging the values in the backend.  You can also add “+d.getSeconds()” if you want to allow seconds, but I find that’s wasted space.

  $('.datepicker').datepicker({
        dateFormat: 'yy-dd-mm',
        onSelect: function(datetext){
            var d = new Date(); // current time
            datetext=datetext+" "+d.getHours()+":"+d.getMinutes();
            $('.datepicker').val(datetext);
        },
    });

 


On occasion, you’re going to have some mammoth form that doesn’t validate properly with any Javascript validation library.   One event is when the form you are given to deploy has a lot of checkboxes and one of those checkboxes needs to be checked to be valid.  The easiest way to make sure this happens is to create a form submission even listener then if there’s at least one checkbox checked, it returns true at which time it triggers the form validation OR it sends the “e.preventDefault()” command, which will stop any further processes, in this case, triggering the form submission which would then trigger the validation.  It’s kind of pre-submit validation, but to me, it’s the fastest way to “piggyback” on the existing form validation if everything else works properly.

Here is a sample, and this is the form library that I think is incredibly reliable, clean, and very easy to use:

http://jqueryvalidation.org/documentation/

$("#mainForm").on('submit',function(e){

   if ( $("input[type='checkbox']:checked").length > 0) {


   }
   else {
         e.preventDefault();

         alert("Please check at least one category you wish to be listed in.");
         return false;
   }

   return true;

});


$("#mainForm").validate();

This works well CDN’d with Symfony form projects.


Here’s how you can get the image width and height of an image file at a remote URL.

function getImgDims(url){
   var img = new Image();
   img.onload = function(){
      var rtnArr=Array;
      
      rtnArr['width']=this.width;
      rtnArr['height']=this.height;
      
      return rtnArr;
   };
   
}

This will return an a multi-element associative array containing values under “width” and “height” as its keys.


All browsers have their idiosyncrasies — Internet Explorer had so many Microsoft is changing its name.

Here’s another one of a hundred browser “idiot syncrasies” that wasted so much time.  I’ve always developed sites first for Firefox then Chrome then found I had to add more hacks on top for IE, the infamous “shiv” code still makes me shake my head — if only we didn’t have to waste so much web development time worrying about all those browsers and devices and focus on the solution.  If only we’d know the standard tires would work on every standard road!  Things are getting much better and standardized, but even the surge of Chrome users may find the latest updates are causing interface issues and new UX challenges.

One issue is dealing with forms, autofills and validation.  For Google Chrome, I wasted hours with a form auto fill behavior and discovered you have to set  autocomplete=”false”  instead of to “off” for the fields you don’t want the browser to automatically reset and take over.   It can cause real problems with certain forms that keep defaulting to the wrong state in a credit card because a user entered a different state elsewhere and didn’t notice it.  This could be the difference between making a sale or a customer leaving because the credit card information is incorrect.

For web developers out there, you all know Stack Overflow, this is the usually the first place web developers look when they are stumped, this is one of those times where once I realized it was a Chrome issue it took me two minutes to Google the problem, find the problem on Stack and implement the change.  It’s great when you encounter an odd problem and find the exact solution so quickly.

Here’s the link for more information, I hope this helps someone save some time!

http://stackoverflow.com/questions/15738259/disabling-chrome-autofill