Archive for the ‘Programming’ Category

GPS Conversion Utility

Saturday, December 27th, 2008

Last night I was preparing to load up a lot of GPS markers into the Garmen eTrex and Magellen Maestro 4040. The problem I had was that the Geocaching site only allowed me to download a LOC file of about 20 locations. With a 25 mile radius, this left me with almost 90 files to combine into one. On top of that, the Maestro doesn’t understand LOC files, and the eTrex didn’t come with software to import/export waypoints.

The software for the Maestro was able to understand GPX files. I created a utility to search for all LOC files within a folder, combine them, and save them to a GPX file. It took me a few tries before I got the format setup correct. Once it was all setup, I was sailing fine and saw all the points show up in my local area on the Maestro.

LOC 2 GPX Converter Screenshot

LOC 2 GPX Converter C# Source Code

I then found some software called Expert GPS that claimed to work with the Garmin eTrex (but not with the Magellan Maestro). Much to my surprise, I was able to import the same GPX file and transfer the coordinates to the eTrex using the 30 day trial software. I had a limit of only 500 waypoints, so I had to cut the list pretty short. Switching between types of data to display continued to make the Expert GPS crash.

With both GPS devices in hand, my nephew and I headed out to find some treasure. We drove around into dead ends and discovered a bit of my neighborhood. When we got out to walk around, a police officer pulled up behind us with lights flashing. I was a bit confused until he started pointing to six guys driving around on ATV’s up by the power lines. I assume he thought we may have been with them at first. He got back in his car and we walked off.

We headed over to GCQVYX with the only information of “Lego Land Pearl Jam”. It didn’t make much sense. It took us over to the side of a local Wall-Mart. We saw a guard rail, some trees, and the pole to a road sign that must have been taken down recently. We spent about 20 minutes, but couldn’t find the whereabouts of the cache. We decided to head back and grabbed a bite to eat at Burger King.

Looking at the details after we got home, it appeared that the guard rail was the main thing we should have concentrated on, and to look for a micro cache. In turn, it would have led us to a second cache. I may return tomorrow to take a second look. There are a few problems with what we have available. First, the eTrex is often only good to about 20 feet at best (it’s old). Next, waypoints that I saw in the Magellan didn’t show up in the eTrex (500 limit). Maps of roads in the Magellan is severely out dated, or were just never entered. Even main streets are not present. And last – the lack of details. I may start looking into creating a lot of text files (one for each cache) and saving them to my phone. This way, we can look up the details in a text file when we arrive at each cache to get some clues and background information.

The optimal solution would be to just get a new GPS that can hold more waypoints, be a bit more accurate (within 3 feet), contain current maps, and allow me to import topographical, arial, and/or street maps of the area. Something like this would be around 300 to 600 dollars (ouch). Since I’m broke, I’ll make due with the toys I already have.

Red-Gate Goodies

Tuesday, October 21st, 2008

Last month I had looked into tools to notify me when any of the databases at work went off-line. I primarily looked into a beta of SQL Response by Red-Gate since I would automagically own it when it would finally be released. The SQL Toolbelt bundle that I have would include the software. I found many problems and made recommendations. After the beta was over, the Red-Gate folks contacted me and asked for my address so that they could send me a T-Shirt. Today I came home to see a 6″ cubed red cardboard box. Inside was plenty of shredded documents and a shirt (odd packaging for a shirt). I took out the shirt and discovered that it was wrapped around a coffee/tea mug – which within contained a pen, some mints, and a 1 GB USB thumb drive. I gave the drive to my wife since she loves the color red. Originally shocked that they would give me a t-shirt, I was simply impressed that they threw in all the other goodies.

File Tree Copier

Sunday, September 28th, 2008

