Write It Out

I’ve seen this suggested before, but only half-believed it.

When you’re stumped by a question, write it out. We’re hosting a video game tournament tomorrow, and I was thinking about scoring. I got stumped by some technical problems with the way the bracket would work.

So I decided to burn my weekly Ask MetaFilter question. Except, three-quarters of the way through writing out the question (in great detail), I realized exactly how you solve the problem.

The thing is, if I sat here and tried sketching out how the bracketing would work, I never would gotten it. For some reason, writing it as a question caused me to be able to answer my own question, in a way that starting at it didn’t.

Seriously, try it next time you come across a tough question. It obviously doesn’t work 100% of the time (“How many escalators are in Wyoming?”) But something about writing it out causes the mind to look at it differently. And sometimes that’ll solve your problem!

Also, an Excel hint… How do you do “Best 2 out of 3?” in Excel? There’s no native function to do it. And if you asked me to write code, I’d overthink it and write some contrived thing that would take the best x of y items. But let’s say that cells A3, A4, and A5 (thus A3:A5) contain the three scores, and you want the best (highest) two of the three. =SUM(A3:A5) - MIN(A3:A5) does it. Best two out of three is the same as “All of them, discarding the lowest.” This doesn’t scale: if you wanted the best six out of eight, it’d be much harder to compute. But here, you’re just dropping the lowest.

Business School

As I’ve mentioned in a few past posts, those of us in business school really don’t think normally. Having found that there are a lot of good jobs in Nashua (versus my previously-narrow search in Boston), I started looking, out of curiosity, at real estate in Nashua. And I stumbled across this place, a home with an attached storefront.

It’s located in a very dense rural area, and seems like it may have a high percentage of renters in the neighborhood. So I thought a laundromat may do well. Of course, you also stock a lot of vending machines. Although labor really isn’t necessary, I’d probably want to employ one person to watch over things, and maybe to do laundry for people who want to drop stuff off, and to help customers who need it. I’ve read that it’s hard to keep good staff, but really, the job requirements are minimal–you have to be able to work a washing machine, be friendly to people, and watch over the store. You’d probably have a lot of free time, too, which could be spent watching TV, surfing the web, or whatever. And I don’t think I could bring myself to pay less than $8/hour or so.

It’s hard to find much information on commercially-available solutions, but a “water recycling” system could help cut costs, too–filtering the “waste water” and reusing it. Additionally, I’d sell plastic “gift cards,” at a small discount. ($50 for $45 or so.) The cards would also help everyone by not being coins, meaning that they wouldn’t have to lug around a pocket full of quarters, and I wouldn’t have to empty huge hoppers of quarters. (Although a lot of coin-based places seem to end up being “closed loops” of quarters–you put your bills into the change machine, get quarters, and put them into the washers or vending machines. So at the end of the week, I go in and move the quarters back into the change machine, and take the bills to the bank.) Selling the pre-paid cards, though, would generate a lot of cash up front, which could be put into a high-yield savings account. If you get a gift certificate for your birthday, how long until you spend it? Especially when it’s a “bulk” item (something you can spent on multiple visits), it may well be six months or longer before you’ve depleted it. Further, gift certificates also get forgotten and lost. Thus, if I sell $5,000 in gift certificates, I might only ever have an expense of, say, $4,500. And that $5,000 is in the bank earning me a decent chunk of interest.

They now make cheap security cameras that do resolutions like 1280×1024, versus the standard 640×480. And with things like ZoneMinder on Linux, it’s easy to set up an excellent camera system on the cheap.

I’d also pull in a cheap cable/DSL line and offer free WiFi for people doing laundry. Hopefully, while waiting for their laundry, they’d also buy some food from the vending machines. (As long as I have someone working there, actually, we could maybe serve fresh, hot food, like hot dogs or pizza!)

And of course, there are benefits to me besides the income. I wouldn’t need a washer and dryer in my home, since I’d have a dozen attached to my home. And I wouldn’t need to buy Internet access, since I’ve already got it at the laundromat. Plus, it’s occasionally a problem to have packages delivered to my house, as no one’s home and they might need a signature. Now I’ve got an employee who could collect them.

