Tuesday, May 31, 2005

No TechEd for Jason

:-(

I totally missed the opportunity earlier this year to enroll in TechEd, which kicks off this week. I'll catch the webcasts when they're made available, but it sucks that once again, I'm stuck working instead of seeing the cool new stuff.

Disclaimer: It would have been really tough for me to attend anyways, which could not have been predicted earlier this year--my current project is readying for "go live" this week, which would have been hard to do while in Orlando.

RSS and SharpReader

Ok, I've been using SharpReader to subscribe to multiple RSS feeds for more than a week now.

I was first really apprehensive--I mean, this is essentially web browsing for me using an email reader instead of IE. But, the more I used it, the more I finally "got" why it's such a powerful tool.

Once you learn of an RSS feed that you're interested in, you simply instruct SharpReader to open that feed and subscribe to it. SharpReader will then periodically download the XML and notify you when there's new content, much like an email reader would. It definitely saves on the time spent browsing the same sites looking for changes, that's for sure!

I still think that there's a niche for my personal portal concept. The power of RSS is that the content is easily extracted and transformed, so it fits perfectly into this idea.

Saturday, May 28, 2005

Movie: Primer

I was turned onto the movie Primer by my friend Jim. They claim that this movie was produced for a total of $7,000, and it has been nominated for and won some indie film awards.

The main characters, who appear to be in their twenties or early thirties, wear shirts and ties throughout the movie, so I thought that was a little unrealistic. ;-) Another thing that bothered me was seeing a flyback transformer hanging off of their "time machine" with the anode disconnected and hanging freely. I mean, what's up with that?

The actors are not polished actors, and the sets are nothing fancy. These flaws only add to the possibility that maybe we're watching something that could actually happen. I'm even in the process of watching the DVD a second time, just because it's one of those out-of-sequence time-shifting story lines that make more sense when you see it again.

If you see it on the shelf at your neighborhood rental shop, or use Netflix, then check it out! I've seen movies with millions of dollars in them that sucked, and this, for the sum of its production costs, is actually a cool story (read: it doesn't suck at all).

Couple More Puzzle Solutions

Not much work got done yesterday....

You are an employer of a company and you are in the process of hiring a new employee. You must pay this employee in gold at a rate of 1 oz. per day. This employee will work for you for 7 days and must be paid every day, no more and no less then 1 oz. per day. You happen to have one 7 oz. bar of gold and may make two cuts on this piece of gold. What cuts would you make in order to successfully complete the task?

I had to think about this one for a while. I kept thinking "two cuts....I wonder if you need to make one cut, and then stack the pieces and make another cut somehow". Then it dawned on me that the only way this would work is if the employee gave back some of his earnings in exchange for the total sum that he was due up to that point in the week. This breaks down to be a binary number problem. The two cuts leave you with 1 oz, 2 oz, and 4 oz chunks (powers of two).

Day 1: Give employee 1 oz
Day 2: Employee gives you 1 oz, you give employee 2 oz
Day 3: Give employee 1 oz
Day 4: Employee gives you 1 oz and 2 oz, you give employee 4 oz
Day 5: Give employee 1 oz
Day 6: Employee gives you 1 oz, you give employee 2 oz
Day 7: Give employee 1 oz.

Please write a function that will determine if a number passed into it is a perfect number. How would you test this?

I'll admit, I had to look up what a perfect number was. I knew that it was related to Mersenne primes, but I did not remember all of the details. (Simple definition: A number whose factors sum up to the number itself. Example: 6 has factors of 1, 2, and 3 [don't use 6 as a factor for this purpose]. 1+2+3 = 6).

A theorem states: If 2k-1 is prime, then 2k-1(2k-1) is perfect and every even perfect number has this form.

Nobody has found an odd perfect number thusfar, so chances are that they do not exist. So, I'll take advantage of this theorem while writing my code. Having a knowlege of binary arithmetic is extremely helpful here.

2k-1 will be a string of 1's when represented in binary. For example, 23-1 = 7, which is 111 in binary.

