Recent Posts
Tags
 

Thomas’ Toolkit

Cleaning Contact Information with MySQL

11:03 19 May in Contact Management, Data Cleaning, MySQL, PHP, REGEX, Thomas' Toolkit by Thomas

Last week I came in to bat clean up on a large data project.  It was a long lead up before it got to my desk.  A database of some 30 thousand contacts was verified by a group of individuals who actually took the time to call and email every contact to see if their information was still accurate, a truly herculean effort.  But, in the end, because there were many people working on the project, there was a wide array of inconsistencies in files and the way they kept their data.  In the autopsy phase of the project, we discovered ways to prevent that sort of problem, but no sense wasting time on 'woulda, coulda, shoulda', and no looking back now.  I had to clean what I was provided. To start, I uploaded all the contacts to a new MySQL table.  This required that all data from multiple sources get homogenized into a single CSV file to normalize all field data.  There after, I like to set all known bad entries to NULL. Set as Null: update table_to_clean set website = NULL WHERE (website = 'no' OR website = '' OR website = 'n/a') The website field had several different values, depending on who made the entry.  I did this for the other fields as well. The email address field was the most important, as this list is going to drive electronic contact going forward.  I found this expression that does a good job of identifying a proper email address format: '^[A-Z0-9._%-]+@[A-Z0-9.-]+.[A-Z]{2,4}$' First, to find all bad email addresses: SELECT...

jQuery Mobile

22:27 14 May in JavaScript, jQuery, JSON, Thomas' Toolkit by Thomas