Of course, only after developing a killer business plan in my head did it occur to me that maybe I don’t want a home in a not-so-hot neighborood, especially one where I don’t have a driveway.

BitTorrent is Cool

Having recently pulled down some updates via BitTorrent, I discovered a cool neat thing about the protocol. Obviously, it’s basically a peer-to-peer filesharing tool. But it has some neat things that keep it working well. Files are split up into many pieces, and each of those chunks can be downloaded from anyone. (Apparently, various file-integrity provisions exist, too, to help guard against people injecting garbage.)

The first neat thing is the concept of “choking” selfish systems. As I download chunks, my torrent client will automatically start sharing the completed chunks. If my client detects that you’re downloading completed pieces I have, but not sharing the completed pieces you have, you get “choked,” or banned. I stop sharing with you. (Periodically, an “optimistic unban” will kick in, giving you another chance.) This greatly increases the incentive for you to share files: otherwise, everyone would want to download only, meaning that very few people had the file.

The obvious problem is that the file, if one piece is missing, is useless. If you take a random 1MB chunk out of the middle of Microsoft Office, the whole program will fail to work. (Not that I condone downloading MS Office via BitTorrent. After all, it’s free from school!) So it’s important to make sure that no pieces become unavailable. So most clients implement a neat algorithm, called “rarest first.” The name sums it up pretty well: as clients go out advertising what pieces of the file it has, it will go out and grab the least-available pieces first. And after I finish that piece (and, by necessity, begin advertising that piece to peers), I go and get the next-rarest piece. Since the whole is useless without all the parts (the whole point of the rarest-first system), it doesn’t matter what order I acquire them in, thus permitting each client to help raise availability.

Overall, the more I read about the inner workings, the more impressed I am.

BitTorrent

A few tips, in the hopes that it’ll help someone else. (Aside: don’t download illegal stuff with BitTorrent. Do download the many awesome, legal things on BitTorrent, such as Ubuntu torrents.)

  • You can encrypt your BitTorrent traffic, which is meant at circumventing ISPs that feel like being pains and blocking traffic. However, “Enabled” isn’t the value you want. You want “Forced.” In uTorrent, this is under Preferences -> BitTorrent.
  • If you don’t upload at all, other nodes will “choke” you by refusing to talk to you. It doesn’t seem to me like it has to be entirely equitable; I’ve capped my upload at a pretty small number, but am downloading around 100 kB/second (800 kbps).
  • You’ll have a port number for incoming connections. If this port isn’t coming through (such as if you have a “default-deny” policy), things will work, but they’ll be unbearably slow. As an aside, if you’re behind an OpenBSD firewall (using pf), have a local IP of 192.168.1.79, and use the randomly-selected port 26689 as your local port for BitTorrent, the firewall rule looks like rdr on $ext_if proto tcp from any to any port 26689 -> 192.168.1.79 port 26689. Remember to flush the rules (pfctl -F rules) and then (possibly required? possibly done automatically with the flush?) load them back in (pfctl -f /etc/pf.conf).

With these three principals in mind, my (legitimate) download went from 0.8 kB/sec to 145 kB/sec.

Huh, a neat tip… If you pick a torrent from one site, but it’s something identical to what other sites have, add the additional trackers in to the first download, which will give you more peers!

Oh, another tip: don’t arbitrarily set a download limit! My downloads wouldn’t break 145 kB/sec or so, until I realized that I’d set a limit of 150 kB/sec. I removed the limit and am suddenly at 400 kB/sec. (Incidentally, our available bandwidth has suddenly plunged to nothing…)

One final note: Peer Guardian is good, but don’t run it unnecessarily, since it blocks a lot of legitimate traffic. Including, oddly, Steam’s servers (for games like Counter-Strike and TF2), apparently because they use Limelight’s CDN, and they’ve dubbed Limelight bad?

Security Forces

