## Zombie Door

Run!!!

Zombies are pretty cool.  This post describes something a little less cool, but uses zombies to explain the concept (in a shallow, transparent attempt to capture your attention!)

# Zombie Door Method

Imagine we want to generate a uniformly distributed random sampling in some complex space that our random number generator does not directly support.

Let me start with an simple example.  Imagine we have a random number generator that produces a random integer between 1 and 100.  However, we actually want to generate random numbers between 41 and 50.  (I know there are better ways to do this, but stick with me for this example.)  Let’s solve this with the zombie door method.

• Build a wall and label it 1-100 where 1 is to the far left, and 100 is to the far right.
• Cut a door in your wall from 41 to 50.
• Now create random zombies starting anywhere from 1 to 100 and let them walk straight towards the wall.
• The zombies will lurch across the room and eventually hit wall, explode, and dissolve in a fizzing puddle of bloody goo … or whatever it is that zombies do when they die.
• The zombies that are lucky enough to walk through the door survive!

For this example it would be easy to scale and offset the usually available random number generator that produces a floating point value between 0 and 1, but it illustrates the basic approach of the ‘zombie door’ method.

# A More Interesting Example

Imagine we have an arbitrary polygon outline and we want to splatter it with random circles.  However, we only want circles that are completely within the polygon.  (And we want our random circles to be a true  unbiased, uniformly distributed random sample.)  This example is just like the simple ‘wall’ example except now we have gone ‘2D’.

Imagine an arbitrary polygon shape:

We would like to fill this shape with 200 random circles, making sure none of our circles straddle the boundary or lie outside the polygon.  We want an even distribution over the interior area of our polygon.

We can do this by generating random circles within the min/max range of our shape, and then testing if they lie completely inside the polygon.  We reject any outliers and keep the inliers.  It’s very simple, but very cool because … you know … zombies!  Here is a picture of how our circles turned out:

If you are at all curious as to what became of our dead zombies (all the ones that splatted against the wall) here is the picture of that:

If you the reader are concerned that I am making light of a very real pending zombie apocalypse issue then here is my best tip for protecting your residence:

Finally, here is the python script I used to generate the pictures in this posting.  I leverage the very, very, very cool GPC polygon clipping library to test if the outline polygon ‘covers’ the circle.

```#!/usr/bin/python   import random   # polygon (GPC) python package: https://pypi.python.org/pypi/Polygon2 import Polygon import Polygon.IO import Polygon.Shapes   # this will seed the random number generator with current time and # force different results on each run. random.seed()   # this is the bounds of the shape that will contain our splatters outline = [ [0.5, -0.01], [1.01, -0.01], [0.5, 1.01], [-0.01, 1.01] ]   # define circle properties num_circles = 200 min_r = 0.002 max_r = 0.02   # no closer than this to the boundary margin = 0 #margin = 0.002   # create the polygon template (outline) template = Polygon.Polygon(outline)   # make the shape a bit more interesting c = Polygon.Shapes.Circle(radius=0.4, center=(1, 0.5), points=32) template = template - c c = Polygon.Shapes.Circle(radius=0.3, center=(0, 1), points=32) template = template - c   # determine max/min of template min_x = max_x = outline[0][0] min_y = max_y = outline[0][1] for p in outline: if p[0] &lt; min_x: min_x = p[0] if p[0] &gt; max_x: max_x = p[0] if p[1] &lt; min_y: min_y = p[1] if p[1] &gt; max_y: max_y = p[1]   print 'template bounds:', min_x, min_y, 'to', max_x, max_y print 'radius range:', min_r, max_r print 'margin:', margin print 'num circles:', num_circles   # generate splats using zombie door method circles = [] discarded = [] while len(circles) &lt; num_circles: x = random.uniform(min_x, max_x) y = random.uniform(min_y, max_y) r = random.uniform(min_r, max_r)   # make the circle c = Polygon.Shapes.Circle(radius=r, center=(x, y), points=32)   # make the circle padded with extra margin cm = Polygon.Shapes.Circle(radius=(r+margin), center=(x, y), points=32)   if template.covers(cm): # circle + margin fully contained inside the template circles.append(c) else: discarded.append(c)   # assemble final polygons and write output final = Polygon.Polygon() for c in circles: final += c Polygon.IO.writeGnuplot('in.plt', [template, final]) Polygon.IO.writeSVG('in.svg', [final], fill_color=(0,0,0))   reject = Polygon.Polygon() for c in discarded: reject += c Polygon.IO.writeGnuplot('out.plt', [template, reject]) Polygon.IO.writeSVG('out.svg', [reject], fill_color=(0,0,0))```

## Failure is not fatal

This post is penned during a moment of extreme frustration, beware!

# Kobayashi Maru

https://en.wikipedia.org/wiki/Kobayashi_Maru

One of the reasons I loved the original Star Trek series is because no matter what the odds, no matter how hopeless the circumstances, no matter how impossible the foe, Captain Kirk always found a way to think his way out of the mess.  He never ultimately failed or lost to an opponent, not once, not ever.  That makes a great hero and fun TV!  Fictional super heroes do things that normal human beings could never possibly do … like fly, or be stronger than steel, or always win.

# Stress and the Brain

I don’t have time to read stuff like the following link, especially when I’m coming up short of a promised deadline.  Maybe you do?  http://www.health.harvard.edu/staying-healthy/understanding-the-stress-response

I’m told that when we begin to get stressed, the front area of the brain that is responsible for logic and reason starts to shut down, and command functions begin to be transferred back to the “fight or flight” portion of the brain.  I think about standing up in front of a group and speaking, then sitting down and wondering what I even said?  I think about arguments that got out of hand?  Where was the front part of my brain in all of that?  I think about looming deadlines and mounting stress … and … and … and mounting stress!

# Recursive Stress

My job largely amounts to puzzle solving.   I love the process and I love finding clever solutions.  But if I ask you a riddle or give you a logic problem, can you give me a specific estimate of how much time it will take you to solve it?  That’s not how puzzle solving works, it’s not a step by step recipe that leads to a solution in a known time.  Failing to solve the problem in time stresses me out!  What is needed in these situations is clear, logical, and calm thinking.  But that is the first part of the brain to turn off during stressful situations!  It’s exactly the part of the brain we desperately need the most.  I know all this, and I watch helplessly as it happens.  What does that create?  More stress of course which accelerates the process of losing the most important part of my brain!