As I use this little utility that I made on each computer system, I find the need to add more features, handle specific scenarios, or simply fix bugs. The software is actually becoming very stable and flexible. The latest changes to it are:

  • Add the ability to cancel what it is doing.
  • Disable “Copy” button, and make all text fields read-only.
  • Show a list of stats (File total/copied/skipped, folder total/copied/skipped, error count)
  • Add error handling on everything.
  • Remove stack-trace in output since it doesn’t really help with anything.
  • Provide ability to start half-way through the job.
  • Give status messages of what is going on.
  • Only list file name instead of full path with each file.
  • List the folder path above the file.
  • Change the layout to be more friendly with very long file/folder names.
  • Change how files are retrieved/compared from destination to get list all at once rather than individually.

File Tree Copier Screenshot

I’m debating if I should sell this thing for a few bucks. It is a useful utility that has probably saved me hours of head-ache with normal windows copy/paste operations over the network. I admit that I’ve been copying hundred of Gigabytes, but perhaps someone else would find it useful as well.

One interesting thing that I saw is that regardless of connecting through the Wirless or wired LAN, the destination seems a bit slow. Not by much I guess. I’ll need to find a way to measure the transfer speed between each computer and the NAS to be certain.

After everything is copied to the NAS, the next step will be organization. Part of this would involve comparing files to find duplicate information. I am sure that another utility will come about from this adventure as well. I guess I should start looking into making a website of some sort to make these utilities available.

Tic-Tac-Toe

Saturday, September 27th, 2008

In the game of tic-tac-toe, a single row has many different possible states. Each cell can either have X, O, or remain blank. It is a trinary number system. The number of unique states in one row is 3 to the power of 3 (3*3*3), or simply 27.

I am looking into this because I am interested in making a game of tic-tac-toe in an environment where image size and count mean everything. The less data that is needed to be transferred, the better. I could create an image for the entire grid, but that would result in 3 to the power of 9 images (19,683 images). I could dumb it down to just 3 images of an X, O, or empty spot, but the format of what is available would require me to use more resources to display 9 separate images at one time. The optimal method to use limited resources is to display 3 rows as 3 separate images.

I could go ahead and create 27 different images to load up in each row. However, the key idea here is the use less data that is needed to be transferred. My take on it is that I’ll use the same image for each row, but only show part of that image. So if I have an image that says “XXOXOXOXX”, and I want to show “XOX”, then I’ll stretch the image and center it on the “XOX” so that all of the other characters are outside of the visible area.

This is good, but I had one last thing to focus on. 27 different images all streamed together would result in an image with 81 characters. Surely their is a lot of repetitive characters? Take my example: “XXOXOXOXX”. You’ll notice that “XOX” is repeated three times, and “OXO” is repeated twice. I could try eye-balling it to cut it down to size, but we have computers for that sort of thing.

I started generating a random string of ” “, X, and O with 81 characters. As soon as I found a string that suited all possabilities that a row would have, I would generate another random string with 1 less character. It took much longer as I tried to generate less characters. I could only get down to 29 characters “O-OOX-O—X-XXX–OXO-XOXXOOO-”. This was very interesting to me because I was starting to see a significant pattern here. 29 is very close to 27, and as I noted earlier, the total number of possible combinations is … 27.

Doing the same for 2^2 is something I could do in my head. Possible combinations are 00, 01, 10, and 11. I came up with 10011. Only off by one (2^2 = 4), but if I wrap the text to repeat itself, I get “1001″ – 4 characters! Note “11″ is “wrapped” with the two ends. Now, with that knowledge in hand, look at the pattern that I had with 29 characters. Notice that the last 2 characters matches the first 2. From here, I can wrap the text around to reduce 2 additional characters resulting in 27! My final pattern was “O-OOX-O—X-XXX–OXO-XOXXOO”.

This reduces the total size of my image by almost 67%. The “wrapping” effect already happens with images in the environment that I work with and is known as “tiling”. If an image does not cover an entire area, the same image is placed next to itself, essentially causing a tiling effect over the whole area.

The next steps are to actually make the image, detect where a person has touched the game, and map the image to reflect the actual state of the game in each row.