I just finished a show on “NatGeo” about the private security firms working in Iraq. It was a really interesting watch. They’re not there to engage in combat, but they’re there for “security,” such as escorting construction materials for a new police station (something insurgents are eager to stop), and transporting VIPs around.

IEDs are apparently a huge problem, moreso than the news portrays. One of the guys brought back his SUV, with the whole side blown in and full of bullet holes. The SUV was “reinforced,” meaning that it had bullet-proof glass and huge steel plates over it, and yet it was still in terrible shape. He made it out alright, although the driver, an Iraqi, died. “That was my seventh IED,” he mentioned casually.

Most are apparently set on desolate roads, and are basically just tripped by any car. There are often just tripwires that set them off, versus manually being tripped. Which got me thinking of an old idea…

I want to build an “RC Car,” something radio-controlled. Except I don’t mean a little RC car. I mean an actual car that’s driven remotely. With GPS and a set of video cameras (plus a high-speed, low-latency data link), you could be pretty accurate. It probably wouldn’t be a good idea to remotely drive one of these down Route 3 (although I think you could design it to work pretty accurately). But I think they might rock in Iraq. You send one out a quarter-mile in front of your “real” convoy. No one’s in it, but its main purpose would be to trip IEDs, and do some scouting for you. From the back of a van in tow, or from a remote headquarters, people could watch for anything suspicious. And, “worst case,” it trips an IED, effectively wasting the IED on blowing up a van with no one in it. The real people behind could either divert their course, or plow on through, knowing that the bomb had been detonated.

I’ve also thought RC planes would be interesting. These days they’re “UAVs,” unmanned aerial vehicles. What I have in mind is isn’t the military UAV, a “real” airplane remotely controlled, but something a couple feet long with some cameras. Outfit it with GPS and various data links, such that it can stream video real-time, or even capture higher-resolution still images and transmit those. (Heck, fit a high-end camera on it, but have it transmit a 640×480 image, and just store the full-res to an 8GB Flash drive…)

I always thought it’d be cool to have as a pet project. Fly it around and go “sight-seeing” from your room, with what’s essentially a wireless webcam in the sky. I think they’d also be popular with places doing mapping / “satellite” imagery, as you could send these little things up and just have them run autonomously, snapping photos of an area until the batteries / gas ran low, at which point they’d return “home.”

But these things would rock in combat, too. Send these out over areas you’ve got to travel. (And areas you’re not travelling, to keep them guessing.) At a remote command post, someone can spot potential threats and identify them long before they become a problem. (You could even try grazing them with your mini RC plane.)

I don’t know what sort of radio infrastructure over there (well, I know they’re running CDM1250s and HT1250s, but I mean, I don’t know if they run repeaters / what power they run), but you might even fit a portable repeater on the little UAV, ensuring that their portable radios could still keep in touch with their post miles away.

As an aside, the radios I saw them with in the show don’t support encryption, meaning that it really wouldn’t be hard for insurgents to tune in. Their bombs keep getting more and more complex, showing that they’ve got some technically-minded people on board. It seems like a pretty bad idea to me to not encrypt your radio traffic in those circumstances.

Opium

Afghanistan has a flourishing opium trade. They apparently produce most of the world’s opium. Ironically, it’s kind of our fault–the Taliban had pretty much eradicated all poppy cultivation, but with them gone, it’s come back. A recent news story suggests that the Afghani leaders in charge of fighting opium quit after their pay was slashed due to overseas funding drying up. (This one was poorly thought through…)

I want this job. Here’s my plan: encourage opium cultivation.

India has a flourishing, but regulated, opium trade. The product is sold to pharmaceutical companies, who refine it into morphine. Farmers are apparently limited to how many poppies they can grow. The government periodically does inspections of farmers to make sure they’re complying, and to make sure that their product isn’t being diverted into illegal usage.

This is what Afghanistan needs. You deal a crippling blow (again…) to the illegal drug trade, while also bolstering their economy with pharmaceutical sales.

Where do I submit my resume?

Public Safety

For those of you who don’t monitor police scanners regularly, I’d like to introduce what can be considered a fairly scary fact: their computer systems go down all the time.

