Archive for the ‘Programming’ Category

Gif Stopper :: Chrome Extension

I love a good animated gif and most the time I just view them and move on. But now that I have joined Google Plus, animated gif have turned into an eye sore.  Okay, they’re only annoying when you are trying to read something and there is elephant that keeps bouncing up and down on a trampoline.  So I decided to do something about it.

Introducing my latest Google Chrome extension:  The Gif Stopper.  This will stop an animated gif in its tracks by just pressing the escape key.

Okay, I can’t take total credit for it.  The bread and butter of the extension what written by Johan Sundström and he posted it on userscripts.org.  I just turned it into a Chrome Extension.  The code for the extension including Johan’s code is posted on my github page.

Enjoy.

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

I don’t always…

I love this meme.

Fix Kaspersky AntiVirus False Positive Detection of AutoIT Applications (Trojan-PSW.Win32.Autoit.m)

Our company just switched from Symantec antivirus to Kaspersky a few weeks ago and I noticed that every application that I have written and compiled with AutoIT ended up getting falsely detected with Kaspersky as a virus.  Since I wrote each application, I know for a fact that there isn’t a Trojan in my code.  So I started a live chat with Kaspersky’s support staff and here was our solution.

1) Open up the Kaspersky Administration Kit and navigate to Managed Computers > Policies and then right click on the Protection Policy that you want to update and then select Properties.  For me the policy name is Protection Policy – Windows Workstations.

2) Next Click on the Protection Tab

3) Click on the Trusted Zone button

4) Click add and fill out the rule description as follows:
Properties: Threat Type
Comment: <What ever you want to name the Rule> AutoIT False Positive
Rule Description:
select object: Trojan-PSW.Win32.Autoit.m
Component: any

5) Click Ok then OK.

This will then automatically update all of the clients and all of your AutoIT application will run and not be detected and deleted as a virus.  If for some reason you AutoIT applicaiton are flagged as a virus other than Trojan-PSW.Win32.Autoit.m then you can just replace that parameter with above.

Note: This will now allow any valid Trojan-PSW.Win32.Autoit.m virus to go undetected by Kaspersky.  I write a lot of my script around the office in AutoIT so this was a chance I was willing to take.

 

 

Beerware License

My new favorite software license.

/*
 * ----------------------------------------------------------------------------
 * "THE BEER-WARE LICENSE" (Revision 42):
 * <motersho@gmail.com> wrote this file. As long as you retain this notice you
 * can do whatever you want with this stuff. If we meet some day, and you think
 * this stuff is worth it, you can buy me a beer in return Terry Moore
 * ----------------------------------------------------------------------------
 */

via Wikipedia

Back To School

Back To SchoolWell after managing to stay out of a class room for more than 10 year I have finally decided to go back to school.  I have enrolled in a Beginning and Intermediate Java programming class at WakeTech here in Raleigh.  And at only $70 a class, I would be stupid not to.

Why Java?  Well, the application that is developed by the company that I work for is written in Java and I figured if I ever want to make the switch from system/networking engineer position to more of a developer role then now is the time. Plus I have already started doing the Installshield development for our next software release.  So I guess I am hoping to extend that “developer” role in to some basic Java work.

It’s kinda ironic that I would be wanting to switch to a developer position, 10 years ago while in college I was a CS major and hated the thought of having to take programing classes.  Now the older, possible wiser me, is seriously kicking myself for not just sticking with it.

I have taught myself several languages in the past (PHP, Python, AutoIT, HTML, JavaScript,  InstallShield, etc)  but I don’t feel that I have a full grasped every aspect of each language.  Meaning that I can develop in it but I don’t know if what I am doing is the best practice or not.  This is something that I hope to get from this class.  Plus I have tried to teach myself Java for a quick project at work and failed miserably.  I quickly turned to Python to get the job done.

So with that I leave you with the Java Hello World that we did last night in class (This is done from memory so it may be wrong.)

public class Person
{
    public static void main( String[] args )
    {
         System.out.println('Hello World');
    }
}