At one point, I did try creating a string of values and incrementing them as a trinary number (—, –O, –X, -O-, -OO, -OX), however this actually took a lot of time to do. After letting it run for a couple hours with no results, I abandoned it all together and went for a randomized “fuzzy” approach. Randomly, I was finding different combinations of 29 characters each in about 2 minutes each. The lack of speed may have been because I was dealing with strings rather then an array of numbers. I’ll look into different possabilities next time.

Hero me three

Wednesday, May 17th, 2006

Sometimes, I surpass my own geneouse.  Something got done today that was an amazing solution to a difficult problem regarding cyclic redundancy.  The side effect of this solution has sereouse potential to solve some very aged and hard problems that have been left hidden away in a corner.

All of this has to do with the implementation of Http Modules within ASP.Net.  With these special modules, you can catch the process of a web page before the web server processes it in its own normal way.  The power of them is so strong once they are understood that you can make all kinds of tweaks that were never possible before.

So today, I solved an immediate problem, impressed the manager on how I solved it, and collaborated on how we could use the method to solve some past feature requests.  When I left for home, I already had a working solution up and running on my local machine in the office.  What a day.

Learning ColdFusion with BlueDragon

Saturday, May 13th, 2006

I’ve been tasked to learn ColdFusion this weekend. If you see any web pages on the internet where the name ends with CFM, those are ColdFusion web pages. I don’t have any software, and a server wasn’t provided for me to work with. I was a bit confused on how I was supposed to learn the stuff. We have a new guy comming in on Tuesday and I need to know ColdFusion by then so I can help him get up to speed.

I did some searching on the internet. I found a product called BlueDragon that can run web pages with ColdFusion tags in them (ColdFusion Markup Language – CFML). It can run on its own on port 8080 by default, and you can also map it to Microsoft’s Internet Information Server (IIS). The best part of the deal is that this server is free.

I found a few websites with ColdFusion tutorials. I also found that Macromedia has a website that I could use as a reference for everything CFML. I always looked down at ColdFusion as if it were almost a joke. When HomeSite started supporting ColdFusion tags, I was busy learning Active Server Pages (ASP). Thank goodness for that, as ASP has caught on greatly compared to ColdFusion.

It seems that ColdFusion has finally caught up with me. The good news is that I already know so many programming, scripting, and markup languages. This is making it easier to catch onto CFML.

Open-Source

Thursday, May 11th, 2006

I created an account for myself over at SourceForge. This is a website that many people use to provide open-source software on. Many services are available such as defect tracking, forums, tasks, screenshots, and even some source-control using CVS.

The whole reason I’m looking into SourceForge is that I want to go public with my Automagic Podcaster software soon that I use with Dreamy Audio. I’m looking into a couple of things before I do it. Besides places to host the files and collaborate with others, I also need to look into licensing.

Although I wish to distribute the code as free open-source software, I also need to protect it. I want to allow people to modify it, but I don’t want them to package it up and resell it. I also want credit where credit is due. I also don’t want people to redistribute there modified version without stating what they have modified from the version that they received.

There are many licenses out there. I just have to find the rite one that matches my intent.

Sneaky Tags

Tuesday, May 9th, 2006

I’ve started to have a look at the tags in other MP3 sources other then the files that I make myself for DreamyAudio. The purpose is to test the compatability of my software with MP3 files. It’s like throwing a monkey wrench into a running motor. I started off with DarkCompass and found a few bugs that I had fixed quickly.

During this time, I stumbled upon four ID3v2.3+ tags that I hadn’t seen before (PCST, TDES, TGID) in the DarkCompass podcast. I haven’t found any documentation on these tags when googling them, but from the content within, they appear to be related specifically to podcasts. I came upon similar tags (TID, TDS, WFD, TDR) in another podcast that was using ID3v2.2 tags. Thankfully, the 2.2 tags were documented on many sites on the internet.

One thing that grabbed my attention was the content withing the tags of an old podcast that I grabbed off of Odeo. It actually had the URL of my feed in it. I started thinking a bit about this and realized that if I redistributed the MP3 file to friends and such, that eventually it could be traced back to me. It seems that Odeo had dynamically threw in its own ID3 tags that identify my account.

