Monday, April 28, 2008

Confused Deputy

Doc Searls has noticed the failure of WordPress to protect against the Confused Deputy problem.

Until we get a solution in place, the Internet is no longer subject to Metcalfe's law.

The lost value is staggering, though it's probably up there on the scale of the social surplus recently noticed by Clay Shirky. It's definitely larger that the 10.5 Billion that we're spending annually just to bail out the water and keep the boat afloat.

We need open source projects that bring capabilities into the mainstream. I'm open for suggestions as to where to start.

Thursday, April 24, 2008

The Bubble

Gas was $0.36/gallon in 1971.

Nixon closed the gold window in 1971

The dollar has dropped 95% since then relative to real money. (Gold)

Thus gas should cost $7.20/gallon now.

But it doesn't because the dollar bubble isn't done popping yet.


Wednesday, April 23, 2008

Guestimating twitter

I did some guestimates in Excel to see if I could figure out why twitter has issues with scaling. The results are surprising. I guestimated that the total byte flow of the raw tweets to/from the database would be on the order of 3k per second.

You can see the spreadsheet for yourself (thanks to Google docs).

The raw flow is surprisingly low. Mostly because we're talking about unique tweets, with no duplication to all of a person's followers, etc.

At the heart of it, any reasonable PC could do it... the bandwidth is very low.

The key question is architecture. If it's done right, the backbone of twitter has this very low bandwidth (but very important) flow multicast out to a bunch of front end machines that handle the subscriber's pipes. If you keep it basic, listing for each message (about 10 / second), if everyone had 5000 subscribers, you'd still only have to put out 50k messages /second for the whole twitter farm... not unreasonable if you broke it up into pieces.

I think I could build a twitter clone. I think a lot of us could. I think it would be a cool hacking challenge to see who could do it with the smallest collection of VMware machines against a simulated load/userbase.

What do you folks think?


Initialization code in Adobe Flash ActionScript 3.0

At long last, it's really, really, working right... and the code looks like this:

var initialized; // has to be declared, even if it's undefined

if (initialized == undefined) {
stop(); // stop the slide show on the first frame
Next_btn.addEventListener(MouseEvent.MOUSE_UP,function(evt:MouseEvent):void { nextFrame(); });
Back_btn.addEventListener(MouseEvent.MOUSE_UP,function(evt:MouseEvent):void { prevFrame(); });

initialized=true; // could make it anything, as long as it's not undefined

So, now I can just put all of the initialization code in the middle of the braces, and it all runs only once!

Tuesday, April 22, 2008

Slide shows and duplicate event listeners in Adobe Flash ActionScript 3

Today was my first day (of 30) as an Adobe flash developer. I focused on trying to help one of my co-workers who is an avid PhotoShop / CS2 user try to get up to speed on getting a basic slide show build in Flash with ActionScript 3.

Most of the tutorials you find on the net assume ActionScript 2, so that's a handicap from the get go. We did eventually find something that got us going... until the bug made itself obvious in the first 2 minutes... we were getting multiple presses out of our Next button if we dared go back to the first frame of the slide show. Then we noticed it happened with the back button as well.

The code looked like this:

stop(); // stop the slide show at the first frame

function(evt:MouseEvent):void { nextFrame(); });

function(evt:MouseEvent):void { prevFrame(); });

Which works... unless you happen to get back to the first frame, because it runs again every time you happen to touch the first frame. There doesn't appear to be any way to put Initialization code before all of the run time code, so you have to work around this (and this page is probably where you'll learn about this if you're having this problem in the future, and not Adobe's help files)...

To prevent duplicate event handlers, it's necessary to wrap them in code, each and every time, to prevent this.

Something like this:

stop(); // stop the slide show on the first frame

if (! Next_btn.hasEventListener(MouseEvent.MOUSE_UP))(
Next_btn.addEventListener(MouseEvent.MOUSE_UP,function(evt:MouseEvent):void { nextFrame(); }));