2k-1 is simply a power of two, and when you multiply a binary number by a power of two, you're simply doing a bit shift (i.e., adding zeros to the right side of the number). For example, 23-1 = 22 = 4, which is 100 in binary. 111 * 100 = 11100, or 111 shifted two bits to the left.

So, the function to check if a given number is a perfect number would be as follows:



static bool IsPerfect(long number)
{
string x=Convert.ToString(number, 2);

// Check for form: 111110000

int lastOne = x.LastIndexOf("1"); // 4 = k - 1
int firstZero = x.IndexOf("0"); // 5 = k

if (firstZero < lastOne)
return false; // There's a 1 after a 0

if (lastOne + firstZero != x.Length)
return false; // Improper bit length

// The number is now in the form of a perfect number, but that
// is not sufficient. We need to prove that 2^k - 1 is prime before this
// can be a perfect number. Luckily, there's a very small list of
// mersenne primes that fit our number's 64-bit length, so let's just
// see if k is one of these.

int[] mersenneExponents = new int[] {2,3,5,7,13,17,19,31,61};

for (int i=0; i < mersenneExponents.Length; i++)
{
if (mersenneExponents[i] == firstZero)
return true;
}

return false;
}



To test as I was building it, I came up with a list of known perfect numbers and known numbers that were in the form of perfect numbers but were not perfect numbers, and I ran them through the function to verify the appropriate results.

Probably took me 45 minutes to an hour to write the function and blog it here... That's probably way too long for an actual interview environment, which is why I live in Ohio and not Washington. :P

Also, it might have been easier since we have a finite list of possibilities to just calculate the known perfect number, and then check against the given candidate. Wouldn't have to dork around with strings that way....

Friday, May 27, 2005

String Puzzle

I found mention of this on Eric Maino's old blog (link):

You are given lengths of string that will always burn in 60 minutes from one end to the other. You have been tasked with measuring 45 minutes using these string how would you do it? Now imagine that the strings will burn from one end to the other in 60 minutes but they will not always burn at the same rate. Sometimes the strings will burn faster or slower at parts. How would you measure the time now?