Perhaps in the future, ID3 tags (or any embedded metadata) could become a privacy concern. Imagine if more sensitive data was stored within those tags such as email addresses, phone numbers, or any sort of contact information without your knowledge and you let your friends get a copy and listen to it. Further down the line after friends sending friends sending their friends the MP3 file, someone gets a hold of it who knows how to read all of that data. Now a stranger has your personal data and could sell it or make use of it in malicouse ways.

Ok, so I’m really going over the edge here and blowing a little thing up to infinite proportions. Who cares if the alien Captian Zorgon from the planet TH-87w discovers our planet and designates you as the offender of the careless audio. What if he makes use of a tool specifically crafted for him to carry out his will of removing any source of that aweful sound and targets you just because your email address was in a small tag in the file.

Back to reality. It’s just a little thing really. I’m just a bit unsettled that someone had inserted some information with my account name as part of a url feed into the ID3 tags without my knowing.  Still, maybe it isn’t Odeo that did it.  Maybe iTunes inserted this data in there behind my back when it downloaded the MP3 file from the feed.  If that is the case, iTunes is the culprit for exposing that extra information.

Variable Bitrate

Monday, May 8th, 2006

I’ve been having a go at improving the accuracy and format of my DreamyAudio podcast. The accuracy being the part where I read information embedded within the MP3 files.

I decided to challenge myself and display the playtime for a mp3 file encoded with a variable bitrate (VBR). It was tough just trying to detect that the file had a VBR. It’s actually simple now that I figured it out.  You need to detect if an Xing header is present in the audio data a few bytes after the MPEG header.  The tricky part is figuring out what position those bytes are at in the file.
After figuring out if the file has a VBR, I noticed that the estimated playtime is out of wack. It’s based on a constant bitrate (CBR). So now I’m plagued with a problem.

I assume that I could go ahead and read through the individual audio frames and tally the bitrates from each one and divide it by the number of frames found. The thing is, there are thousands of frames. Perhaps I can find a way to read the first few hundred and give an estimate based on the number of bytes remaining.
Bah. No time for it today.

HTTP Conditional Get

Sunday, May 7th, 2006

I was looking into a way to cache my generated pages on the server with PHP. I couldn’t find anything to do it on the server-side, but I did find something to prevent a client from asking for the page via client-side caching.

When a web browser requests a page for the first time, it will save a copy into its local cache. If the person visits the web page a second time, the browser will send the date and time when the page in the local cache was originally retrieved. The server checks the date and responds with either a new page, or a message stating that the page hasn’t been modified since the last time the request was made.

This helps out servers to decrease how much bandwidth is being sent accross the internet. Some of us are charged extra if we go over so many gigabytes per month. It also helps my server from doing unnecessary processing of scripts.

I was working out a way to take care of this. PHP has a method to access the client headers individually called getallheaders(). The problem is that this only works on apache web servers. I’m testing things here at home on an Internet Information Server (iis). Although my website is hosted on apache (I think), I still would rather have support for multiple platforms.

I continued to run through some problems until I found a PHP implimation of conditional get. It was pretty easy to impliment and it worked immediately. The method expects a parameter of a date to compare. I read the date that an MP3 file was last modified and passed it in there. The method did the rest of the work telling the web browser that the information had not changed.

I didn’t realize that this term, “Conditional Get”, was coined for this pattern. The PHP implementation referred to a very good article about it called HTTP Conditional Get for RSS Hackers. It goes into detail about the whole process of it all. It’s amazing how much detail you can get into that amounts to just a few lines of code.

Tomorrow I’ll look more into caching data on the server. I found a method (md5_file()) to get a hash of a file that I can use to see if the files contents have changed since the last time I created cached xml documents and images referring to its contents. Reading all of that data from MP3 files constantly could perhaps have a toll on the servers performance that I want to avoid.