Slept In…

I've been working so hard and under so much stress over the last few weeks that today I just decided to sleep in.  That was nice, although my sleep ended with a nightmare about someone stealing my kid.  That was awful.  And now I really have to get to work.  There's still so much to do on my crazy project.  I had a meeting with the customer yesterday and it looks like they are at least somewhat pleased with what I've gotten accomplished, but I'm pretty sure it's not everything they wanted. 

Other than that, there's not much to report in my life right now, except that when I get home in the evenings I'm so drained I have no energy for anything, and barely have time to post blog entries.  By Christmastime this should be over.  Looking forward to THAT.

YouTube — Nobody's Watching

It's official… I'm becoming addicted to YouTube.  You'll recall I talked about the user SuttSteve recently.  Another user I've been checking out from time to time is impytherap.  These guys identify themselves as “Nobody's Watching“; their thing being that 99% of network television sucks.  So they are always making fun of television shows, and sometimes of other videos on YouTube.  There is apparently one show they like, though, and that is LOST.  That right there gives them high marks from me.  Here's a video they made about LOST in which the uber-hot Maggie Grace herself (Shannon Rutherford) makes an appearance.

Much Ado…

Today's pathetically misinformed offended person story comes from Pagosa Springs in Colorado, where a homeowners' association tried to force a local resident to take down a Christmas wreath shaped like a peace symbol (link).

The owner of the wreath was told that it was “divisive” and that “3 or 4″ residents had complained that the wreath was an anti-Iraq war protest or a symbol of Satan. The association stated it would impose a $25 fine every day until the wreath was taken down.

Forgetting the outrageously ridiculous premise that anyone should be able to tell you whether or not you can hang a wreath on your door… “symbol of Satan”???

Dear clueless religious wingnut in Colorado: the peace symbol was developed in Britian in 1958 as a symbol of nuclear disarmament and was adopted by peace movements everywhere. It has nothing to do with devil worship. The design of the symbol comes from the semaphore code — a system of communication involving one person holding two flags in different positions to signify different letters and numbers. Before radio, it was often used by the military to communicate visually over long distances. The diagonal lines in the peace symbol match the semaphore for N, and the vertical line matches the semaphore for D. ND = Nuclear Disarmament.

The owner of the wreath says that it is a “spiritual thing” and not a war protest. That's not so hard to believe. For religious folks Christmas is a celebration of the birth of Christ who is sometimes referred to as “The Prince of…” Anyone? Anyone? Bueller? “The Prince of Peace”.

Even if it was an anti-war statement, what difference does that make? People who want to live in a place where they will never have to see something that offends them should encase themselves in concrete and shoot themselves into space, for the benefit of us all. So someone is against the war, get over it.

You know what's really offensive? Homeowners' Associations.

At least in this case there is a happy ending. The association in question has changed its mind (link). One of those rare stories where reason prevails.


The Five Second Rule

We've all heard of that one right?  You are eating something and you drop it.  If you pick it up within 5 seconds, it's not dirty and is still good to eat.

One YouTube user has put together this little video to highlight just how ridiculous that belief is. 

From the wiki:

…A study on the five-second rule was performed by Jillian Clarke, a high school senior, during a seven-week internship at the University of Illinois at Urbana-Champaign in 2003. Clarke and a doctoral candidate named Meredith Agle took swab samples from various floors around campus. They then looked at the samples under a microscope and discovered that they did not contain significant amounts of bacteria. The conclusion was that in most cases, dry floors would be safe to eat from.

However, Clarke also wanted to test the five-second hypothesis in cases where the floor was known to be contaminated. She therefore spread E. coli on both rough and smooth floor tiles in a laboratory, placed pieces of gummy bears and cookies on the tiles for various amounts of time, and then examined the foods under the microscope. All the foods had a significant amount of bacteria after less than five seconds. Her findings therefore disproved the five-second rule…

…The five-second rule was also featured in an episode of the Discovery Channel series MythBusters. The results they got from their tests confirmed Clarke’s findings: time was not a factor when food is exposed to bacteria; even two seconds' exposure is more than enough time to contaminate it…


1957 Coke Machine

Image

Saw this old Coca-Cola vending machine in little take-out place called “Tory's Steaks” in downtown Leominster, MA and just liked the looks of it.  It is indeed functional, as the little sign atop it atests–”Yes it works.”  Although the price has changed a bit, now $1.50 instead of ten cents, and only one of the slots holds bottled Coke.

