Archive for the ‘Ajax’ Category

2010-11 NHL Roster by Birth Location

I was at lunch a few weeks ago at a sports bar with several co-workers and started discussing sports with one of our developers.   Our discussion led to the question about how the NHL consisted of players from so many different countries compared to other US based sports.  When I got back to work I did a couple of Google searches looking to see if someone already had that information for me.  But the search didn’t turn up any results (at least not for this year ).  But it did lead the the NHL.com website that had all the information about the players but it was displayed in a HTML table that span over 30 webpages.  This is where being a programmer pays off.

I decided to write a quick script to parse out this data and place it in an CSV file.  I was going to write it in Python but since I was in Windows I decided to to just use my favorite Windows scripting language, AutoIT.  Below you will find the complete script that I used to loop through the 3o webpages on NHL.com and grab the contents of the 2010-11 players bio table.

#include <Array.au3>
#include <IE.au3>
#include <File.au3>
 
$csvFile = "c:\temp\players.csv"
 
for $i = 1 to 30
 
	$ieObject = _IECreate ("http://www.nhl.com/ice/app?service=page&page=playerstats&fetchKey=20112ALLAASAll&viewName=bios&sort=player.birthCountryAbbrev&pg=" & $i)
 
	$table = _IETableGetCollection ($ieObject, 3)
	$aTableData = _IETableWriteToArray ($table, True)
 
	FileOpen($csvFile, 1);
	For $r = 1 to UBound($aTableData,1) - 1
 
		For $c = 0 to UBound($aTableData,2) - 1
			FileWrite ($csvFile, """" & StringStripWS($aTableData[$r][$c], 3) & """")
			if $c = 18 Then
				FileWrite ($csvFile, @CRLF)
			Else
				FileWrite ($csvFile, ",")
			EndIf
 
		Next
 
	Next
 
Next

Note: This doesn’t do any error checking.

I then imported the data to a MySQL database and ran couple of PHP scripts againts the data to get these results.

Here is the number of players in the NHL broken down by birth country.

Country the NHL players were born in.

AUT: 3 BLR: 3 BRA: 1
BRN: 1 CAN: 482 CHE: 3
CZE: 39 DEU: 10 DNK: 6
FIN: 22 FRA: 1 ITA: 1
JPN: 1 KAZ: 1 LTU: 1
LVA: 4 NOR: 2 POL: 1
RUS: 26 SVK: 12 SVN: 2
SWE: 54 UKR: 4 USA: 211

Another stat that I though would be interesting was to find out what state the US born NHL players came from. So here it is:
State that US born NHL player where born in.

AK: 6 CA: 8 CO: 3
CT: 8 DE: 1 FL: 1
IL: 10 IN: 2 MA: 17
MD: 1 MI: 34 MN: 41
MO: 3 NC: 2 ND: 3
NE: 1 NH: 3 NJ: 4
NY: 33 OH: 2 PA: 14
TX: 1 UT: 1 WA: 2
WI: 10

Reddit Hover Craft Update v1.3

I put the finishing touches on the Reddit Hover Craft Google Chrome Extension.  This version, 1.3, addresses some of the issues that were brought up in previous releases.  Mainly this extension fixes the images popup location so that the image will either popup above or below the link that is being hovered over.  Previously it would only popup below the link cause and link that we was located low in browser window to not be fully shown.

I am hoping to address some other concerns that were brought up such as a not showing NSFW links (this will be able to be turned on and off in the options menu) and adjust the width of certain images and not just the height. Stay tuned

If you already have it installed then Google Chrome will automatically update you to the latest version.  If you don’t have it installed already you can get it here.

50 Excellent Ajax and JQuery Demos

9lessons has an excellent post/tutorial on using Ajax and Jquery to make you website come alive.

In these demos I had explained about jquery connectivity with MySQL database, Ajax implementation with PHP and Animation addons to your web pages. I hope it’s useful for you. Thanks!

More..

Set Windows Applications to Always Be On Top

Here is an application that I wrote that will allow you to select a running application and keep the windows running on top of all of the other applications.   This has been tested on Windows XP/2003/7.  I assume that it will work on Vista.  There isn’t an installer just download the executable and run the application.  The application was written in AutoIT and I have included the source code.  It is release under the GPL v3 license.

Application: RunOnTop.exe (142)
Source: RunOnTop.exe Source (162)

Screen Shot of RunOnTop.exe

Screen Shot of RunOnTop.exe