# What is the solution?

No, seriously, what is the solution???

People often say they do their best work under pressure.  I know for myself, I do my worst work under pressure.  I strive whenever possible to get a long head start on a complex and difficult task.  I strive whenever possible to identify and solve the hardest parts of the task first.  But that isn’t always possible.

So instead I sometimes see failure coming weeks away, maybe like an asteroid on a collision course with earth.  I’m very serious about the task, I do everything I possibly can, I pour in all my energy and expertise, but it’s not always enough.  Things I thought would be easy turn out to be 10x more difficult than imagined.  Things that were working break for unexpected reasons.  Things that shouldn’t take time, take way too much precious time.

Captain Kirk to the rescue?  Sadly, no … he is a fictional character.  In the real world the asteroid looms bigger and bigger, it’s trajectory is a mathematical certainty.  The physics of the impact can largely be predicted.  At some point it becomes clear my efforts will fall short and there’s nothing left to do but watch the asteroid in it’s last few hours of flight.  Then <boom>.

# Is it just me that fails colossally?

It usually seems like I’m the only one that makes a miserable mess of things I try to do, the things I’ve promised I could do, things I’ve been paid to do.  Everyone else is posting about their giant success on facebook.  Everyone else’s resume is a spotless collection of triumphs.  But not me.  Maybe once or twice I got lucky and the rest of the time is a huge struggle!  Honestly though, the only reason I’m posting this is because I know it’s not just me.  Any sports fans out there?  How many teams and players succeed to win the championship every season?  What percentage of players ever win a championship in their whole career?  Political success and failure?  How many new businesses succeed versus failing?

# High Profile Failures

By mentioning specific companies, I don’t mean to imply specific people or imply anything negative here.  My intent here is to show we are all in this together and we all, even the best and most successful of us, suffer set backs in our work.  I live and work in the world of drones (or small unmanned aerial systems, aka UAS’s).  This is a tough business.  For all the hype and excitement even big companies can struggle.  Gopro recently did a full recall of their new drone product.  Hopefully they’ll try again in 2017, and hopefully the process will go better for them.  Recently 3DR, the king of DIY drones announced they were cancelling all their hardware efforts to focus on a software package for managing data collected by drones.  Parrot (another big name in the small drone market) just announced layoffs.  Edit: 12 Jan, Lily just announces it is dropping out of the drone race and shutting down.  Edit: Facebook Aquila crashed on first test flight.  Edit:  Titan (google’s own high altitude effort solar powered effort) is shut down.  It’s tough, even for the big guys with enough money to hire the best engineers, best managers and do professional marketing.

There are even higher profile failures than these … Chernobyl, TIger Woods, the Titanic, Exon Valdez, the Challenger, and most Sylvester Stallone movies except for Rocky I.

# The Aftermath

So the asteroid hit.  In the last moments we just threw up our hands, gave up, and just watched it come in and do it’s destruction.  The dust is settling, what happens next?  Maybe the asteroid wasn’t as big as we imagined?  Maybe the damage not as severe?  Maybe life goes on.  In a work context, maybe you take a big professional hit on your reputation?  Maybe you don’t?  Maybe it’s about survival and living to fight another day?

Failures suck.  Failures happen to everyone.  Failures are [usually] not fatal.  The sun will still rise tomorrow for most of us.

# Survival – Yes?!?

If you are reading this, you are still here and still surviving.  That’s great news!  Hopefully I’m here too!  Lets all live to fight another day.  Let’s all help each other out when we can!  There is a word called “grace” which is worth looking up if you don’t know what it means.  It’s a quantity that we all need more of and we all need to give each other in big healthy doses!

“Success is not final; failure is not fatal. It is the courage to continue that counts.” — Budweiser ad, 1938.  (Not Winston Churchill)

# Norris Numbers

I recently stumbled on the following article about “Norris numbers”

http://www.teamten.com/lawrence/writings/norris-numbers.html

The quick summary is that for an untrained programmer, 1500 lines of code is about where they hit the wall before they succumb to complexity and organizational issues.  The next big barrier is 20,000 lines of code for those that have some training and a bit of experience.  The next big barriers are at 200,000 lines, 2 million lines, etc.  At each level, a programmer or team has to develop new techniques and strategies to overcome the inherent cognitive limits of our human brains.

# SLOCCOUNT

Linux offers a neat little tool called “sloccount”.  You can run it on just about any source tree, and it will count up the lines of actual code and then estimate how long it might have taken to develop that code and what the expected costs might be.

For example, my core UAS autopilot project is about 41,000 lines of code currently.  Sloccount estimates this represents nearly 10 years of effort (I started the work in 1995) and at a modest yearly salary estimates the cost to develop this code at about \$1.3 million dollars.

My first reaction is this is crazy talk, sloccount is just pulling numbers out of it’s rear aperture.  But after thinking about it, maybe these numbers aren’t so far off.  If you also consider the need for a project to mature over a period of time and consider bugs, testing, etc. then it’s not so much about how many lines of code can you crank out per hour, but more about how much effort is required to create a body of code that is functional, robust, and mature.  If you take a mature software package and work backwards, I suspect sloccount’s numbers would start to look much more reasonable.

I’ve spent my career in the trenches.  I never really was interested in the management track.  This clearly colors my perspective.  When I read generalized comments (like the article linked above) my first thought is to apply them to myself.

After reading the article about code complexity barriers, I immediately went out and evaluated several of my projects.  FlightGear = 264,000 lines of code.  My UAS autopilot is 41,000 lines of code.  My little summer side project is 6,000 lines of code (sloccount estimates that is 15.76 months worth of effort packed into about 2 months of time.)  My model airplane designer project that I’ve worked on during Christmas break the past 2 years is 5,600 lines of code.

I still don’t think we can put too much faith in sloccount’s exact numbers, but when I wonder about why I’m so overwhelmed and feel buried in complexity and deadlines and pressure, maybe this offers a little perspective, and maybe I’m doing ok, even if I feel like I’m coming up short of everyone’s expectations.  For the managers and entrepreneurs out there, maybe this can guide your expectations a bit more accurately.