The food was great by the way.  I had a chicken parmesan sub with french fries.  Mmmm.

Gary's at it Again!

You remember Gary Brolsma, the “Numa Numa guy”, yes?  I wrote about him back in February of 2005.  I really liked his silly dance and lipsync video, and so did like a billion another websurfers.   I heard somewhere that the attention was a little overwhelming and for awhile Gary wasn't necessarily happy with his fame.  But apparently he's gotten over it.

Two months ago Gary released “A New Numa Video” featuring him goofing about to a new song.  The new song is a Russian piece which includes a lyric that says “nu numa ura hey“.  Unlike his previous effort this video clearly is more professional.  Gary describes the music on his website www.newnuma.com:

…The second video was recorded and produced by Gary Voelker and Andrew Lee of Seattle-based Experience Studios. The idea of “New Numa”, was just a reaction to fans to give them something new from me, and to let them know I'm still around and doing well, and just overall conveying the message of fun and laughter…

…New Numa's song was specially created for me by Variety Beats, with vocals performed by Chad Russell, under the BeLive Productions record label. The song is in Russian with lyrics about a children's song about a hunter and a bunny, again, not directly relevant to what's actually happening in the video…

In addition to Gary at his nutty best, the new video also includes his band.  Yes, you read that right, Gary has a rock band now.  They're called “The Nowadays” and you can listen to some of their music and find out about them on the band's MySpace page.

Needless to say, it's obvious the New Numa Song is a commerical enterprise.  I say good for Gary, he saw an opportunity and is turning it into something that benefits him.  Needless to say, many people who haven't done so are quick to label him a “sellout”, an epithet most undeserved in my opinion.  Onesuch person went so far as to create a parody video called “I will not pay for Numa“.


Babylonian Weelanders?

If you futz around with math like I do, you probably have to compute square roots from time to time.  We all know how to do it.  Basically you punch the SQR button on your calculator.   Or you type SQRT(A1) in Excel or something like that.  But how do you do it by hand?  And moreover, why am I discussing this?  Well, for the latter question, you'll have to wait a bit.  First, square roots.

In school they taught me this: For a given number x choose a smaller number r and square r.  If r squared is bigger than x, choose a smaller value for r, if r squared is smaller than x choose a larger value for r.  Repeat until you converge on the approximate square root of the number.

So, if x is, say 1200 (for reference sqrt(1200)=34.641…), then I would pick an arbitary value for r.  Because I am a computer geek I happen to know that 32^2 = 1024, so r=32 is too low because 1024 < 1200.  So then let's set r=33.  33^2 = 1089, too low.  If r=34, r^2=1156… closer, but still too low.  If r=35, r^2=1225, which is too high.  So I know that the square root of 1200 is between 34 and 35, and I can refine my estimate further by choosing fractional values between 34 and 35:

r=34.5, r^2=1190.25
r=34.75, r^2=1207.56
r=34.625, r^2=1198.891
r=34.6875, r^2=1203.22

And so forth.  As you can see we've gotten pretty close to the square root now.

This is basically a watered down variant of the Babylonian Method of computing square roots.  When I was in Junior High, the above method was easier to understand.  But now that I am an adult, the actual Babylonian Method description is more accessible and more concise.  Here it is from the wiki:

The most common method of square root calculation by hand is known as the “Babylonian method”. It involves a simple algorithm, which will bring you closer and closer to the actual square root each time it is repeated. To find r, the square root of a real number x:

  1. Start with an arbitrary positive start value r (the closer to the square root of x, the better).
     
  2. Replace r by the average between r and x / r. (It is sufficient to take an approximate value of the average, not too close to the previous value of r and x / r in order to ensure convergence.)
     
  3. Repeat steps 2 and 3.

Starting from my original M of 33, it takes only 4 iterations to come within 1/100,000th of the actual square root of 1200:

r=33.00000, r^2=1089.00000. Too low.
r=34.68182, r^2=1202.82851. Too high.
r=34.64104, r^2=1200.00166. Too high.
r=34.64102, r^2=1200.00000. Done.

Interestingly this method works surprisingly fast even if you pick a dreadful starting value for r.  If in this example I start with r=1, it takes only 10 iterations to come within 1/100,000th of the square root of 1200.

