dave

Syndicate content
Your blog is probably better than mine.
Updated: 53 min 32 sec ago

Best bash prompt. Ever.

Tue, 2009-01-06 18:22 -

I have the best bash prompt ever. It took a lot of hacking and googling, but here she is:

Notice that the smiley face and text colors change depending on the exit code of the last run command (red = failed, green = happy). This is handy, for example, after a big long build that has error messages buried in it, and the last line of output just isn’t that useful.

To make your prompt awesome, put this in your .bashrc and enjoy:

BLACK="\[\033[0;30m\]" DARK_GRAY="\[\033[1;30m\]" LIGHT_GRAY="\[\033[0;37m\]" BLUE="\[\033[0;34m\]" LIGHT_BLUE="\[\033[1;34m\]" GREEN="\[\033[0;32m\]" LIGHT_GREEN="\[\033[1;32m\]" CYAN="\[\033[0;36m\]" LIGHT_CYAN="\[\033[1;36m\]" RED="\[\033[0;31m\]" LIGHT_RED="\[\033[1;31m\]" PURPLE="\[\033[0;35m\]" LIGHT_PURPLE="\[\033[1;35m\]" BROWN="\[\033[0;33m\]" YELLOW="\[\033[1;33m\]" WHITE="\[\033[1;37m\]" DEFAULT_COLOR="\[\033[00m\]" export PS1="\`if [ \$? = 0 ]; then echo -e '$GREEN--( $LIGHT_CYAN\u$YELLOW@$LIGHT_CYAN\h$GREEN )--( $YELLOW\w$GREEN )-- :)\n--\$$DEFAULT_COLOR '; else echo -e '$LIGHT_RED--( $LIGHT_CYAN\u$YELLOW@$LIGHT_CYAN\h$LIGHT_RED )--( $YELLOW\w$LIGHT_RED )-- :(\n--\$$DEFAULT_COLOR '; fi; \`"

Happy bashing!

The Economy Stinks. We’re Hiring.

Sat, 2008-12-13 21:18 -

Taking a break from computer science and model aviation for the moment, I want to make sure my readership (both of you, not counting my mother) is aware that my company is currently hiring software developers. I know that many developers in the Salt Lake City area have recently found themselves on the job market. I also know that new job opportunities have slowed significantly. Although I take a more optimistic view than most, I readily admit that times are harder today for developers than they were one year ago. Despite the current state of the economy, my company is doing extraordinarily well. If you are looking for work, and you would enjoy working on a small team of engineers solving problems of national and global importance, then this may be the job for you.

At my company, we build the world’s most advanced signal processing systems. Developers here tend to get intimately involved in projects from the early idea stage all the way through delivery. You won’t be an insignificant cog in a massive corporate machine. Although we tend to have a small company feel, we have big company stability and benefits. Our Salt Lake City office of 60 people is actually a satellite office of our California-based headquarters, so we have all the best medical benefits afforded to larger companies, and yet we still maintain that small company feel: no office politics, no bureaucracy, no pigeon-holing, just pure engineering at its best. We have been very fortunate for the past couple years, and now we have more revenue coming in than we’ve ever had before.

As for experience and requirements, I won’t mention the specific technologies we work with since the only real job requirement is that you are smart and get things done. You’ll pick up the job-specific knowledge you need once you start working.

If this sounds good to you, feel free to email me your resume: dave@thesmithfam.org

I look forward to hearing from you.

Graph Theory Problem

Fri, 2008-12-12 22:44 -

I came across a graph theory problem at work this week, and decided to blog about it to help me sort it out. At first I didn’t think of it as a graph problem, but that’s how these problems often go, shrouded in disguise and all. But I digress.

The problem is this. Considering the following directed graph, which nodes are the most senior ancestors (speaking in tree terms, of course)?

The answer is that nodes A and B are the most senior, meaning they have the most number of descendants in their sub-trees. This becomes obvious if we draw the same graph this way:

I’m trying to discover an algorithm to identify the senior most nodes given any directed graph. The graph is given as an edge list, like this:

  • A -> B
  • A -> F
  • A -> E
  • E -> H
  • E -> G
  • B -> A (notice the cycle here back to A)
  • B -> D
  • B -> C
  • H -> I

So there’s the problem. I’m looking for an algorithm that will find the top-most nodes given any directed graph. In the case where there is only a single top-most node, it’s easy, but that’s just one case, and I want a general solution. Also, the graph need not be fully reachable from any node. It could be two or more non-connected graphs.

If you have an idea for an elegant solution, please post it in the comments below. I’ll post my own solution next week.