## Update: 10/01/2014

Things just aren’t quite falling into place perfectly for this cord cutter.  Since cancelling our satellite, I’ve been monitoring 4 possible antenna DVR options.

1. Tivo Roamio OTA.  This seems like exactly what I’m hoping for.  Maybe a little expensive on the monthly subscription, but I’m willing to give it a try.  The downside: not available anywhere, any target date has been scrubbed.  Rumors suggest best buy is removing all tivo products from their stores.  Oof dah.
2. Tivo Roamio.  This is \$110 more than the Tivo Roamio OTA for the initial purchase with the same monthly subscription.   On the plus side it is available and shipping now.
3. Tablo DVR.  This one looks really interesting.  However, I don’t own an ipad and I want to watch TV on my TV, not on my tablet.  They say they have newly added Chromecast support, but everything I’ve seen suggests their android support (needed for chromecast) sucks, and it’s unclear if watching live TV would work through the chromecast and how sports type shows would look.  It’s fairly pricey on top of everything else.
4. Smart TV.  I looked at this for the first time yesterday.  It seems plausible, but some of the basic features I would expect were in their premier package and not their “basic” package.  This one just didn’t quite have me jumping up and down either.

So what is my plan?  For now I guess I wait for the Tivo Roamio OTA which could be a month or two or more away from being available to me.  In the mean time maybe I give up trying to save \$110 and just buy the original Tivo Roamio.  But for now I keep watching.

Dear Tablo: you almost had me, but you lost me on your poor android support.  Give me a reasonable chromecast experience on par with netflix so that I can use my phone or tablet as a remote control and I think you probably would have my money.

## Update: 9/23/2014

As of today, the 9/14/2014 release date of the Tivo Roamio OTA has come and gone.  The latest availability estimates are late October or early November.  Will I even want a tivo by then?  I guess we’ll have to wait and see.  Are there other potential options?  Does anyone have any opinions on the “Tablo”?

# The cost of having all the channels you are told you should want

\$110 per month.  I’m almost embarrassed to admit that is how much we were paying our satellite company each and every month for HD + DVR service.  \$1320 per year.  That didn’t include any of the extra pay channels we didn’t get — like HBO, Cinemax, Stars, pay per view, etc. etc . etc.  I can’t imagine what some people must pay every month.

Was it great?  Was it awesome?  Was it worth every penny?  Did I eagerly watch each and every second of every NFL game every week?  Did I suck up endless 24 hours cable news shows?  Was I current with all the reality shows?  Did I see all the movies?  Did my kids ever run out of Disney and Nickelodeon shows to watch?  What ever happened to Hannah Montana?  Are they still making new Spongebob episodes?  I’m sure I would know the answers to all these important questions if I actually watched \$110 worth of TV each and every month.

Maybe I was getting my money’s worth at some point along the way?  Somewhere, somehow, I accepted all of this.  But then we signed up for netflix and discovered so many of the shows and movies we do or did watch are available at 1/10th the cost.

# Cancelled!

So we did it, we called up our satellite company and cancelled.  They gave me several chances to reconsider and even found a way to get my bill down to \$68 a month.  But we held firm, they accepted our decision and we parted ways.  It was a much more pleasant breakup than others have reported with certain cable companies.

# What Next?

Rabbit ears?  Running to the refrigerator or bathroom during commercials?  Making sure you are home at specific times to watch your show?  Missing your show and never getting a chance to see it?  Programming your vcr and juggling vhs tapes?   Getting up to turn the dial and adjust the antenna to switch stations?  Is this my new life?  Not exactly.

## Digital Antennas

It suddenly occurred to me I had never tested the tuner on my TV.  I didn’t even know if it had a digital tuner.  So I went to the store and spent \$25 on a digital antenna.  It took some fiddling around to find a place that worked, but it worked!  For me, closer to the window helped.  It was also sensitive to height and direction — table top level didn’t work work, but eye level or higher worked much better.

I discovered some interesting things when I plugged into the local broadcast world.

• The resolution and detail was so much sharper.  Even though I got all the major broadcast stations over satellite, it turns out they heavily compress the signal, even the HD signal.  The local broadcast signal is way sharper!  If you are a sports fanatic, you should check out your game on the local broadcast station and compare to your satellite or cable feed.
• I found a myriad of stations I didn’t know existed.  If you are into classic TV shows or classic movies, there are stations out there that feed an endless supply over the airwaves.
• Soccer is my sport and the local mini-professional team broadcasts their games.  Cool!  I played one summer with the guy who is now the head coach, and his dad (who was the coach of that team) is now one of the broadcast announcers.  Crazy!  (I was never close to good enough to play at higher levels, but one summer I played on a team where everyone was a lot better than me, and it was a good experience.) 😉
• I do miss my DVR.  I miss being able to set and collect shows and watch them when I want.  I miss being able to pause, skip commercials, rewind to catch something I missed.

## Tivo to the Rescue?

According to the Tivo web site, they released a new version of their tivo designed especially for me.  For \$50 (plus a modest monthly fee) they offer their basic DVR for recording over the air channels.  It has no cable card slot which I don’t need or want.  It is to be sold exclusively at Best Buy, but none in my area seem to have it yet … I am impatiently tapping my foot right now Mr. Best Buy.  Please take my money!

## Netflix

Of course Netflix, and other streaming services such as Hulu, Amazon, and Youtube are what make this endeavor possible.

Big media companies, big content providers, and big cable/satellite companies are working hard to lock up exclusive deals and shut out those that don’t buy in.  These companies have tremendous power.  It’s why so many people stick with their current expensive providers.  But I feel the tide is shifting.  They won’t be able to lock things down forever, and eventually will have to relent to the online streaming world.  Kids these days (I’m told) watch much less traditional TV that we did as kids, and instead are watching their shows online, on their phones and tablets.

I’m not the first nut case to cut the cord, but I still feel like a pretty early adopter.   Maybe?   Maybe not?  Is this a powerful movement that is starting?  The first one to do something is the crazy nut job, especially if no one joins in.  It is the first followers though that form the bridge, that show the crowd how to follow, that make it less scary, more normal, more fun.  Before too many years go by, the non-cord cutters will be on the outside.  That is my prediction.  On line, on demand streaming and the various evolution of this new form of entertainment will soon rule the entertainment industry and our lives.