I've been on a jQuery Mobile based product for almost a week.  Its a revamp of a project I did 2 years ago. The original system ran on Wordpress just for the HTML shell, and my own custom JS, heavy on the AJAX, then later on jQTouch for mobile.  Its been a solid performer for about 2 years now, and a pretty hot item our clients, so there must be something to it. But, times change, and I'm feeling that jQuery Mobile is evolved enough now to take a real run at it. So far its been easy enough to learn, once you get by the whole 'pageinit' thing.  I'm only adapting the system, not rewriting it yet.  This job is "old brain in new body".  For the moment, I've found this works to call custom JavaScript for each page: $( document ).delegate( "#my_page_id",  "pageinit",  function() { $.ajax(...

Webmin, Linux Firewall, and China

08:00 02 May in Firewall, Linux, Security, Thomas' Toolkit by Thomas

Here was the situation. Our server got hit by multiple login attempts from China about a week ago. Our security of course keeps these attempts from being successful, but the shear volume of attempts slowed us right down. After dealing with the immediate attempts to get in, and restoring service, I had to find a more permanent way of dealing with the attacks. Since the time of the attack, I've been reviewing access logs on a daily basis.  Access attempts continue, with 5-6 machines attempting 1000's of times each to get in, guessing usernames and passwords.  Over 85% of the attempts originate from China...

jQuery Version Check: live() Vs. On()

12:34 31 January in Compatibility, JavaScript, jQuery, Thomas' Toolkit by Thomas

Recently I started work on my own jQuery plugins.  I do love that jQuery.  But, as I was working, I came to see the difference between on() and live(). I'm reading that live() is depreciated, so in order to make my plugin a bit more universal, I wrote a function to detect the jQuery version being used, and act accordingly.  Here it is: function useOn(){ var jRequired = '1.7.1'.split('.'); var jInstalled = jQuery.fn.jquery.split('.'); var on = true; for(x in jInstalled){ if(parseInt(jInstalled[x]) < parseInt(jRequired[x]) && on==true){ on = false; } } return on; } If the jQuery version is 1.7.1 or higher, this function will return true. If lower, it will return false. I call the function when I'm getting ready to set click functions on some of my objects. I couldn't find anything like it will poking around Google, so hopefully someone else finds this helpful. ...

United States JSON state list

10:28 04 February in JavaScript, JSON, Resources, Scripting, Thomas' Toolkit by Thomas

In case anyone needs it. var US = { "AL":{"count":"0","name":"Alabama","abbr":"AL"}, "AK":{"count":"1","name":"Alaska","abbr":"AK"}, "AZ":{"count":"2","name":"Arizona ","abbr":"AZ"}, "AR":{"count":"3","name":"Arkansas","abbr":"AR"}, "CA":{"count":"4","name":"California ","abbr":"CA"}, "CO":{"count":"5","name":"Colorado ","abbr":"CO"}, "CT":{"count":"6","name":"Connecticut","abbr":"CT"}, "DE":{"count":"7","name":"Delaware","abbr":"DE"}, "DC":{"count":"8","name":"District Of Columbia","abbr":"DC"}, "FL":{"count":"9","name":"Florida","abbr":"FL"}, "GA":{"count":"10","name":"Georgia","abbr":"GA"}, "HI":{"count":"11","name":"Hawaii","abbr":"HI"}, "ID":{"count":"12","name":"Idaho","abbr":"ID"}, "IL":{"count":"13","name":"Illinois","abbr":"IL"}, "IN":{"count":"14","name":"Indiana","abbr":"IN"}, "IA":{"count":"15","name":"Iowa","abbr":"IA"}, "KS":{"count":"16","name":"Kansas","abbr":"KS"}, "KY":{"count":"17","name":"Kentucky","abbr":"KY"}, "LA":{"count":"18","name":"Louisiana","abbr":"LA"}, "ME":{"count":"19","name":"Maine","abbr":"ME"}, "MD":{"count":"20","name":"Maryland","abbr":"MD"}, "MA":{"count":"21","name":"Massachusetts","abbr":"MA"}, "MI":{"count":"22","name":"Michigan","abbr":"MI"}, "MN":{"count":"23","name":"Minnesota","abbr":"MN"}, "MS":{"count":"24","name":"Mississippi","abbr":"MS"}, "MO":{"count":"25","name":"Missouri","abbr":"MO"}, "MT":{"count":"26","name":"Montana","abbr":"MT"}, "NE":{"count":"27","name":"Nebraska","abbr":"NE"}, "NV":{"count":"28","name":"Nevada","abbr":"NV"}, "NH":{"count":"29","name":"New Hampshire","abbr":"NH"}, "NJ":{"count":"30","name":"New Jersey","abbr":"NJ"}, "NM":{"count":"31","name":"New Mexico","abbr":"NM"}, "NY":{"count":"32","name":"New York","abbr":"NY"}, "NC":{"count":"33","name":"North Carolina","abbr":"NC"}, "ND":{"count":"34","name":"North Dakota","abbr":"ND"}, "OH":{"count":"35","name":"Ohio","abbr":"OH"}, "OK":{"count":"36","name":"Oklahoma","abbr":"OK"}, "OR":{"count":"37","name":"Oregon","abbr":"OR"}, "PA":{"count":"38","name":"Pennsylvania","abbr":"PA"}, "RI":{"count":"39","name":"Rhode Island","abbr":"RI"}, "SC":{"count":"40","name":"South Carolina","abbr":"SC"}, "SD":{"count":"41","name":"South Dakota","abbr":"SD"}, "TN":{"count":"42","name":"Tennessee","abbr":"TN"}, "TX":{"count":"43","name":"Texas","abbr":"TX"}, "UT":{"count":"44","name":"Utah","abbr":"UT"}, "VT":{"count":"45","name":"Vermont","abbr":"VT"}, "VA":{"count":"46","name":"Virginia ","abbr":"VA"}, "WA":{"count":"47","name":"Washington","abbr":"WA"}, "WV":{"count":"48","name":"West Virginia","abbr":"WV"}, "WI":{"count":"49","name":"Wisconsin","abbr":"WI"}, "WY":{"count":"50","name":"Wyoming","abbr":"WY"} }; [Generated using jQuery and the US Postal Service. ;) ]...