Fenux.Net - The Life of a Geek
Coding
Stories about coding that don't fit anywhere better.
Page 1 of 2
Posted on 4/21/2008 4:27 pm in Coding

What is it?

A "simple" program to sort files on a FAT file system. The target scenario for it is to sort the files and folders on a USB flash drive alphabetically, so they are loaded properly on devices that read them.

But why?

I bought a cheap car stereo about a year ago that plays MP3 files from either CD or from a USB flash drive or a compact flash memory card. However, it plays them in the order that they were added to the device.

Sometimes, Windows doesn't copy the files over in the right order, or if files are added at a later date, they stay at the end. When I listen to full albums in the car, it bugs me when they play out of order.

I searched around for a utility to correct the problem, but none of them supported recursion of subfolders. So I decided to make one.

Why it is necessary

The FAT file system doesn't support sorting directory entries. However, this is the only file system for USB flash drives that is widely supported. Unless the hardware or software accessing the device (like your computer) resorts them for display, the files will show in the order they were added to the directory.

How we get around it

To get around the problem, we cheat. By making a temporary directory, moving all the files to it, and then moving them back, in the new order, we effectively resort the directory. We then repeat the process in each directory listed. Sorter does this in reverse order, but not for any reason other than it makes the progress bar more accurate, because it knows how many files are there before it starts.

Why do you say it's a "simple" program

The actual sorting process is fairly straight forward. However, it offered me an excuse to play with technologies I hadn't gotten to use yet, like WPF (Windows Presentation Framework) and threading. I've also added basic support for localization, but as I don't speak any other languages, I haven't made any translations for it. With all that in mind, the program ended up quite a bit more complicated than necessary, but it doesn't hurt anything.

What does it require?

The program requires Windows XP or later and the .NET Framework 3.5. It will allow you to download the framework when you install it, so you don't have to install it beforehand.

Where can I get it?

You can download the file directly here. It also includes (most of) the source code for the program, if you want to take a look. I've released it as open source (see the included license for details).

Posted on 10/17/2007 8:04 pm in Coding

Adding sounds via javascript is a pain. After trying out several APIs, I finally came across SoundManager 2. It's the only API that worked immediately for me.

On a related note, I've also been trying to find some royalty free sounds for use in the project and I came across a pretty good source.

Royalty Free Music and Sound Effects Download the music and sound effects you need for your multimedia project today at Partners In Rhyme.

Posted on 2/24/2007 2:21 pm in Coding

I've been busy lately, and I think it's starting to get to me. At the end of December, I picked up a new project, a big project.

It all started when one of my existing clients from HolosTek called me up and had an idea. He wanted to get involved in starting a dating website, but he didn't know where to start. Of course, I agreed because I'm poor and could always use some extra money.

What I didn't realize, was how big the project was actually going to be. For the last month and a half to two months, I feel like I've done nothing but work, sleep, and spend a little time with Kortnee.

I have to admit the project has been a lot more interesting than I expected. I've learned a new framework for PHP development (CakePHP) and I've learned quite a bit about using AJAX for fast page loads and clever effects. I always enjoy expanding my skill set.

The project still has a little ways to go before it's open to the public, but you can see what's available. It's called The CandiShoppe. Also, if you're interested, you can signup to be notified when the site is open. The current plans include offering totally free access to everyone on the site for the first few months. After that time, certain features will require paying a subscription fee.

Posted on 10/18/2006 8:09 pm in Coding

From this article on The Old New Thing

Help text is not the place to put logic puzzles.

In Windows Vista, when you go to the System control panel, you are shown a number that describes your computer's rating. But are higher numbers better or worse? If I had a choice, would it be better to have a 1 rating or a 5 rating?

In earlier betas of Windows Vista, you had to have a degree in philosophy to figure this out. If you clicked the "Help" button on the System control panel page, you were sent to a page of help text that tried to explain the performance rating. When it got around to explaining what the number means, the text said, paraphrased, "When looking for software to run on this computer, you should choose programs whose rating is less than or equal to the rating of this computer."

So does this mean that bigger ratings are better?

"Well, if a program's rating is small, then the computer's rating needs to be bigger than that, so a program wants its rating to be as small as possible so more computers can run it. If my computer's rating is small, programs will be fighting to get a rating low enough that I can run it. That's a good thing for me, right? No wait, but what if the program I want has a high rating? Then my computer will need a higher rating. If my computer had a low rating, then that wouldn't be less than or equal to the program's rating. No wait, I got it backwards, it's the program that needs to be less than or equal to the computer, not the other way around. If the program's rating needs to be less than or equal to the computer's rating, then that means that the computer's rating needs to be greater than or equal to the program's rating. If my computer rating were higher, than it could run more programs."

"I think."

"Why can't they just say, 'Bigger numbers are better'?"

Posted on 10/13/2006 3:49 pm in Coding

I just came across an old blog entry from a Sun employee about their ZFS file system. The punchline really got me.

Although we'd all like Moore's Law to continue forever, quantum mechanics imposes some fundamental limits on the computation rate and information capacity of any physical device. In particular, it has been shown that 1 kilogram of matter confined to 1 liter of space can perform at most 1051 operations per second on at most 1031 bits of information [see Seth Lloyd, "Ultimate physical limits to computation." Nature 406, 1047-1054 (2000)]. A fully-populated 128-bit storage pool would contain 2128 blocks = 2137 bytes = 2140 bits; therefore the minimum mass required to hold the bits would be (2140 bits) / (1031 bits/kg) = 136 billion kg.