## What about the internet connection

Yeah, that’s a small detail.  You can’t really stream your content without a high speed internet connection.  So maybe as time goes on, our money will shift more to the bandwidth providers, and away from the content aggregators?  Don’t ask me how much I pay per month on my internet bill!  That’s one cord I can’t see myself cutting for a long time.

Somehow I imagine that the total cost for our entertainment and communication needs won’t change all that much in the long run, but hopefully we small consumers will have more choice and control to direct our spending on exactly what we need and want.

# The World is Constantly Changing

The last time I built up my own PC was March, 2011 – going on 3 years ago.  The basic idea of building your PC and the basic skill set required are still pretty much the same, but a couple new things caught me off guard.  Because I only do this every 2-3 years, I don’t keep track of trends and buzzwords and product nicknames, so plowing my way through this is a bit of a (fun) adventure each time!

# Basic Skills Required

• For me, the most important requirement is necessity.  I typically am interested in specific things.  I’ve wasted too much of my life struggling to make cheap PC junk work reliably.  Just about every time I’ve bought off the shelf systems, they’ve been a disappointment and a struggle.  But on the flip side, I don’t want to spend too much to get the features I need.
• You need to be able to operate a phillips screw driver.
• You need to be able to match up cables and get them plugged in correctly.  Almost always they are keyed and labelled so there is only one possible way to connect them. This amounts to plugging the round peg into the round hole, and the square peg into the square hole, and not mixing those up (at least not very often.)  You don’t need a sledgehammer if something isn’t going together. Backup and take another look at what you are doing. 🙂

# Mini-ITX Motherboard

One thing I discovered this time around is the mini-ITX motherboard.  This is smaller than a traditional motherboard, but has a ton of stuff packed into a small area.  I was planning to build a simple file server and was hoping for a smaller footprint in my office, so I rolled the dice and chose this style motherboard.  Here are a few comments:

• I bought the AMD FM2 socket version, and as far as I can tell it accepts any FM2 processor.  What’s FM2?  I have no idea, but typically you want the motherboard socket and the CPU socket to match.  That’s something important to keep in mind when shopping for parts.
• The MSI A75IA-E53 motherboard I chose only offers 2 memory slots and 1 PCI expansion slot.  But what it does include onboard is most everything you’d want already: gigabit ethernet, wifi (surprise!), bluetooth (surprise!), usb-3.0, analog and hdmi video out, plus several other plugin ports that I don’t immediately recognize.  So far so good.
• Installing the CPU and RAM is the same as it’s always been done, no surprises there.
• Installing the Motherboard in the case is also pretty much the same: screw it down, find where all the power/connectors plug in and plug them in, and you are good to go (hopefully!)

# AMD CPU/Motherboard Integrated Graphics

Here is the one thing that did catch me off guard.  The motherboard I chose has analog and hdmi video output.  However, I eventually discovered that this only works if you install an AMD CPU that has integrated video support.  I have never seen this before, and it seems to be something relatively new, or at least introduced since I built my last PC a couple years ago.

I chose a CPU without integrated graphics and spent half a day trying to figure out why my new system seemed dead on arrival.  Eventually I dug up an old PCI video card out of the bottom of a box of spare parts, installed that in the one available expansion slot, and “ta da!” I could see the motherboard booting up and running its power on stuff.  (This motherboard doesn’t beep on boot, I was expecting beeps and not getting them, but it turned out to be normal, not an indication of a problem)  So, excellent, everything is working as it is designed!

I am planning to use this machine as a simple server (backup server, nfs server, disc burning server.)  I don’t plan to play games on it, so graphics is not a big issue, and I was very relieved to have my system up and running correctly — running with a “discrete graphics card” installed which is the new terminology apparently.

# The Case

Along with a new (new to me) motherboard form factor comes a new case style designed to fit the mini-ITX motherboards.  When you shop online and don’t know exactly what you are doing, occasionally you get stuck making guesses and hope that it will work out!  I was hoping for something smaller than a mid-tower case, which was my whole intent when I selected the mini-itx MB.  I chose a case listed as a “mini-tower” and designed specifically for mini-itx MB’s.  I also wanted one external 5 1/4″ bay so I could install a dvd/blu-ray burner.

What I received was much bigger than I was expecting.  It is still shorter than a mid-tower case, but actually a bit wider, and uses a standard ATX power supply.  So the downside is that the case isn’t as small as I was hoping, but the upside is that I get a system that is flexible, expandable, and upgradeable.  That said, after stuffing in all the stuff, it is still a pretty cozy fit.  There is still lots of space for add on hard drives, but everything in between is quickly packed full of cables.

• The power button and the power LED are integrated, so the button you press to turn on the computer also lights up.  That’s pretty fancy for this guy.
• The reset button also doubles as the hard drive activity LED.  It’s a nice, clean, sharp looking case!

# To Bling or Not to Bling

I have never been interested in case bling.  I don’t need to be blinded by my case.  I don’t want my case to be visible from outer space.  Give me a small power led and a small hard drive activity light and I’m happy.  Oh, and I don’t need my case to look like a Star Trek prop, basic rectangles are fine.

The case I chose came with a 12″ front fan that is illuminated with blue LED’s.  Normally it wouldn’t be something I’d pick, but I ended up with it and I think it’s pretty cool … at least it doesn’t blink or flash or change colors.

# Peace and Quiet!

Another big consideration when spec’ing and building a system is fan noise.  In the past, I have put together systems that literally sounded like jet engines on an aircraft carrier deck.  Often PC fans adapt and speed up/slow down as the CPU heats up or cools down.  But combine this with a noisy fan and the end result can quickly drive a person insane.  How do you avoid noise?