if (! Back_btn.hasEventListener(MouseEvent.MOUSE_UP))(
Back_btn.addEventListener(MouseEvent.MOUSE_UP,function(evt:MouseEvent):void { prevFrame(); }));

It seems to be quite a waste to me... perhaps someone has a more elegant way of initializing things to avoid having to add all of this code, and force it to only execute once per application?

I'm glad to have figured it out and got things working today, so now I can sleep. Hopefully this will help at least one other person who is frustrated with duplicate events firing from addEventListener messing up things.

Sunday, April 20, 2008

Once upon a time

Once upon a time, long long ago, there were a group of computer hobbyists known as hackers. They liked the name, because it as an apt description of what they would do... find a problem, and keep hacking at it until they came up with a solution they liked.

Hackers brought the computer out of the server room, and into our workshops and offices. They would tinker with new hardware, and try to connect almost anything to a computer, just to see if they could make it work.

One of the great joys of the hacker world was the free and open sharing of programs that could take hardware and make it do something new. It was a world where you could trust that anything handed to you was crafted to make things easy to use, and you could probably get help if necessary to overcome some wrinkles in using it.

This spirit is what allowed Xmodem, CBBS, and the shareware scene of the 1980's to really take off. The personal computer was truely personal. If you wrote a new program that did something useful, you could upload it to your favorite BBS, and it would eventually find new users throughout the world, who would give you feedback and support.

Mind you, this was all before the commercialization of the internet.

Things have changed in the past 20 years, and not all of it is for the better. It used to be you could try anything, and you didn't have to worry, because you could just reboot, and be back to normal.

Now it's almost suicidal to merely hook up a PC directly to the Internet. If it doesn't have all the latest patches and firewall, it'll be compromised in an average of 15 minutes, and turned into a zombie... probably before you even get your favorite desktop wallpaper picked out.

It's important to figure out what's changed, and if it's possible to undo some of the mistakes made along the way.

The biggest changes are the complexity of the Operating Systems we all use, and the way we use them.

In 1988, you'd boot a floppy disk to get to a DOS prompt. Your rich friend might even have a hard drive, but it was treated as a big floppy disk by the applications. You would ALWAYS have a spare copy or two of your OS, and your favorite configuration, in case you messed it up, or in the far more likely event that the disk went bad, or wore out.

Experimenting with a new OS, or program was simple, as the complete state of the system was confined to a floppy disk. It was a simple as
diskcopy a: a:

to get a new complete environment as a backup.

The other great thing was that you could make a disk read only by the simple manipulation of a piece of black tape. Later this was made even easier with the little flipping bit of plastic in 1.44mb floppy disks. Since it was enforced by hardware, you could be very sure that your data was safe as long as you didn't move it.

Now we have systems that require updates just to keep from getting hijacked before you can even use them. Does it have to be this way? NO.

One possible way to turn back the hands of time is to use a USB key, and write-protect the OS partition on it. The prices are now in the $10/Gigabyte range at Target, of all places. This is PLENTY of room for an OS with everything you need to surf, edit documents, etc.

A few USB keys, and you can kiss hard drives goodbye.

This is just ONE of the possible approaches, I'll write more as time permits.

Friday, April 18, 2008

Little bit of rock and roll

At 4:40 AM today, I was awakened by an Earthquake. It took a moment to realize it wasn't random motion from me that was moving things around in the bedroom... I noted time, and went back to sleep.

Tuesday, April 15, 2008

The first time

Virginia is in her crib, sleeping off her first walk around our block. The start was a bit rocky, as she really wanted to wander around on her own, but after a bit, we got into it. She found a stick to carry around, and play with... which we left outside. All in all, a nice start to the outdoor season.

Monday, April 14, 2008

...but I'm not bitter

The end of WWII, the world made safe for Democracy. What do we do with the peace that cost so many lives?

Well... the CIA and KGB collude to keep us in a cold war for 50 years, resulting in the huge military-industrial-complex that can't possibly keep us safe because it's all outsourced to China anyway... but I'm not bitter.