I had not seen this puzzle before today, and since it's the day before a holiday weekend, and I'm working instead of taking my assigned company holiday, I thought that I'd give myself a break, eat some peanut M&M's, and think up a solution (pretending all-the-while that I'm at the mothership in Redmond with some uber-cool geek [oxymoron] interviewer waiting for my answer).

My solution to the first scenario is to simply cut 1/4 of the length off, and start burning from one end. The assumption here is that the string burns at a constant rate. To find the 1/4 length, fold the string in 1/2, and then in 1/2 again. If you can't cut, then just start the burn at the 1/4 mark, and the flame should go in two directions (towards each end). When the longer segment finishes burning, that should be 45 minutes.

For the second scenario, a constant burn rate cannot be assumed. This means that if you start burning a string from one end, it will reach the middle point at a different time than if you started from the other end. But, if you burn both ends at the same time, then when the flames meet and burn out, you should be at 30 minutes (regardless at what point in the string that event takes place).

If you started burning a second string from only one end when you lit the first string, then you know that regardless of how much of the second string is burned up at the end of 30 minutes, that you'll have 30 minutes left to go. Using the same principle as the first string, light the other end of the second string at the 30-minute mark, and when the flames meet and extinguish, then you should be at the 45-minute mark.

Thursday, May 26, 2005

Motorcycle Ride through Chernobyl

This is kind of an older site, but fascinating whenever I see it. A motorcycle-riding hottie named Elena tours the ghost town near the Chernobyl reactor, and posts her photos. A Must See Site!

L O S T

I love LOST (on ABC). I'm so sad that I have to wait the entire summer to get my weekly fix of new episodes. Luckily, there's little things planted around the Internet related to the show.

Like this website, for instance.

Code: The Hidden Language of Computer Hardware and Software

I first heard of Charles Petzold's Code: The Hidden Language of Computer Hardware and Software [amazon link] from DNR.

My copy arrived in the mail yesterday, and I've had a chance to read a few different sections. So far, I'm impressed by Charles' description of the logic hardware that is used to build a binary adder, as well as his description of ones-compliment and twos-compliment (a topic that is often hard to describe to someone). I can't wait to read more!

Monday, May 23, 2005

Voice Recognition: Cool Stuff, But Is It Practical?

Voice Recognition has come a long way, but it has a long way to go yet. My health insurance provider uses a voice recognition system to handle customer service phone calls, and the result is that it is nearly impossible to get to an actual human operator.

As I sat working today, I listened as my wife called the insurance company to verify something. The first phone call was a bunch of her saying single words: "Yes" "Coverage" "Pharmacy".... Stuff like that. Eventually, she somehow got a prompt that asked if she wanted to talk to someone, but that was maybe 2 minutes into the call.

Come to find out that she ended up at the wrong department or something, because that person could not answer her question, nor could they transfer her. She would have to call back and navigate the voice system again.

This time, her "Yes" "Coverage" "blah blah" responses were much more irritating. Eventually, she again was prompted to speak to an actual human. (BTW--she did try dialing Zero, etc, to see if it would circumvent the voice recognition system, but it wouldn't).

This person was useless as well, so she had to call back again! (They must outsource their call centers or something--not being able to transfer between departments seems like a rediculous incapacity).

The third time, the voice system wasn't recognizing her clearly irritated/almost outraged tone of voice, because she was starting to repeat each response. "YES' "YES" "I SAID YES!". At one point, I heard her say "GIVE ME SOMEONE REAL!".

Until we have actual Star Trek-level voice recognition, I don't see why companies are using them in customer service roles without providing up front a way to reach a real human.

MSPaint Masterpiece

Check out this guy's artwork, all created using MSPaint! (And Photoshop for some blurring effects):



(Hopefully they'll allow this link to the thumbnail, otherwise just click on the blank square above)

Saturday, May 21, 2005

RSS needs a Personal Portal Server

I'll admit, I'm really behind the scene on adopting RSS feeds as a primary source of information. Chiefly, I haven't found an aggregator that I particularly like. I gave it another try today using SharpReader, so we'll see how it goes.

My primary problem is that I don't want to think of news items (and blog entries, etc) as email, which is what aggregators seem to do. I want a portal-like interface, and do everything from my browser, but I don't want to run a dedicated portal server, and I don't want feeds to be collected at the time that I request them.

What I really want is a personal portal server to augment my browsing. I already have a pretty predictable list of sites that I visit multiple times a day, and most visits are only to see if anything new was added. What the personal portal server (running on my PC) would do is periodically crawl those sites or RSS feeds, get the new info, and compile into my portal page. When I get the urge to surf, my browser only needs to load the "compiled" portal page from the local hard drive, instead of going to some overpowered server chunking through code to assemble my page on-the-fly.

Shrinkster Helper

As I listened to the live Mondays show last night, I realized that there's something about trying to keep up with all of the Shrinkster URLs while listening to a live feed (i.e., you can't pause it) that was a little overwhelming. I mean, in reality, it's only a matter of remembering three characters, but I found myself typing in "h t t p : / / s h r i n k s t e r . c o m / " and then trying to remember the three letters for the URL.....

I made a recommendation this morning to Kyle, who took it as a valid suggestion, to offer a launching page from Shrinkster where you only need to type in the unique part and click a button. It wouldn't need a round-trip to the server, because the browser could spawn a new window. Something like the following:

[html]

[head]
[title]Shrinkster Launcher[/title]
[style type="text/css"]
.code {font-family:monospace;font-size:small;}
[/style]

[/head]

[body]

[span class="code"]http://shrinkster.com/[/span]

[input class="code" type="text" id="suffix" name="suffix" size="5"
maxlength="5" /]

[hr /]

[input type="submit" id="clicky"
onclick="window.open('http://shrinkster.com/' +
document.getElementById('suffix').value, 'ShrinksterURL')"
value="Launch" /]

[/body]
[/html]

Note: I had to translate the angle brackets into square brackets because I gave up trying to fool Blogger. If you want to use this code, just replace all "[" with "<" and replace all "]" with ">".

Friday, May 20, 2005

Carl Franklin's "Mondays"

I just finished listening to the live taping of Mondays. I actually was hoping to catch the live episode of DNR, but came in too late, I guess. It wasn't until they said the show's title that I realized what stream I was actually listening to.

Anyways, I have tried to listen to recordings of Mondays in the past, but didn't find them, well, all that captivating. The live show was much better, giving a peek behind the scenes of just how many times Carl and the gang mess up (which all get edited out) and swear during the 2 hours of taping that will be edited down to an hour. Plus, being an active participant in the chat only enhanced the entire experience (maybe this is what I was missing while listening to previous recordings).

If I'm not busy next Friday night, I'll probably be back! ;-)