• One thing that people use is water cooling.  This can create a system that is virtually silent.  I’ve never setup a water cooled system before … it looks complex, and some of the parts get a bit pricey.
• Use bigger fans that spin more slowly.  This is really the key point.  The case I chose has a 12″ front fan.  Bigger fans move the same amount of air at a slower RPM and are generally quieter.  Often the cheap/stock fans are small and have to spin at a high RPM.
• After market CPU coolers.  The same bigger-fan-size principle can work for CPU cooling as well.  In this system that I just built, the stock CPU fan seems to be pretty quiet, so I’ll most likely just stick with it.  But if you find your CPU fan sounds more like a hyperactive F-16, there are a number of aftermarket cooling systems that have much larger heat syncs, and bigger/slower fans.  Just make sure you have enough case clearance for the cooler you pick.  Some of the bigger/nicer heat sync/fan coolers won’t fit in a smaller case.

When you build a system from scratch, typically it doesn’t come with a pre-installed operating system.  That is left up to you.

I’m a long time Linux enthusiast so I loaded Fedora 20 (the current release) on this system.  Linux offers packages like “BackupPC” which can backup all my  other systems on a regular schedule.   I can also easily do NFS file sharing, blu-ray/dvd burning, web serving, and a host of other useful tasks with this system.

For everyday uses, Linux offers Chrome and Firefox, so as our lives increasingly exist “in the cloud”, and more and more our interface is through our phone, tablet, or web browser; I think Linux is becoming more and more of a good option for ordinary computer users.

1. It is free (no microsoft tax on your new computer.)
2. It is every bit as easy to install as windows or osx
3. It offers many of the same capabilities as other systems for most things people want to do.  We all have our preferences, but these days it’s becoming more and more difficult to practice “OS advocacy” on the basis of capability or available software.
4. These days with Windows 8 still being so new,  Linux often supports more hardware and devices out of the box than your other options.

# Fedora 18 “Spherical Cow”

I think everyone has a bit of a love/hate relationship with their technology.  We hate it when it doesn’t work, or we can’t figure something out, or something breaks or doesn’t make sense.  But we love the new upgrade, the fancy new desktop background, animated menus, or what have you.  Fedora 18 was just recently released so of course I had to jump on that and get all the new stuff here as quickly as possible.  Is it great?!?  Was it worth the wait?  Is it a waste of time?  Do I love it?  Do I hate it?  Yes!

Over the past week I’ve been migrating several of my machines from Fedora 17 to Fedora 18.  The old “preupgrade” tool that was available for upgrading your system to new releases no longer is available for upgrading to fedora 18. Instead a new utility called “fedup” is provided.

What do I think of the new “fedup” tool?  For me on my systems it has been a resounding #fail.  Both systems I tried to update got trashed.  In the first case I was able to run “fedup” and do the initial pre-load.  Upon rebooting I was able to do the “upgrade” boot and the installer ran all the way through to the end and it all looked really good.  But when I rebooted after completing the upgrade I found a mess.  My system couldn’t boot or booted partially into an error state of not being able to find what it needed.  I didn’t continue to debug or try to figure out what happened.  Personally I’d rather have a fresh clean system, than a trashed system that’s been just barely patched together enough to boot and run.  So I blew everything away and loaded from scratch off the DVD ISO.

On the second machine (a laptop this time.)  I ran fedup and prep’ed the system for upgrade, rebooted into the upgrade installer and proceeded with the upgrade.  But partway through the package installation process my entire machine rebooted with no warning.  This laptop isn’t prone to doing that sort of thing.  Blame it on the hardware?  Maybe, but …. ???  This also left me with a system that wouldn’t boot, so again I blew it all away and loaded Fedora 18 from scratch off the DVD.

In both cases, installing from scratch from the DVD worked flawlessly after seeing fedup fail.  On my other machines, the DVD install from scratch has worked well.  So fedup is a #fail, but otherwise I’m happy.  There’s something to be said about a clean system that hasn’t carried over all the cruft from previous revisions and years of use, so I’m not entirely unhappy that I was forced to install my systems from scratch.  (I have a sophisticated backup system “backuppc” and store my home directories on separate hard drives, so an install from scratch is not as big a deal as it might be if I had everything on a single drive with no backups.)

## Freshly installing Fedora 18

In all cases (for me) installing from scratch has worked perfectly.  I’m disappointed that the upgrade didn’t work, but the fresh install procedure works quite well.  In my case what ultimately happens with a fresh install is that later I stumble on packages I forgot about or configurations or tools I had setup for some task on the old machine, and a few months later when I need to do something again, I discover that and need to scramble to get it going again from scratch on the new system.

Here are some installation hints, tips, and tweaks for Fedora 18 that I discovered along the way:

• Naming your machine: the layout of the network config dialog box caused me to miss seeing the field where you enter the machine name.  When I was all done, I had “localhost.localhost” which I was not happy about.  I used: “hostnamectl set-hostname <name>” to set the domain name (which seems to be the way to do it on Fedora 18).  There are some nuances of fully qualified domain names that I’m not sure I got 100% right, but for now it’s close enough, the machine has a name.  The real answer is to make sure you enter your machine name during the install process (in a box way down in the lower left of the screen that can be easy to miss.)
• Picking a drive: one other area of the installer that I tripped on was also mainly due to screen layout/ui issues.  I was installing over the top of an existing linux system and I wanted to wipe those existing partitions.  So after selecting the target disk, there is a continue button hidden in the lower right corner of the screen.  Hit that and you can go on to “reclaim” the space, delete the existing partitions and let the installer automatically reformat and repartition that area that is now available.  (Note it happily works around existing windows partitions on a system that’s already setup for dual boot.)
• Nvidia drivers: several of my machines have nvidia graphics hardware.  I am heavily involved in FlightGear which requires 3d hardware acceleration.  The nouveau drivers are ok for desktop work, but no where close to good enough for all out 3d graphics.  In the past I’ve downloaded the NVIDIA driver from nvidia.com and installed things manually.  This time around I added the rpmfusion.org repository and installed the akmod-nvidia package.  This seems to have worked well so far.  We’ll see how it gets through a kernel upgrade.  Being left in the cold for a few days with package mismatches isn’t really an option for me so I could be back to manual installation before long — depends on how quickly the rpmfusion.org guys can track fedora updates.

## Tweaking for Personal Preferences

No one likes a straight up stock machine (except maybe iUsers) so right out of the starting gate we need to tweak and configure several things.  Here is my list of “must tweaks.”