Where it usually comes up is when they try to run a license plate or a person, or to query NCIC or similar. The officer calls it in and waits a few minutes, before the dispatcher calls back that the (remote) system is down. When you’re monitoring multiple neighboring towns, you’ll often notice that they all lose it at once. The backend servers are going down.

This drives me nuts. It’s usually not a huge deal, but now just imagine that you’re the police officer, and the guy you pull over, but can’t run through the system, actually has a warrant out for his arrest. For murdering a police officer. But you have no clue, because the system is down. Of course this is extreme, but it’s always been said that traffic stops are actually the most dangerous and unpredictable things an officer does. They never know whether it’s a nice old lady or someone with a warrant out for their arrest. A decent amount of arrests come from pulling people over for traffic violations and finding subsequent violations, like cocaine or guns, or an outstanding warrant.

My webserver sits in Texas on what’s basically an old desktop system. And it seems to have better uptime than these systems. As biased as I am in favor of my blogs, even I will admit that police databases are more important. Further, if my blogs were routinely unreachable, I’d be furious with my hosting company. Why is it tolerated when this happens?

Databases are fairly easy to replicate. Put a “cluster” of database nodes in a datacenter. You’re protected against a hardware failure. Of course, the data center’s still a single point of failure. So put another database node in a separate datacenter. That alone is probably all you’ll ever need. But you can keep turning up more database nodes in different locations as budget permits. (I suspect budget is the limiting reactant.)

But you can take it one step further. Set up another database node, not in a lonely datacenter, but in a large dispatch facility. (The MA State Police apparently run a very large 911 answering center.) So they get a database node there, that doesn’t answer public queries, but that receives updates from other database servers. And, in the event of some sort of catastrophic failure, remote dispatchers can call up and request that something be run.

I’m just really bothered that people seem to find it acceptable that, probably at least once a week, the system is unreachable for quite some time.

Confirmation Bias

Have you ever noticed that someone mentions something, and all of a sudden you notice that thing multiple times? One professor mentioned that very phenomenon one week. Early the next week, I was touring Waltham’s 911 dispatch center, and noted the software they used forĀ  (Computer Aided Dispatch) CAD, intending to look more into it. The next day, I had that professor’s class again, and, for reasons I still don’t understand, somehow slipped in a mention of knowing someone who worked at that company. So I mentioned this to him after class, and also pointed out the incredible irony of the fact that the week before he’d mentioned the “someone mentions something, and all of a sudden you keep seeing” it phenomonen. {Meta: this phenomonen may, itself, be related to a confirmation bias, but I digress.}

So Kyle mentioned confirmation bias in one of his recent posts. The next day someone on Ask MetaFilter asked why black people were afraid of his dog. Most answers bordered around it being a confirmation bias. (Although it got interesting when several people reported having noticed the same thing, suggesting that maybe, just maybe there is some sort of racial difference in how dogs are viewed.)

The other day there was a lunar eclipse. Around the same time, we had several short problems with Internet access, where traffic wasn’t leaving Bentley. (Incidentally, I had the same experience I’ve had with most of my tickets–I only open then when I run into an issue I can’t solve myself and am very confident that it’s a problem, so I usually include enough information that the front-level have no idea what’s going on an forward it to an expert… So I ended up speaking with our “Network Engineer,” a position I didn’t even know we had, and we had a good talk about exactly whta the problem was… It appears to lie with an upstream company performing some maintenance.)

So today my professor–who teaches nothing related to electronics nor astronomy–randomly interrupted her lecture saying, “Thursday was a lunar eclipse. Did anyone else experience technical problems because of the lunar eclipse?” People had several problems that day–several brought up the Internet disruption. Someone had their computer crash. She explained that the lunar eclipse tends to cause those things.

If ever there were evidence of a confirmation bias, that’s it. I don’t profess to be a total expert, but I’m pretty certain that the moon being obscured by our shadow isn’t why our Internet link went down for a couple minutes. And yet she’s found plenty of evidence to support what’s probably an urban legend.