Tuesday, April 14, 2009

Wow armory bank parser and some other things

I made several programs while playing world of warcraft. He's three of them.

Bank Parser

While I was playing the World of Warcraft with my friends, we formed a guild. We used the guild vault to pool resources in a sort of communist style system. My guild leader wanted to ensure that everyone was being generally fair with their contribution and usage of resource. So I endeavored to write a program to analyze the guild bank log from wowarmory.com. Getting at the data is not too hard, as the whole website is sent as XML and then transformed in the browser with XSLT. I wrote one program to download the XML pages and load and display them. The code can be found on Github. I'm not posting a binary because this project has not been updated since Blizzard switched to using Battle.net accounts for log-in. So currently it does not work, but it should not be too much trouble to update it.

Flying Mount Macro

While this is by definition less than 255 characters, that is why it was so difficult to make.
/run m={1,34,35,40};z=GetZoneText();if IsFlyableArea() and(((z~="Dalaran")or(GetSubZoneText() =="Krasus' Landing"))and(z~="Wintergrasp"))then m={11,26};end /run CallCompanion("MOUNT",m[math.random(1, #m)]);
It will randomly select a ground mount while in old world, dalaran (but not Krasus' Landing), or wintergrasp. While in any other part of northrend or out land, it will select a random flying mount. It is kinda cumbersome to use, as the mounts are specified by their position in the mounts window. The first m= is ground mounts will the second is flying mounts. This only has to be updated every time you get a new mount ;-). I know there are addons such as Mounted that give you a nice UI and don't break every time a new mount is added, but I found my macro to be more reliable once I got it working.

Wowhead downloader and scanner

Wowhead.com has a ton of useful information on it. For certain tasks it can be handy to have a copy of their website on your hard drive. For example, the bank parser could be augmented to see if any materials lying around could be crafted into an item. Pointing a conventional web spider at wowhead does not work because of the site's intense usage of javascript. However I noticed that the javascript used to define links to other pages was not too far from being JSON (duh, since JSON is just a subset of javascript). For all the details see the code on Github.

Monday, January 26, 2009

Lazy Loading Collection

So I came across an interesting situation in a program I was writing recently. I had a bit of code that takes a list of image URLs to download and display. It shows the UI immediately while it downloads more pictures in the background. However in some cases each URL needs to be transformed a bit and each transform required another web request. If I did all the transforms before starting to download the first image there would be a large pause before anything could be shown to the user. Fortunately, my image download and display code took an ICollection interface instead of a concrete type. So I made a little collection that would lazy load the transformations. Now no matter how many untransformed images there are, it will always take about the same amount of time for the first image to be shown to a user. My collection ended up being not specific to this program. You can take a look at the code on GitHub. Just a heads up: there are several methods that are not supported because I did not need them and they would be difficult to implement. For example, how do you implement Contains when not all the transformations are complete?

Thursday, July 10, 2008

How to disable download zone flagging in Firefox 3

You know that really anoying behavior that Windows Xp SP2 added where downloads warn when you try to open them? The one that brings up the dialog titled "Open File - Security Warning" with the message "Do you want to run this file"? For some reason the Mozilla guys thought it would be a good idea to add this "feature" it to Firefox 3. Fortunately it's not too hard to disable the Attachment Execution Service behind this. According to the Microsft article about the service, you can disable the service by:

  1. Opening regedit.exe.
  2. Navigating to HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Attachments.
  3. Create (or set) the DWORD value SaveZoneInformation to 1.
This post is mostly for my future reference, but I hope you find it useful too.

Saturday, August 25, 2007

Url Reservation Modifer

Today I am releasing a tool that makes it easy to create URL reservations. Why would you want to do that? If you try to use the HttpListener class in .NET as a limited user, you need a preexisting URL reservation. Otherwise you will get an access denied message. The documentation says to use the HttpCfg.exe tool to create these reservations, but it requires you to use the verbose SDDL language. My tool has an easy to use interface: Download the binaries and the source code at CodePlex.

Thursday, June 28, 2007

Facebook Graph Theory

After the AP test, all I had left to do in Calculus BC was to give a presentation at the end of the year on some mathematical topic. I have always been interested in graph theory, and my partner thought it was an ok idea. Then I had to find some way to make this abstract subject tangible to my peers (the people doing pi had it easy; all they did was give everyone some pie). Just about everyone at Mountain View High School is in a social network. 15 of the 20 people in our Calculus class are in Facebook. So I wrote a few tools to pull the data out of Facebook and make some pretty graphs. Implementation details after the pictures.

This is a graph of the people in my Calculus class. Nothing that interesting going on here.


My cousin Chris went to Bellarmine while I went to Mountain View. Our mutual friend T.J. went to Bellarmine for two years and then Mountain View for two. Below is Chris's graph. People who go to Mountain View are in blue. You can see T. J. is better connected to Chris's friends than my group of friends.


Implementation Details

To get a social graph, I used the FQL statement shown below (replace {0} with the current user's uid). Microsoft's Facebook Developer Toolkit made it pretty easily to talk to the Facebook rest service.

SELECT uid1, uid2 FROM friend where uid1 in (select uid2 from friend where uid1 = {0}) and uid2 in (select uid2 from friend where uid1 = {0})
I wrote a small Visual Basic app that generates a graph definition file to feed into Graphviz. I ran neato, twopi, and fdp and chose the best looking graph.

I ran into a few issues getting this to work. When I created graphs with 500 nodes, the images were so big (tens of thousands by tens of thousands of pixels), the only program I could use with out freezing my computer was IrfanView. When I got to about 1000 nodes, the Graphviz programs would fail, citing a malloc error. It was hitting the 2GB user memory limit on 32-bit processes (I could have run a 64-bit version on my Core 2 Duo/Vista x64, but there are no Windows x64 builds). Also, people with large number of friends (>800) have trouble pulling down all the data from Facebook.

Tuesday, June 05, 2007

Yearbook

To anyone coming to my site via the MVHS yearbook, welcome! I intend to keep this URL under my control indefinitely. This should ensure that you all are always to find me if need be.

Monday, March 05, 2007

MSBuild Runner

Have you ever wanted to quickly compile a Visual Studio solution or project without opening Visual Studio? Well, now you can! I have been using my MSBuild Runner tool for some time now, and I find it pretty helpful. It sports Windows Explorer integration and supports building for any version of the .NET Framework that comes with MSBuild (currently 2.0 and the 3.5 CTP come with a version of MSBuild). Feel free to send me suggestions and feedback at the CodePlex site.