• “yum install vino”  This adds desktop sharing.  I have several computers on my home network and this helps manage and use them by allowing me to share and view desktops from one machine to the next.  I don’t need a monitor and keyboard and desk for each computer.  Look for “desktop sharing” to enable this and run “remote desktop” to connect to shared machines.  And yes, if you are wondering, I am a heavy ssh/command line  user too. 🙂
• “yum install gconf-editor”  This is a graphical tool that allows you to tweak gnome-shell options.
• I run 2 monitors on my main machine and by default, gnome-shell makes all windows on the second monitor follow me to every virtual desktop.  If you aren’t sure what a virtual desktop is, then sheesh, how do you live?  I’d give up my coffee before my virtual desktops!  So to make the second monitor obey desktop switching run gconf-editor and Desktop->Gnome->Shell->Windows-> uncheck workspaces_only_on_primary
• By default gnome only maps 4 virtual work spaces to hot keys.  Virtual desktops (err work spaces?) are worthless without being able to hotkey between them.  From a shell you can run the following command to assign Alt-1 to switching to the first virtual desktop.  Then replace 1 with 2, 3, 4, … to assign hot keys for up to 9 work spaces.  I usually do 6, that’s as crazy as I get: gsettings set org.gnome.desktop.wm.keybindings switch-to-workspace-1 “[‘<Alt>1’]”
• For what it’s worth, I tend to setup specific tasks (like email, or working on a program, or web browsing) each in their own virtual desktop, and then throughout the day I can hotkey back and forth between them as needed.  For the cynical, this is sort of like the instant spreadsheet “boss hack” on the old video game that I can’t remember the name of now.  Facebook and google+ can get their own virtual desktop. 🙂
• Autologin: I’m getting lazy in my old age so why not setup the machine to log me in automatically?  In “System Settings” (under user name in top bar when logged in) select “User Accounts”. Select the account and enable “automatic login”.
• rpmfusion.org provides a number of packages that aren’t available in the default Fedora distribution.  I like installing mplayer which plays all those odd format movies.  Or maybe you want to be able to play mp3’s from rhythmbox.  Run this long command as root: yum localinstall –nogpgcheck http://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-18.noarch.rpm http://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-18.noarch.rpm  Then install what you want.  In my case I do: yum install mplayer ffmpeg gstreamer-plugins-bad gstreamer-plugins-bad-nonfree gstreamer-plugins-ugly unrar
• NVIDIA hardware accelerated opengl drivers: A must for any gamer or flight sim enthusiast (or flight sim developer!)  Once you setup the rpmfusion.org repository you can run “yum install akmod-nvidia” to install nvidia drivers for your system.  Be sure to reboot to activate them.
• Here is my personal list of extra packages I like to install on any fedora system: yum install emacs jpilot lsb gnumeric subversion subversion-devel apr apr-devel openal-soft openal-soft-devel freealut freealut-devel freeglut freeglut-devel libudev-devel fltk-devel fltk-fluid libopenvrlm-devel system-config-lvm librsvg2-devel libpng-devel libjpg-devel texi2html chrpathopencv opencv-devel aspell lm_sensors gnome-shell-extension-weather gnome-shell-extension-cpu-temperature gnome-shell-extension-systemMonitor gnome-tweak-tool libreoffice minicom inkscape
• Virtualbox: I’ve always run virtualbox (now owned by oracle) but Fedora by default now has something called “boxes”.  I need to check that out at some point and see if it works.  If I can migrate my disk image over without needing to reinstall Windows XP again from scratch it might be worth doing, just to use default packages.  Oh by the way, I’m a linux guy, but I have windows xp setup in a virtual box to run a couple small programs once in a while.
• Do you want to see the date on the status bar?  Run gnome-tweak-tool and do: Shell -> show date in clock -> on
• Do you want google chome?  Go download the package from google and “rpm -Uvh <filename>.rpm”  Make sure you have run “yum install lsb” first to get the required supporting libs.

## Conclusion

So far I’ve been very pleased with the newest release of Fedora.  Fedora 18 is a worthy successor to Fedora 17 and the previous versions too.  If you are coming from some other platform, you may find aggravations or things that don’t work (or don’t work the same way.)  But if you are coming from a Fedora background, everything I do works at least as good or better in the new Fedora 18.  With a bit of tweaking for personal preference, it offers a very solid and very powerful system with recent versions of the kernel, gnome, gcc, libreoffice, gimp and other major software packages.  It is built around standard open source packages so if there are glitches or things I (or others) might not like, you will often find the exact same behavior in other modern Linux distributions that are built on the same packages.  The upgrade installer “fedup” is worthless as far as I’ve been able to see.  But installing from scratch works great.  I can’t say if Fedora is better or worse than other linux distributions (I know we all have our personal preferences) but I will say that I’m a solidly commited “linux guy” and Fedora 18 is really great and the best Fedora so far.

## Setting up “autologin” on a gumstix running the 3.5 kernel (yocto, poky, et. al.)

The gumstix.org wiki has a page on how to configure your gumstix to auto-login on boot.  This can be very nice for “production” systems where the intention is to power on and run some specific firmware/code every time.

However, with the new Yocto/Poky images based on the 3.5 kernel, things have changed and the old instructions no longer work.  Here is a quick recipe to get autologin running again on the newer systems.  First of all credit to http://fedoraproject.org/wiki/Systemd for their section on setting up autologin on a virtual terminal with the new systemd architecture.

## Step #1:

Compile this “autologin.c” program and install it to /sbin/autologin (make sure you have executable permissions, etc. etc.)

```#include <unistd.h> #include <stdio.h> #include <string.h>   int main() { int nrv = 0; FILE* fptr = 0; char user[64];   // clear buffer memset(user,'\0',64);   // open autologin profile file fptr = fopen("/etc/autologin.profile\0","r\0");   // make sure the file exists and was opened if (fptr != 0) { // the return value from fscanf will be 1 if the autologin profile name is read correctly nrv = fscanf(fptr,"%s\0",user); }   // only autologin if the profile name was read successfully, // otherwise show the regular login prompt if (nrv > 0) nrv = execlp("login\0","login\0","-f\0",user,0); else nrv = execlp("login\0","login\0","\0",0,0);   return 0; }```