r=1.00000, r^2=1.00000. Too low.
r=600.50000, r^2=360600.25000. Too high.
r=301.24917, r^2=90751.06084. Too high.
r=152.61629, r^2=23291.73210. Too high.
r=80.23957, r^2=6438.38915. Too high.
r=47.59739, r^2=2265.51190. Too high.
r=36.40443, r^2=1325.28246. Too high.
r=34.68373, r^2=1202.96082. Too high.
r=34.64104, r^2=1200.00182. Too high.
r=34.64102, r^2=1200.00000. Done.

Square Roots and Factorization

Now why am I going on about this?  Well I've been thinking about the Weelanders again.  I'd like to create a new generation of Weelanders who break numbers down into their prime factors.  (As in 1200 = (2^4)(3)(5^2), or 2 x 2 x 2 x 2 x 3 x 5 x 5 = 1200).  Because of this I need Weelanders to be able to compute square roots, and the method above will be the one they will use.

Why do I need to do square roots to factor a number?

One rudimentary way to find the factors of a number N is to divide N by values which are < SQRT(N)… if any of them evenly divides the number, then it is a factor.  The SQRT portion is important, because it lets you know where you should stop trying factors, without having to keep going all the way up to the value of N itself.  This makes sense because any value X<SQRT(N) which is a factor of N, necessarily multiplies by another factor Y>SQRT(N).  The only exception to this is when X=SQRT(N).  This means that by the time you've reached the SQRT(N), going further will simply yield factors you already could have computed by dividing N by an earlier value of X.  We can show this with 1200.  Here are all the values of X less than SQRT(1200) which are factors of 1200, and the corresponding factor you must multiply by (Y) to get 1200:

X=1, Y=1200.
X=2, Y=600.
X=3, Y=400.
X=4, Y=300.
X=5, Y=240.
X=6, Y=200.
X=8, Y=150.
X=10, Y=120.
X=12, Y=100.
X=15, Y=80.
X=16, Y=75.
X=20, Y=60.
X=24, Y=50.
X=25, Y=48.
X=30, Y=40.

Note how X and Y both converge toward the SQRT of N.  This is why when you are looking for the factors of N, there's no reason to test values of X greater than SQRT(N).  The biggest value of X in this case that divides 1200 evenly is 30 which is just a little less than SQRT(1200)–34.641.  The factor paired with that X is 40, which is just a little larger than SQRT(1200).

So if for example N was 1201 instead of 1200.  You'd know that 1201 was prime by the time you had finished testing 1201/34.  Because 1201/X where X is an integer larger than 34 must yield a value Y which is less than 34 which you would have already found.

For doing prime factorization (as opposed to full factorization, which is what you see above), you test even fewer factors (only the primes), and your target endpoint changes with each successful factorization.  Consider 1200 again, as with full factorization my endpoint for testing is SQRT(1200).  So I try the first prime 2.  This works 1200/2 = 600.  But that means now I'm no longer really factoring 1200, I'm factoring 600.  Which means my endpoint is now really SQRT(600) or 24.5.  That means: none of the primes between 24.5 and 34.6 evenly divide 1200 or 600.  So now I don't have to test 29 and 31.

Divide by 2 again, and that gives us the result 300, which has a square root of 17.3.  So there is no reason now to test beyond the prime 17, and so we no longer need to test 23 as a factor of 1200.

Divide by 2 again and we get 150, with square root 12.2.  Which means that 13 and 17 also no longer need to be tested.

Divide by 2 one more time we get 75, with square root 8.66.  Which means that 11 doesn't need to be tested.  Look how much we figured out!  By dividing 1200 by 2 successively we now know that all of its remaining prime factors are less than 8.  And since we clearly can't divide by 2 again, all that is left to test is 3, 5, and 7!  Isn't that cool?

If N were 1205, we'd find after dividing by 5 that the quotient 241 requires us to test no further than 15.  So that would mean we'd test 5, 7, 11, and 13 with no luck, which would tell us that 241 is itself prime.

Prime Factorization and Weelanders

I'd like to recode the Weelanders to do basic square roots, and basic prime factorization, and then build a “rack” of 1000 Weelanders, give them all the same number to factor, and let them all factor it.  Any Weelander who gets the wrong answer or no answer gets the axe, and of the remaining Weelanders, the fastest 10% (those who computed the results in the fewest number of steps), would be allowed to reproduce (sexually or asexually, haven't decided yet.)  The remaining 90% would also get the axe to make way for the offspring of the top 10%.  The top 10% would reproduce until the “rack” was filled again.  And then it would be time for another factorization test.

