TheJach.com

Jach's personal blog

(Largely containing a mind-dump to myselves: past, present, and future)
Current favorite quote: "Supposedly smart people are weirdly ignorant of Bayes' Rule." William B Vogt, 2010

Simple abstraction

Abstraction is good. Say you're given the following task: write a script to take in five integers as input, add them together, and print the result. A naive implementation would look like this:


n1 = raw_input('Enter number: ')
n1 = int(n1)
n2 = raw_input('Enter number: ')
n2 = int(n2)
n3 = raw_input('Enter number: ')
n3 = int(n3)
n4 = raw_input('Enter number: ')
n4 = int(n4)
n5 = raw_input('Enter number: ')
n5 = int(n5)
total = n1 + n2 + n3 + n4 + n5
print total


Now, this certainly gets the job done, and if you're new enough that you can't conceive of better abstractions to make the work load a lot less, this will suffice for a first shot allowing you to continue work on launching your product... If you're writing software for a company that's not giant, the first job should be making something that works, the second job is making it work efficiently/elegantly/maintainable. While I'm working I have to stop myself from premature abstraction that I didn't see until I was done with a naive approach. I'll get the obvious things, sure, but a few times I've seen abstractions for the entire code base that I was only allowing myself to do later, not at the moment I saw them.

See Full Post and Comments

Mesh Current Method

Suppose you are given this circuit topology:

mesh

What is the power dissipated by the 1 k-ohm resistor in the center?

See Full Post and Comments

You are being hit by a bat

I'll begin with a quote from Douglas Adams:

Imagine a puddle waking up one morning and thinking, "This is an interesting world I find myself in, an interesting hole I find myself in, fits me rather neatly, doesn't it? In fact it fits me staggeringly well, must have been made to have me in it!" This is such a powerful idea that as the sun rises in the sky and the air heats up and as, gradually, the puddle gets smaller and smaller, it's still frantically hanging on to the notion that everything's going to be alright, because this world was meant to have him in it, was built to have him in it; so the moment he disappears catches him rather by surprise. I think this may be something we need to be on the watch out for.

I encourage you to read the quote again and think on it.

See Full Post and Comments

Why you'll never see real government-mandated safety or public automation for cars

I've got an idea that I'll share that I'd like to try and bring to the market sometime in the next few months. Basically, it's a series of IR sensors you attach to the exterior of your car (via magnetism or something sticky) and they wirelessly send a signal to a controller inside that will make a buzzer go off if a sensor detects something too close. I hate backing out of parking stalls and not being sure how much room I have left behind me, and I don't want to wait until I hit someone's car before I find out, so I often find myself doing a few reverse-forward-reverse-forward cycles before being on my way. Rear-view cameras solve this problem too but are expensive.

Anyway, I was thinking "The government already mandates basic safety and pollution requirements for cars, why don't they mandate real safety like forcing a max speed through the radio?" Almost every car has an antenna, it seems like through the use of cell blocks or radio waves or something the government could easily send out a signal to cars in a certain area that they cannot exceed speed X and force manufacturers to install the limiting device. After a few years of improvements that can even lead to fully automated cars. For older cars, do the same they did with the recent digital shift in television: give out free vouchers for the mechanism to limit your car's speed.

What about people that disable the mechanism? If you catch them speeding, you criminalize them with some high punishment (more than current speeding tickets do). Problem solved. This also helps the police by enabling them with tools to override a radio signal and stop a car they're after, since most runners aren't hardened criminals that would have previously disabled the device.

See Full Post and Comments

My rule for getting help

Fairly often I'll run across a problem that doesn't stump me, per se, but is challenging enough that I can't solve it very quickly and my usual approaches to solving problems are failing me. When even descending into the dreaded shotgun testing method (the last resort of a desperate man...) fails, I know it's time to get help. But I have a rule for getting help before then: did I think it would take me less than thirty minutes, and has it taken me longer than 45 minutes? If so, I implement a two-step process: post a help message somewhere (Stack Overflow, a mailing list, an email, a bug case), but then the most important step: keep working on the problem. When others are helping you with the problem too, that doesn't mean you sit on your hands and wait for them. (I've seen this happen a lot.) At the very least pretend the problem is solved and move on to the next step.

The second step is so important because very frequently I find myself solving the problem quite soon after posting my help message.

I have a simple theory for why this is so: writing out the help message lets you focus your mind on what you already know about the problem, plus when writing the message (if you've done it more than once anyway) you know it's good etiquette and you're more likely to get an answer if you generalize the problem to a less-specific case. A potential helper doesn't need to know your login checking query if your problem is handling a failed login on the client side, so you leave that out of your summary. In addition, you're taking a break from actively attempting to solve the problem, but not letting the problem escape your brain's local cache like it might if you go take a walk.

See Full Post and Comments

Tao Te Ching Reflections, 56 through 81 (end)

(I'm really bad at this. I guess it's just not high on my priority since I've read it so many times, but rereading is essential. I still have trouble living the parts I have accepted..)

56

Those who know don't talk.
Those who talk don't know.


See Full Post and Comments

Have some physics! Impulse

In the interest of posting something I'm going to mostly copy a comment here that I made on a forum. :)

To set up some context: why do buses have big, foam-padded seats instead of seatbelts? The answer is that foam-padded seats provide the same function as a seatbelt, but without the risk of strangling a kid or breaking one of their bones. Buses rarely tip over (though there are some (and I may be going to hell for suggesting) humorous videos on youtube of such incidents), and it still seems better to let the kids fall to the roof than get hung by a seatbelt (possibly from their necks!!).

Anyway, what is it about seat belts and foam seats that make them desirable?

See Full Post and Comments