That's a lot of gear.

To operate at the 1031 bits/kg limit, however, the entire mass of the computer must be in the form of pure energy. By E=mc2, the rest energy of 136 billion kg is 1.2x1028 J. The mass of the oceans is about 1.4x1021 kg. It takes about 4,000 J to raise the temperature of 1 kg of water by 1 degree Celcius, and thus about 400,000 J to heat 1 kg of water from freezing to boiling. The latent heat of vaporization adds another 2 million J/kg. Thus the energy required to boil the oceans is about 2.4x106 J/kg * 1.4x1021 kg = 3.4x1027 J. Thus, fully populating a 128-bit storage pool would, literally, require more energy than boiling the oceans.

Posted on 2/25/2006 4:46 pm in Coding

From The A to Z of Programmer Predilections:

Word Salad Warren
Unlike Uri, Warren's native tongue is English; but it does him little good. Listening to Warren explain something technical is like listening to Dr Seuss - all the words make sense when taken individually, but assembled together they seem to be mostly gibberish with no coherent message. Such is Warren's talent for obfuscation, he can take simple concepts and make them sound complex; take complex topics and make them sound entirely incomprehensible. ...

Posted on 2/25/2006 1:59 pm in Coding

This was just too beautiful not to share, so here it is, almost in it's entirety.

From The Day Programmer vs. The Night Programmer:

Over the years I've come to the belief that there are two kinds of programmer in the world, no matter what technology they work with, lets call them:

  1. Day Programmers
  2. Night Programmers

Now - day programmers are the most prevalent in this industry, and you find them mostly in organisations which have historically tolerated a certain amount of inefficiency. Day programmers have the following characteristics:

  1. They are mostly led and seldom lead.
  2. The have trouble coping with complexity.
  3. They cannot visualise a solution.
  4. They don't load their development tools at home.
  5. Typically don't participate in the development community.
  6. See programming as "just a job".

If you are a night programmer, you probably have trouble understanding why a day programmer even entered the industry, and the reason is because they are motivated by different things than you are. The characteristics of a night programmer are:

  1. They mostly lead (or drag kicking and screaming).
  2. They develop deep understandings of complex things.
  3. They can visualise a solution and have a sixth sense around design.
  4. They load the alpha/ctp/beta version of tools at home.
  5. They participate in user groups and mailing lists.
  6. See programming is as vital to them as breathing air.

If you are a day programmer, you look at the night programmer and think that they don't have a life. And you laugh at them when they come in excited about some cool new trick they can do in the framework.

I definately fall in the Night Programmer category. I do, in fact, often have trouble understanding why a day programmer even entered the industry.

There is also a further post in that blog on clarifications of the first post.

Posted on 2/15/2006 4:33 pm in Coding

I'm working on a project for work. I've got a bunch of sales data that's stored on our AS/400 in flat files. Why flat files? Because the bulk of the code was originally written in 1986, but that's beside the point at the moment. I need to get that data into an SQL2005 server. Why SQL2005? Because it makes my life easier when writing .NET code, and because SQL Express is also free.

Currently, I can easily pull the data, at regular intervals, into a MySQL database using bits of Perl code I've written over the years. This works pretty well for those tasks, but interfacing with MySQL in .NET just isn't as pleasant. So I need to find a new solution.

The Problems:

  • Interfacing with SQL2005 (or 2000) is hard to do from Unix.
  • Running Perl code by itself isn't as practical on a Windows box, because it lacks cron.

The best solution I've come up with uses 2-3 steps, and that's not acceptable. I've downloaded ActiveState's Perl Dev Kit to give it a try. It has a .NET component builder so I may just be able to use my perl code from within the .NET app to access the data. That may just be easier in the long run.

Posted on 10/17/2005 12:12 pm in Coding

I was looking for something for MediaWiki and came across this. I thought I would share.

Posted on 8/17/2005 4:48 pm in Coding

I was working on my website and saw the following quote come up in my quote list. I didn't know what waterfall programming meant, so I did a search for the quote. I find it interesting that my site (when it was still using Postnuke) came up in the Google results. Made me happy. But the article I found is an interesting read. The quote was actually part of a reader response to the article.

Part of the reason so many companies continue to develop software using variations of waterfall is the misconception that the analysis phase of waterfall completes the design and the rest of the process is just non-creative execution of programming skills.

The article is "Iterative vs. waterfall software development: Why don't companies get it?" by Bill Walton.

It discusses four methodologies for programming. I think I use the third one most often in my work, except that I rarely have a partner to work with.

  • The iterative and incremental approaches involve a number of short cycles in which steps such as requirements gathering, coding, testing and deployment, are conducted to produce small parts of the final project. The software system grows incrementally, and user feedback can be used throughout the process.
  • The waterfall philosophy is a strictly sequential approach in which a project is completed in a series of steps, such as analysis, design, coding, testing and deployment. Each step, such as requirements gathering, is undertaken only once and must be completed and verified before the next phase.
  • Extreme programming is a software development approach built around rapid iterations, an emphasis on code writing and working closely with end users to achieve business results. The 12 basic practices of XP include continual testing and the idea that programmers should work in pairs. (See Computerworld QuickStudy.)
  • Project Management Institute methodology involves recommended best practices that use a cycle of processes -- initiating, planning, executing, controlling and closing -- to manage a project's scope, time, costs, risks and so on.
Page 1 of 2
Creative Commons License  Subscribe with Bloglines  Get Daily Wisdom!
This work is licensed under a Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 United States License.
© 2000-2010 Jason Burgess