## Step #2

Create the /etc/autologin.profile file by running:

`echo "root" > /etc/autologin.profile`

The autologin program looks for this file to determine which user id should be autologged in.

## Step #3

Setup the systemd configuration.

```cp /lib/systemd/system/serial-getty@.service /etc/systemd/system/autologin@.service ln -sf /etc/systemd/system/autologin@.service /etc/systemd/system/getty.target.wants/serial-getty@ttyO2.service cd /etc/systemd/system/getty.target.wants/ vi serial-getty@ttyO2.service```

Next, change the line that reads”

`ExecStart=-/sbin/agetty -s %I 115200`

`ExecStart=-/sbin/agetty -n -l /sbin/autologin -s %I 115200`

## Troubleshooting

• If you still get a login prompt, make sure you created the /etc/autologin.profile file correctly, the autologin program needs that or it will just execute a standard login prompt.

## Step #4

You may find yourself in a situation where you may not always want your code executed automatically.  You may want an option to “break in” and get a prompt.  There are many ways you could do this, but here’s one simple way:

Compile the “pressanykey.c” code and install the executable in /sbin/pressanykey

```#include <stdio.h> #include <stdlib.h> #include <string.h> #include <sys/types.h> #include <termios.h> #include <unistd.h>   int kbhit(void) { fd_set rfds; struct timeval tv; int retval; struct termios term, oterm; int fd = 0; tcgetattr( fd, &oterm ); memcpy( &term, &oterm, sizeof(term) ); cfmakeraw(&term); tcsetattr( fd, TCSANOW, &term ); /* Watch stdin (fd 0) to see when it has input. */ FD_ZERO(&rfds); FD_SET(0, &rfds); /* Wait up to one seconds. */ tv.tv_sec = 1; tv.tv_usec = 0; retval = select(1, &rfds, NULL, NULL, &tv); /* Don't rely on the value of tv now! */ tcsetattr( fd, TCSANOW, &oterm ); return(retval); }   int mygetch( ) { struct termios oldt, newt; int ch; tcgetattr( STDIN_FILENO, &oldt ); newt = oldt; newt.c_lflag &= ~( ICANON | ECHO ); tcsetattr( STDIN_FILENO, TCSANOW, &newt ); ch = getchar(); tcsetattr( STDIN_FILENO, TCSANOW, &oldt ); return ch; }   int main(int argc, char **argv) { int count = 5;   if ( argc > 1 ) { int tmp = atoi(argv[1]); if ( tmp > 0 ) { count = tmp; } }   printf("Press any key ... "); fflush(stdout);   while ( count >= 0 ) { printf("%d ", count); fflush(stdout);   //int result = mygetch(); if ( kbhit() ) { return 1; } //sleep(1); count--; }   return 0; }```

Next create a ~/.profile file that includes the following:

``` /sbin/pressanykey 5 if [ \$? != 0 ]; then echo "Starting interactive shell" else echo "Continuing with default" /path/to/my/code fi```

Now, along with autologging in as root (or which every user you specified) you will then be presented with a count down timer similar to the “u-boot” timer where you can press any key to get a shell prompt, or continue to your firmware code if no interaction is required.

# What is the ultimate computing device?

Recently I just jumped into the world of tablets and wanted to share a few thoughts.

If we could build the ultimate computer, what would it look like?  Size?  Weight?  Battery life?  Transportability?  Network/Wireless speed?  Wireless access?  CPU Power?  Memory?  Hard drive space?  Graphics?  Display size?  Touch screen?  Keyboard/Mouse?  Voice input?  Cost?

The reality of today is that nothing meets all the objectives and gives us the ultimate in computing power, large display size, fast network speeds, comfortable typing and viewing, long long battery life, while slipping into our shirt pocket for storage and being relatively inexpensive.

# Desktop PC’s

We have all been using desk top PC’s — they offer the ultimate in display size and computer power and are comfortable to use when setup properly, but they are a lot of work to transport.

# Laptops

Laptops give you a computer that can be folded up and carried with you.  Often the result is still pretty heavy — maybe 20-30 lbs by the time you stuff your power cord and laptop and external hard drive and every other goody you have in your backpack.  Laptop performance can rival desktop performance, but at the expense of burning your battery very quickly and generating a lot of heat.  And you often have to make sacrifices in terms of display size, keyboard size, comfort of use, etc.  You can bring your own external keyboard and 30 inch monitor, but then you lose the transportability gains.

# Smart Phones

Smart phones are great — they can slip in your pocket and go where ever you go without being hardly any nuisance.  They offer internet connectivity anywhere you go.  Many of these can run all day (or a good chunk of the day) on battery.  And despite their small screen size (maybe 4″ is typical) you can check your email, browse the web, post to facebook, even edit documents, and do quite a bit of the computing things that people typically need to do in a given day.  But it’s at the expense of screen size and most of these devices do not have a keyboard, so you are forced to poke your messages in one key at a time through a clunky touch screen interface.  Oh, but the touch screen interface — this is something new to people who are generally used to desktop or laptop computers.  The touch screen interface is really really nice for many things — you point directly at what you want and touch it rather than needing to move a mouse pointer around the screen.

# Tablets

Here is my question: are tablets (such as the ipad) designed to address the short comings of smartphones or the short comings of laptops?

A tablet gives you a much bigger screen and often more battery life than a smartphone.  But most of them offer the same clunky touch screen keyboard interface — or is it a beautiful intuitive point directly at what you want touch screen interface?  — Along with similar CPU and memory size that is comparable to a smart phone.  But they do usually have wifi, gps, camera, tilt sensors, and touch screeens built in — keeping many of the best features of the smart phone.

Tablets tend to be lighter, smaller, and run longer on their batteries compared to laptops.  But often tablets provide zero expansion, no usb ports and severe limits on how they can connect to other devices and interface with the rest of the world.

# Tablets with Snap-on Keyboards