A Reporting Services How-To

Here's my quick Reporting Services tip for the day:

Suppose that you have a chart (or full report) that you want to display on a web page as an image (i.e., within a portlet or web part). You can easily use URL Access to do that!

Consider the following IMG tag:

< img src="http://servername/ReportServer?
%2fMyReporting%2fChartExample&rs:Command=Render
&rs:Format=IMAGE&rc:OutputFormat=PNG" border="1"
>

Breaks down like:

http://servername/ReportServer?

The URLAccess URL.


%2fMyReporting%2fChartExample

This is the path and report name. Note that %2f is the URL escape character for a slash.


rs:Command=Render&rs:Format=IMAGE&rc:OutputFormat=PNG

Causes the report server to render the report as a PNG image.

Do I need to pick a specialty?

I've always been a jack-of-all-trades. I've been equally comfortable working on my own automobile, digging with a backhoe, rapelling down a cliff, repairing an arcade monitor, working on math problems, writing software, installing Windows, performing electrical work on my home, installing a satellite dish, etc.

But, my career field (computer technology) has just exploded over the last decade, and I'm finding it overwhelming if not impossible to keep up on everything.

I'm not about to stop learning, but at what point do I need to stop knowing something about everything and start specializing in one or two things? How do I personally decide which technologies to specialize in? How do I ensure that I maximize my income while maintaining a high level of personal satisfaction?

BTW, I've come to understand a long time ago that I derive great satisfaction from prototyping (R&D). My productivity level at the beginning of a project during the problem-solving stage is so much higher than at the end of a project (when there's nothing left but tying up loose strings). How do I get someone to pay me just for this type of engineering while letting someone else finish and refine a project?

Wednesday, May 18, 2005

Hantarex Polo Repair Log

Problem: Weird "wavy" horizontal linearity. Crosshatch pattern would gradually get narrower, and then wider, and then repeat. Vertical linearity was fine.


Simulation of H-Linearity problem of Polo

Solution: Discovered that D135 (BYV95C) was burnt and broken in half. Replaced with a BYV28-200, since that's all that I had and it is rated higher than the original part.

Tuesday, May 17, 2005

UFOs On Google Maps?

We'll probably hear a good explaination in days or weeks, but here's a phenomenon that people have found while Google Siteseeing: Difuse blobs on the satellite images that are not explained.

http://www.mikeslist.com/2005/05/ufos-spotted-on-google-maps.html

http://www.googlesightseeing.com/2005/05/12/ufo/

Now, let's just put on our Fox Mulder hats for a little bit. Suppose that we are under constant survelliance by aircraft, be that alien or perhaps [warning: conspiracy theory] experimental millitary. And suppose that there is a cloaking mechanism that would make these aircraft "transparent" when viewed from the ground against a cloudless blue sky. That same mechanism might not be as effective when viewed from above, and could explain what's in these photos.

Or, maybe it's a flaw in the stitching program that Google/Keyhole uses. Who knows.

From UPI: Major Geomagnetic Storm Heads Toward Earth

I have to chuckle whenever I see "science writers" for major media mix up facts in stories about auroras and space weather, a topic near and dear to me. It's not their fault--I mean, they probably got the short straw on that day, so they missed out on the sports reporting. Let me dissect the part of the story that I have the biggest problem with:

Statement: A major electromagnetic storm from a solar flare was headed toward Earth Monday, possibly causing power distribution, cell phone outages and other problems.

Fact: The Coronal Mass Ejection (CME) that occurred as the result of a major solar flare on Friday had impacted Earth early Sunday morning, USA time. The resulting Geomagnetic storm had all but subsided on Monday.

This would have been a good "heads up" story to run on Saturday, not on the Tuesday following. In my opinion, it seems that they want to put people into a panic over an event that is over (by making the uninformed believe that it is yet to occur).

Monday, May 16, 2005

Next Generation Microwave Oven Idea

Here's an idea: Why not slap a LCD display onto the door of a microwave oven, drop in an embedded OS, and suddenly, that huge block of space on your countertop can become a useful Internet Appliance that you can use to check your email while waiting for the popcorn to stop popping.

Some challenges to overcome: Keeping the LCD clean, considering what the door of my microwave looks like, and if it's wi-fi enabled, overcoming the RF conflict, since microwaves and 802.11b/g use the same frequency band,

Saturday, May 14, 2005

The Coderoom 2

Episode 2 of The Coderoom is now out. I watched it on TheServerSide.NET, who was the first to host it. In this episode, a group of developers must make a bluetooth-enabled application to more or less simulate interaction that a shopper might have in a shopping mall (i.e., be able to view specials going on in the stores via your phone).

The show gives face-time to Rory Blyth, who serves as the MSDN dude that accompanies each episode (or at least, that's been the trend so far). Rory was the co-host of .NET Rocks for 50 episodes, but got too busy when he started working for The Man, and had to relinquish his title!

And speaking of TheServerSide.NET, I just found this site today. My company, which is primarily a Java shop, has sent out broadcast emails before referring to content on TheServerSide.COM. I glanced over that site, and had wished that there was a .NET equivilent, especially since you can get free ebooks, etc. Come to find out, there is an equivilent, just a TLD away!

Friday, May 13, 2005

.NET Rocks!

Yeah, I know, it's 112 episodes into the series at this point, but I've been listening to old episodes of Carl Franklin's .NET Rocks! internet radio talk show focusing on .NET technologies (thank you MSDN for putting all of the first 100 episodes on the spring DVD). I find Carl pretty entertaining, as well as the collection of regulars and featured guests that participate. I was already familiar with Carl's work as the author of Visual Basic 4.0 Internet Programming, which is one of the few technical books that I actually own. Since it's VB4 technology, that's kind of dating myself a little bit (but not as much as stating that I used VB3 professionally for a year or more before VB4 came out!).

Great way to make it through a monotonous workday, as well as being introduced to the major players in the .NET world (whether employed by MS or not).

Tuesday, May 03, 2005

Great Way to Learn Assembly

I don't program in Assembly language on a regular basis, but every now and then, I get the opportunity to play with microcontrollers or other devices that require knowledge of assembly and/or machine code.

Being a high-level developer (VB, Java, C#), it's both interesting and extremely confusing to work at the machine's level. But, I found that a great way to teach myself a new assembly language is to actually write an emulator (simulator) in the high-level language to execute real/compiled machine code.

For instance, in the past, I wrote a simulator for the TMS370 microcontroller because I needed to learn its assembly language to write some serial I/O routines.

A better example for this audience might be to create an emulator for the Z80 microprocessor, simply because there's a lot of real-world programs that you can run (i.e., "Donkey Kong" arcade game used the Z80). Of course, emulating arcade machines involves more than just simulating the CPU and memory--you also need to emulate the graphics system in order to "see" if your CPU emulation is working correctly or not.

But, my point is simple--by forcing yourself to implement each opcode as part of an emulator, including all the different addressing variations, you will truly understand how the opcodes work. And, if you get stuck, you could always check the MAME source code (which emulates a multitude of popular CPUs).

Try it, if you dare! (btw--I'm toying with this very same idea for a book, if I can find the time....damn, I hate working so much).