Happy graphing!

Edit:

After thinking about the problem a bit more, I thought I’d add another example with some corner cases that my solution will need to consider. If you look below, you’ll see a graph with a more complicated cycle and a non-contiguous section. The nodes I expect the algorithm to discover are shown in green:

Here are the edge pairs:

  • A -> B
  • A -> E
  • A -> F
  • E -> H
  • E -> G
  • B -> A
  • B -> C
  • C -> B
  • C -> D
  • I -> J
  • I -> K
  • H -> L

ParkZone T-28 Trojan Motor Upgrade

Sat, 2008-11-22 20:44 -

If you want to give your ParkZone T-28 Trojan unlimited vertical flight for under $30, today is your lucky day. Just head over to hobbycity.com, and pick up one of these Turnigy 35-36C motors.

Here’s what you’ll need to do the upgrade:

  1. The new motor (duh)
  2. A Phillips-head screwdriver
  3. An everyday drill and an ordinary drill bit
    (not sure of the drill bit size — you’ll figure it out)
  4. A new prop (I use an APC 10×3.8). The stock prop’s shaft is too wide for this motor’s prop adapter

You may be asking:

  • Do I need a soldering iron? No.
  • Do I need to cut some wood or aluminum for a firewall? No.

Here’s what you do:

  1. Unscrew the three screws that secure the cowling to the nose of the plane
  2. Unscrew the four screws that hold the plastic motor mount to the firewall
  3. Disconnect the three motor wires (red, yellow, and black)
  4. Unscrew the motor from the motor mount
  5. Use the cross mount thing that came with the motor to pencil in the 4 new holes you’ll be drilling
  6. Drill the holes (be sure to use a drill bit that is the same size as the old holes
  7. Screw the motor on to the mount, connect the wires, and put the whole thing back on the plane
  8. Hold the plane straight up, power it up to full throttle, and release
  9. Watch it fly straight up to the clouds like a friggin’ rocket

Here are some photos of my (not so) handiwork:


This is what it looks like when it’s done. The motor isn’t quite as long as the stock motor, so I tossed a nut on the shaft before I put the propeller on. Without that nut, the prop would be rubbing on the cowling.


Here’s the motor bolted to the stock motor mount. I was in the process of screwing in the 4 mounting screws when I took this.


Here’s where I drilled the 4 new holes for the new motor (circled in blue). The new motor has two holes that are perfectly spaced to line up with the stock motor mount, but the other two holes are actually closer to each other, so you have to drill. I opted to drill 4 new holes, but you may get away with using just two of the stock holes, or even drilling only 2 new holes. I wasn’t quite willing to trust that, and after seeing just how much torque this motor provides, I’m glad I didn’t.

You may also notice in the photo above that this motor has a really weird prop adapter. Rather than tightening on to the shaft, it actually screws onto the bell of the motor. Notice that the motor has a shaft that extends out the aft side of the motor (if you wanted to mount it in reverse). I’ve never seen that in a motor before, but I like it. It seems much sturdier with 4 screws on the bell than a single set screw or “clamp” style prop adapter fastened to the shaft.

The Results

I took it out to the flying field today and did my usual hand launch. Except this time I only launched it using half throttle. It flew out perfectly. After a couple seconds, I punched it up to full throttle and aimed the nose at the clouds. It flew perfectly vertical for a good 5 seconds, showing no signs of slowing down. It was awesome. I was flying huge loops, square loops, vertical rolling ascents. It was great.

The Electronics

I used the stock speed controller (ESC), but I also have a ParkBEC because I don’t trust the stock ESC’s integrated BEC at all, having heard lots of horror stories about it. The stock ESC showed no sign of overheating, though it was about 45 degrees F outside. The motor stayed cool too.

I used a new Zippy 2200mah battery from hobbycity.com. It did great too. No signs of overheating. It came down just barely perceptibly warm to the touch. Within seconds, it had cooled to room temperature. This was the first flight of the new Zippy battery.

My Watt’s Up tells me that the 10×3.8 prop makes this motor pull exactly 30 amps. That’s a lot of amps for this ESC, so I also bought a SuperSimple 50A ESC from hobbycity.com, which I have not installed yet. I may wait to see how the stock ESC performs for a while, because I just don’t want to solder all that crap again (including the ParkBEC).

Bottom Line

This motor is awesome. I plan to use the T-28 as an Aerotow plane soon, so this motor will give me exactly the torque I need. The plane is still quite a slow flyer compared to my Stryker, but even though the T-28’s top speed is lower, it has better vertical.