In the quest to find just the right balance between size, battery life, and functionality, Asus created the Transformer tablet — a pretty standard 10.1″ Android tablet with touch screen interface.  However, they also created a matched “docking station” which is primarily a snap-on keyboard.  Adding the keyboard turns the tablet into something that looks more like a small laptop than a tablet.  The “docking station” provides much more than a qwerty keyboard.  It folds up with the tablet to protect the screen when not in use.  It includes another big battery for greatly extended run times.  It includes a standard size MMC card slot and two USB ports.  The USB ports can handle your typical thumb drive, but they will also power up and run a full blown external hard drive.  Do you want 80, 120, or 500Gb of storage to go along with your tablet?  Or maybe just an easy way to transfer files (documents, pictures, videos) to or from it?  Oh, and the keyboard also includes a mouse pad with left & right buttons.  This suffers the usual laptop problem though of I bump the mouse pad, and my cursor jumps somewhere unexpected and my typing goes in the wrong place or odd things happen because of stray inadvertent clicks.

# Is it a Great Tablet?  Or a slightly too small Laptop?

Perception is a really funny thing.  The Asus transformer by itself is a great tablet.  It is smooth, polished, fast, and has all the gizmos and doodads that you want, plus it runs the very latest Android 4.0 “Ice Cream Sandwich” — could it be the ultimate computing device?  It is about as sweet as it gets (unless you are a Mac weenie.) Really the only thing I would want to add to it would be a real, physical keyboard, some longer battery life and a couple USB ports.

The Asus Transformer docking station gives you exactly what the basic tablet lacks.  Snap it on the base tablet and now you have the ultimate computing platform, right?  But go back to that funny thing about human perception.  If you snap on the keyboard/docking-station, now the unit looks like a laptop.  It feels like a laptop.  It even weighs in like a laptop.  In my mind I start evaluating it based on my laptop criteria.  It’s small and cramped.  The keyboard is typable, but slightly undersized.  Android only runs one app at a time (you can quickly switch between them, but you can’t have two apps open in separate windows simultaneously.)

# What is the answer then?

So then, what is the ultimate computing platform???

If you have some thoughts on the subject, please let me know!

## Seat of the Pants Engineering: I Need More Power!

One of the challenges of bread boarding is finding the right voltage sources and ground pins to power and connect a variety of components.  Recently I was faced with the challenge of connecting a Gumstix Overo with 1.8V TTL signals to a VectorNav VN-100T IMU with 3.3V TTL signals via SPI.  I just happened to have 2 Sparkfun logic level converters on hand.

The gumstix overo is powered from a wall power supply.  The vn-100t needs 3.3v power and ground.  The two logic level converters each need a 3.3v power line and a 1.8v power line (high and low voltage) as well as 2 grounds each.  The gumstix expansion board I’m using offers one 3.3v VCC line and two 1.8v VCC lines and 3 grounds — not even close to what I need.

So here’s what I did.

These are the headers I’m talking about: sparkfun 0.1″ male headers.  These come in rows of 40 pins and you can cut off the number you need.  For my little project I decided I’d make a 6 pin set, two 4 pin sets, and a 3 pin set.

### Solder a bare wire across the back to tie the pins together:

You can see my soldering isn’t quite professional, but as long as there is a solid connection, that’s what counts.

### Hot Glue the crap out of the back to insulate the pins:

I have no idea how I ever survived before I went to Michael’s and bought a \$3 hot glue gun.

### Connect up your jumper wires:

I’ll probably run out of jumper wires and have to live dangerously, but I recommend connecting a wire to every pin as a safety precaution — or at least to the end pins.  Murphy’s law reigns supreme when a “software guy” tries to meddle in the world of hardware.  Spark fun makes some very convenient 6″ color coded jumper wires.  Nice for breadboard projects.

### Double check your red wires and black wires!

An VectorNav VN-100T runs \$800 and an Overo is \$150-200+ depending on which one.  The logic level converters are \$1.95 each.  Guess which one fries first if you mix up your reds and blacks?

# Day 1

Fedora 16 hit the streets on Tuesday of this week.  (November 8, 2011).

I immediately rushed out to do a test upgrade on one of my old PC’s running Fedora 15.  Initially I used preupgrade to do it all via download, but I was met with the above screen when the machine booted.  This was what I got when I should have seen a login prompt.  Some people see this after they log in and that probably indicates other issues.

This is not a very informative message!  I googled quite a bit, examined the logs in /var/log/gdm/ and pretty much came up empty until I hit the following thread entitled “Fedora 16 Upgrade Disaster”.  Wow I thought, this sound promising!

The issue turned out to be selinux — the silent killer and breaker of linux systems.  I run nvidia graphics hardware and it appears to be a conflict between the selinux access policies and parts of the nvidia driver.

The fix for the moment is to run the following for commands as root:

`yum remove selinux-policy selinux-policy-targeted`
`yum update libsepol`
`yum --nogpgcheck install libsepol http://kojipkgs.fedoraproject.org/packages/selinux-policy/3.10.0/55.fc16/noarch/selinux-policy-3.10.0-55.fc16.noarch.rpm --enablerepo=u*g`
`yum --nogpgcheck install http://kojipkgs.fedoraproject.org/packages/selinux-policy/3.10.0/55.fc16/noarch/selinux-policy-targeted-3.10.0-55.fc16.noarch.rpm --enablerepo=u*g`

Long term, I hope this will get fixed by default.  It seems to be killing a lot of folks upgrade dreams.  I’m posting here in hopes that it helps someone out.  Let me know if you find out any further updates to the problem.

# Day 2

I should mention that after seeing this message initially and not finding a solution, I downloaded the install DVD and installed from scratch.  The problem went away — so this appears to be more of an issue for people doing an upgrade from a previous version of Fedora and not a problem for people doing a fresh install from scratch.

# Day 3

More problems with my system that was upgraded from Fedora 15 -> 16.  I can’t burn DVD’s with it.  I can insert a blank disk and it shows up in the file manager, but when I attempt to write an iso image to it, the dialog box claims it can’t find a valid disk to write to.  My system that has Fedora 16 installed from scratch does not have this problem, it can write DVD’s just fine.  More selinux problems?  I will stash all the data on this upgraded system and do an install from scratch to see if that cures my login problems and my dvd writing problems.

# Summary

Upgrading to Fedora 16 from a previous version of Fedora seems to lead to problems!  Installing Fedora 16 from scratch seems to result in a nice well behaved system.