We spent $5,000,000,000,000 (5 Trillion) on our Nuclear deterrent, which won the cold war, and made us the only remaining superpower.... except it didn't really... but I'm not bitter.

Those weapons mean that nobody would dare attack us, and we're perfectly safe... yet in 2003 we Invade because of a threat of weapons that weren't there, from a Dictator we trained and kept in power... but I'm not bitter.

The CIA and elements of the government conduct experiments on the population, the airmen at Tuskegee, and others... and continue to deny for years... but I'm not bitter

JFK - assassinated by rogue elements of the CIA and Mob, killing the one good president since FDR... but I'm not bitter.

MLK - assasinated because he dared to question Viet Nam... but I'm not bitter

RFK - assasinated for threatening to follow in his brothers footsteps and try to make a positive change... but I'm not bitter

Nixon, dropped us off the Gold standard, knowing full well it would cause massive inflation and devaluation of the dollar... just to get re-elected... and then Watergate... but I'm not bitter

The Arab oil Embargo, a huge clue that we need to cut back and conserve our resources... what does Regan do when he gets into the White House? Remove the solar water heaters that Carter installed.... and then proceed to deregulate our economy, removing protections of the workers, environment, and economy, creating the giant sucking sound that outsourced all our jobs to China and elsewhere...... but I'm not bitter

The gulf war, we tell Saddam we're not going to interfere with his invasion of Kuwait, but then use it to justify a war, causing untold death and destruction, and loss of our troops... only to prop him back up at the end... but I'm not bitter.

The World Trade Center is bombed, blowing a 6 story hole in the basements... do we learn from this? No... but I'm not bitter.

The school of the americas, where we train dictators like Saddam Hussein and others to enforce our colonial rule over the planet... still open... but I'm not bitter.

Since 9/11, there are those who insist on blind patriotism, that we need to give up some liberties for security, and if we're not willing to do so, it's ok to spy on us anyway... but I'm not bitter.

We've in a huge mess, our currency is less than 5% of the value it should have according to our Constitution. You can't even buy real money without worrying it will be seized at some future date, just like it was during the Great Depression.

We import our energy... we lie about "huge new fields" found in the west... that aren't technically feasible to extract for another generation.

Anyone who dares point things like this out is marginalized, and called a "tin foil hat conspiracy theorist"... muting all discussion of what really is wrong with our country... but I'm not bitter.

No... I'm not bitter... I'm angry, and sad, but I haven't given up. I'm still willing to help work to straighten this mess out, to get our economy and country back on the right track. I stand willing and ready to Protect and Defend the Constitution of the United States of America, against all enemies both foreign and domestic.

The biggest single step towards doing that is to not be bitter, but to suck it up, see how bad things are, and start to figure out a way forward.

Monday, April 07, 2008

Monday commuter blues

Waiting for the South Shore - Hammond Indiana

There was a bit of a delay this morning on the South Shore Railroad in Hammond, Indiana. It appears that replacement of the overhead wires caused a pantograph on the Westbound train to snag, bringing service to a temporary halt. The train crew informed us of the situation and kept us safe.

I've uploaded the photos I took to Flickr, you can see for yourself some scenes of the morning events.

Tuesday, April 01, 2008 - my script to average frames in a nice way

Here is a bit of code I use to save a LOT of time in Paint Shop Pro. You run this python script with a single parameter - a file mask... (for me it's usually _*.tif)

This program will then take all the files in the current folder that match the mask, and average them, saving intermediate steps as trailnn.jpg and the final file as merge.jpg

import os, sys
import fnmatch
import Image

mask = sys.argv[1]
count = 0

# Program to average a set of photos, producing merge.jpg as a result
# version 0.01
# Michael Warot

print mask
for file in os.listdir('.'):
if fnmatch.fnmatch(file, mask):
print file
count = count + 1
in2 =
if count == 1:
in1 = in2
in1 = Image.blend(in1,in2,(1.0/count))"trail"+str(count)+".jpg","JPEG")"merge.jpg","JPEG")

Railroad Signals

Railroad Signals

Here's a video showing the individual frames that went in to this.