I'd probably not want to select Weelanders based on the results of a single factorization.  I'd probably want to do it based on 5 or 10 factorizations.  (It's possible that a mutant Weelander might be exceptionally well suited to factor the number 5268, but be incapable of factoring other values at all.)  Therefore you'd want to test them a bit and average the results.  (But of course you would immediately cull any Weelander that couldn't solve the problem correctly.)

I seriously doubt that I can come up with any novel ways to factor numbers via this method, but I know there are a number of little “tricks” for factorization that I am not familiar with… maybe my Weelanders can teach me those tricks through natural selection? Wouldn't that be cool? 


Making Thanks

My Dad was asking me the other day how I made yesterday's “Thanks!!” image. I figure if you are familiar with Adobe Photoshop you probably know how, but just in case, here's a little set of instructions showing how I did the effect. There's a lot of different ways to do it, I'm sure, but this is the way I did it. Keep in mind if you want to use Photoshop you will have to buy a copy, but in my last article I covered how to get Photoshop cheaply. I'm going to use an excerpt here, because this article is full of graphics, so click the link if you want to keep reading…

Step 1: Type the Text

Open Photoshop, and choose the text tool. Then in the font bar, specify the font you want to use. I suggest a face which is very thick and bold like “Impact”. Once you've selected a font face, pick a size. The size dropdown only goes up to 72, but you can type in larger font sizes. In the example at the right I typed in 192 as the point size. Like so:

Play around with the text until you have a font you like. I've only typed a single letter here since this is for example purposes only.

Step 2: Paste and Scale the Overlay

Check your image library for a picture you want to overlay on the text. For the “Thanks!!” image I did this dozens of times, once for each little picture. Given that this is an example, I'm just doing it once. I've chosen a picture of some crocuses I took a couple of springs ago.

Once you paste the picture, it will cover up the text, but that is okay. The text isn't gone, it's just in another layer. The example at the right shows the layer window in Photoshop as well, and here I've moved the crocus picture to be beneath the layer containing the text. You can reorder layers simply by clicking and dragging them. Pay attention to the layer that has the little paintbrush in it… this is the one you are actually editting. It's very easy to accidentally paint in the wrong layer!

Eventually when you are done, you can delete the text layer altogether, or move it to the bottom… ultimately we're only using it as a guide.

Once you paste the picture it will probably be too big and will need to be scaled down. In Photoshop 6, you can do this by selecting Edit > Transform > Scale. This will draw little handles around the image which you can click and drag to resize it. If you hold down the shift key while dragging, Photoshop will keep the image proportions the same as you scale it.

Step 3: Select the Whitespace in the Text Layer

Switch to the layer containing the text. Then select the Magic Wand tool, and click on the letter. This will cause Photoshop to select the region containing the letter. Now go to the Select menu and choose Inverse. This tells Photoshop to invert the selection, and select everything but the letter. In the example at the right I've zoomed in so you can see what this looks like. That dashed line going around the T won't appear in the final image, it's just Photoshop's way of showing the boundary of a selected region.

Step 4: Delete the Selected Region of the Image

So now you have basically everything but the letter selected, and that's important, because the only part of the flowers we want to show, are the flowers inside the letter. So switch back to the layer containing the image, and hit the Delete key on your keyboard. This will remove all of the image that falls outside of the letter. It will look something like the example at the left.

Don't worry, the part of your image that is inside the letter is still there. You just can't see it because the letter is covering it up. If you move the image layer to the top again, this will become clear:

Step 5: Select the Image Border

In my “Thanks!!” image, I wanted my pictures to have a soft edge inside the letters, so we're going to do that here. If you want your images to have a sharper edge, skip to step 7.

To soften just the edge of the image, we need to select just the edge. We can do that by choosing Select > Modify > Border. This tells Photoshop you want to select a band that goes around the edge of what you previously selected. Photoshop responds by asking you how wide this band should be, in pixels. I chose 4 pixels. The wider the band, the wider the fuzzy edge of your image will be. The image at the right shows the selected border once you click okay. Note that it includes part of the image and part of the space around the image.

Step 6: Blur the Selected Region

Under the Filter menu, choose Blur > Gaussian Blur. The higher you set the blur radius, the fuzzier your blurred region will be. I recommend setting this to half the size of the border.

In terms of this example, the border was 4 pixels wide, so I set the gaussian blur radius to 2 pixels.

The preview box will show you what your blur will look like when done. Click OK once you like what you see.

Now some of the blur will spill outside the edge of the letter. So to fix that, switch to the text layer, click on the letter again with the magic wand, and invert the selection again as we did in step 3. Then switch back to the image layer and hit the delete key again, which will remove any blur outside the letter.

You should end up with something like the example at the right.

Step 7: Adding the Fat Black Border

In my “Thanks!!” image, I wanted my letters to have a fat black border. If you don't want that, you're basically done. If you do:

Switch to the text layer and select the letter again with the magic wand. Then switch to the Background layer and choose Select > Modify > Border again. Again choose 4 pixels. Then under the Edit menu, choose Fill.

You will see a dialog box like the one shown at the left. In the “Use:” dropdown you can specify what you want to will the selected region with. I chose “Black”.

Because you selected the background layer, the fill will paint the black background on the bottom layer in the image so only the part outside the letter will actually show. Photoshop will antialias the filled region to attempt to give it a soft edge. After that, your image will look like the one shown at right.

Now if you want, you can throw the text layer away, since it is completely covered anyway, but I recommend keeping it, in case you want to come back to the image later and do more work on it


Photoshop on the Cheap

Interested in Photoshop?  I've always been.  But for a long time I went without Photoshop, and limped along using crappier products.

Buying Photoshop for amateur home use can be problematic since Adobe Photoshop CS2 retails at a price point over $500.  Which is why I recommend that you should not buy the latest version from a retailer. If you are just a home user mucking about with photos, an older version of Photoshop purchased used on eBay will have more features than you are ever going to use and will probably save you a bundle. It's only illegal if you are buying a pirated copy. If someone has upgraded from Photoshop 7.0 to Photoshop CS2, or switched to a new product, or a different operating system, they often will sell their old disks, manuals, and so forth on eBay, which you should be able to legally register under your name. Just make sure, if you get it on eBay, that you buy it from a reputable seller and be sure to ask the seller if you can legally register it. If you're really concerned you can probably also find old versions from some retailers. Amazon carries Photoshop 6.0 starting from $200.  That's pretty big savings!

The older you go in versions, the cheaper it will probably be. You could even go as old as Photoshop 5.5. I checked eBay completed auctions and found several where 5.5 went from anywhere between $50 and $150. Here's a copy of 5.5 that went for $76. Here's a copy of 6.0 that went for $111. Here's a copy of 7.0 that went for $260.

One other thing to keep in mind if you buy on eBay, is that there are many Photoshop-related products that in the end you don't need or may not be able to use.  So make sure you are getting the right product from a seller with a high feedback rating who sounds knowledgeable. Things to be aware of:

  • Do not buy anything that says “elements” in the title. “Photoshop Elements” is a companion product to photoshop, you don't need it and without photoshop installed, I'm not sure you can do anything with it.
     
  • Do not buy anything that says “upgrade” in the title as in “Photoshop 6.0 Upgrade”… these are special upgrade packages that will only install photoshop if you already have an older version installed on your system. Adobe sells these at a much lower price to entice people who shelled out big bucks for the last version to buy the next version. Be very careful here. If someone seems to be asking a very low price to sell you Photoshop, be sure to ask them if it is the “full retail version” as opposed to the “upgrade version”.
     
  • Do not buy anything that says “educational”, “training”, or “tutorial” in the title. This is either a special stripped down version of Photoshop price-pointed for college students, which you will not be able to legally register unless you are a college student, or a companion product that teaches you how to use Photoshop. The prices on these versions will be inordinately low. Remember if it seems too good to be true, it probably is.
     
  • Remember to verify what platform (what type of computer) the software is for. If the seller doesn't mention “Windows” or “Macintosh” then the product he is selling could be for either. Ask.
     
  • Try to get the “full boxed” product. This means you are getting everything, the manuals, the disks, the registration card, everything. Be wary of someone who is just selling a CD, or even a CD and a manual. If someone is selling an unopened boxed product still in the shrinkwrap that's your best bet… everything you need will be in there. If you don't get everything, you may not be able to register it.

In the end try to pick a seller with a high feedback. A high feedback seller will likely have sold lots of old versions of packages and will fill out her auction description in such a way that you won't need to ask any questions at all, as in “Adobe Photoshop 6.0 for Windows. This is the full retail version (not an upgrade, not an educational version), in the box with all the manuals, disks, and registration materials. This product is unregistered.” If the auction isn't clear on all of those points, ask the seller to clarify. She won't mind, after all she wants you to be happy with what she is selling, so she'll probably respond relatively quickly. If you can't get enough information or the seller seems shifty or ignorant, let it go and get the next one, there will always be a next one.

Happy photoshopping!