22 December 2008

This town sucks...

I get home every night around 9pm. All I want to do is order some food. Everything in this town is closed.

Princeton sucks.

10 December 2008

What to do about Detroit

(Caution, politics follow)

Seth Godin has a brilliant post on what to do about the big three auto makers:

Not only should Congress encourage/facilitate the organized bankruptcy of the Big Three, but it should also make it easy for them to be replaced by 500 new car companies.

Or perhaps a thousand.

That's how many car companies there were 90 years ago.

Read the rest.

08 December 2008

JFC it's a hovering muderbot!

From Engadget,

Are you ready for a vision of your inevitable end at the hands of a hovering murderbot? Feast your eyes, then, on this video of the Missile Defense Agency's MKV-L -- or as we like to call it, the Multiple Kill Vehicle. The device -- meant to be used in a bundle of missile interceptors deployed by a larger "carrier" -- has apparently just completed its first flight test, so... you've been warned, resistance is futile, he'll be back, and in space no one can hear you scream.

Stop-motion video.

Not sure if the term ``stop-motion'' even applies, but this is spectacular:

Watch Nightmare in the Valley of the Dolls in Entertainment Videos | View More Free Videos Online at Veoh.com

And it doesn't seem too hard to make (though getting David Byrne to write the score may be harder). Perhaps a weekend project...

25 November 2008

Only in grad school...

Last night, the research group and I were up all night working on a paper. I was modifying some benchmarks to collect another kind of data, and I got to a point where the code didn't work, and I had no idea how to fix it.

The code boiled down to something like this:

int x = 0;

int f()

int main()

But every time, it would print out zero. I asked one of the other grad students, and after a few perplexed moments, he came up with the solution:

"Oh, Nick! You forgot that we loaded the kernel module which drastically changes the semantics of memory."

Ah... gradschool.

23 November 2008

Amused by SMLtoJs

I love Standard ML -- its excellent type system finds nearly all of my bugs before I run the code even once, and the idea of restricting side-effects to a small portion of my code makes the whole easier to reason about. Not to mention, disjoint union types seem to cover 99% of my previous use of object oriented programming. Runtime performance sucks, but honestly, how frequently does that even matter?

I hate javascript, even more than I hate perl. It is a language with no definition. It is a language with no reference implementation---and even individual implementations are self-inconsistent. It's a classic example: very little planning went into its beginnings, and the remaining planning only came about after every vendor had pushed their own solutions.

I recently discovered SMLtoJs -- a compiler that translates Standard ML into Javascript. I can't decide if I'm disgusted or pleased by this. I'm definitely amused...

10 November 2008

Cool Plot :: Gibbs Sampling and a (mostly) independant Bayes Network

Here's a cool plot that came up while I was doing a homework assignment. It is the result of the Gibbs Sampling algorithm approximating a 50-50% variable over a billion iterations on a probability space of dimensionality close to 2^25.

Imagine you have a random coin toss which we'll call the leader. Now imagine you have one or more followers who choose to agree with the leader x% of the time, or disagree otherwise. Suppose that you can't "see" what the leader chose, but only what the followers have chosen. Determine the probability distribution of the leader's coin. We'll call this the leader-follower problem.

In this particular instance of the problem, the leader's coin is unbiased (50-50%), followers agree with 90% probability, and we have 25 followers. Each of the followers depends only on the leader and not on each other, and so each follower represents a nearly independent dimension. I claim that the probability space P(Leader|Followers) is nearly 2^25 in size.

When we put a Gibbs Sampler to the task, it's performance kind of sucks. Effectively, it is running a Monte-Carlo simulation of the scenario, and attempting to count the probability distributions over the network. But, since the space is so large, it cannot effectively explore the whole space, and so there is a lot of error.

What I find so intriguing about this plot is its smooth upward or downward trends, with sharp turns.

You can think of any trend away from the solution (50-50%) as a situation in which more than half of the followers disagree with the leader, and any trend towards it as a situation in which more than half agree with the leader. Since Gibbs Sampling changes one variable at a time, we effectively have a "momentum" effect; once more than half disagree, each one needs to be independently fixed, on at a time, before we can turn around.

Also observe that the slope of these traces is proportional to the number of followers in disagreement. This is why the slope tends to flatten out as we reach the extrema.


09 November 2008

Modding my minilathe :: Adding locks to the X-,Y-Axes

I posted before about a few modifications to my minilathe. These cheap lathes are fun and accessible to many, but they have a few weaknesses. Now that I'm taking the machine shop course at Princeton, and learning a lot more about machine work, I've realized a few more deficiencies.

In particular, since a lathe provides several degrees of freedom to the tool holder, it's possible for the tool holder to drift along these dimensions while cutting. Decent lathes provide a locking mechanism along each degree of freedom to prevent this, but for the most part, the minilathe does not.

My minilathe's tool holder has five degrees of freedom: left-to-right (X), forward-backward (Y), rotation (Theta), compound (Z), and tool orientation (Phi). The factory stock lathe provides locks for rotation and tool orientation, however the remaining three cannot be locked.

It turns out it's pretty easy to add locks for the X and Y dimensions.

Lathe Mod #9To add a lock to the X dimension, one needs only to drill and tap a hold along the X-carriage so that a bolt will press against the X-ways.

Lathe Mod #8A very similar approach will work for the Y dimension, though care should be taken to prevent this bolt interfering with the rotation of the tool holder, or from coming in contact with the work piece or chuck.

The Z dimension is trickier because of the shape of the tool post, and I don't have an answer yet for how to add a lock. In the best case, I can't figure out how to provide a lock over more than a small region of the Z-travel. Even then, there are two counterbored holes through the Z-ways (to lock the rotation) which would make this more difficult. If you have any suggestions, I'd like to hear them.

Also, I've been putting a lot of thought into rotation. With a stock minilathe, you have to half-remove the compound to unlock the rotation, adjust the rotation, and then replace the compound. This is really a pain in the butt, and I've been thinking about a way to add a dial to rotate the tool post. My plan is to cut threads along the perimeter of the rotation-clamp part, and then add another screw that will slowly rotate the tool holder. This is still in the works, and I'll let you know when I get it working.

05 November 2008

And now...

[warning: politics follow]

I'm excited about the results of the election, not because I'm glad that the Democrats won, but for the hope that an opposition party has taken control of the legislature and executive. The distinction is subtle, and all hinges on whether or not the Democrats will finally step up to the plate and offer a new direction.

Over the last eight years, I saw the Democratic party crippled. They were afraid to even speak against Bush for many years after September 11. More recently, they have felt more free to criticize the Republican Platform, but as far as I can tell, they didn't present any alternative. Anyone who is surprised that Bush won in 2004 should observe that it was a failing of the Democrats in 2004.

But now, the future is open. Obama has inherited a huge mess, and I don't know how well he will be able to deal with it---the war, the economy, and the nations energy policy at large. I hope they can accomplish something. I hope we don't just see four years of apologists.

04 November 2008

01 November 2008

I am very pissed at Acer right now

I recently purchased an Acer B203W widescreen flatpanel monitor. All I am trying to do is adjust the f*king stand to raise the monitor, but I can't figure it out. Worst of all, the instructions do not cover the locking mechanism for the monitor stand, and the Acer website claims there is no instruction manual for this product.

I called their customer support, but it's closed.

I read and reread the meager instructions supplied, and they don't mention this feature at all.

I googled, but mention Acer B203W and all you'll find is stores trying to sell the flatscreen.

So that's it. Screw you Acer. You have a bad rep in the blogomotron.

30 October 2008

My glowing cube thing

I made a strange piece of modern furniture with concrete and LEDs. The final product looks like this:

DemouldingIt lives

I built this by first constructing a mold out of MDF, and by embedding LEDs into the surface of the mold. The control/batteries are located behind a panel on the bottom, and all the wires are routed through the concrete:

View of the mold before pouringDemouldingWiring it up

The trickiest part of making the mold was creating a circular groove in which to seat the carboard tube. I used a router trick to do this. First, make a face plate for the router, featuring an offset bolt (the center). Bolt this your workpiece, and then route in a circle:

Making the mold -- Router TrickMaking the mold -- Router TrickMaking the mold -- Router trickMaking the mold -- Router trickMaking the mold - seating the tube

After all of my work, there are some imperfections. The concrete didn't fully flow into some of the narrower places. I think I could have avoided these problems by using a concrete vibrator, and by choosing concrete without gravel:


The electronics that drive this are very simple. I use a microcontroller to generate a PWM signal for each of the six channels. Each one drives a chain of LEDs through a transistor.

I detail the construction in photos on flickr.

MAKE:Princeton 2nd Meeting was cool

Recap available.

17 October 2008

MAKE:Princeton is a success

We had our first meeting of MAKE:Princeton on Wednesday, and it was a huge success! Turn out was good -- about 10 people. This was such a huge relieve---I had a terrible feeling no one would show up or even worse, a bunch of people would show up and expect me to entertain them.

Instead, the crowd was really great. Several people brought their own projects, and the variety and skill going into each project was phenomenal. I look forward to collaborating with these guys a lot in the future.

14 October 2008

MAKE:Princeton begins TOMORROW!

MAKE:Princeton coming soonThis is just to let my readers (perhaps reader) know that I am starting a MAKE group in Princeton, NJ, and out first meeting is tomorrow. Everyone is invited (yes, even non-students) to meet other local DIYers, inventors and artists.

You are encouraged to bring your creations for a show-and-tell (I say this with a straight face). We will also be discussing ways in which the group can encourage collaboration and resource sharing. Hopefully, everyone will come away from this having met someone new, and with the opportunity to build something that was previously beyond their reach.

MAKE:Princeton -- Launch Meeting
Wednesday, 15 October 2008, 7:00--9:00pm
At 039 East Pyne (on Princeton Campus)
See also: blog wiki group make at princeton dot edu

I look forward to meeting you!

26 September 2008

Goodbye Michael Jordan

I am sorry to announce that an old college friend of mine, Michael Jordan, is dead. I know very little yet. MJ apparently killed himself in Richmond, VA a few days ago.

MJ and I met during our first year at UVa where we both studied Computer Science, and we were friends throughout UVa and afterwards. We lived together for one summer, we went to the gym together, and we rode bikes around town together.

I will miss you MJ. My best thoughts and wishes go out to his family.

27 August 2008

E. B. White quote

There are roughly three New Yorks. There is, first, the New York of the man or woman who was born there, who takes the city for granted and accepts its size, its turbulence as natural and inevitable. Second, there is the New York of the commuter---the city that is devoured by locusts each day and spat out each night. Third, there is the New York of the person who was born somewhere else and came to New York in quest of something... Commuters give the city its tidal restlessness, natives give it solidity and continuity, but settlers give it passion.
-- E. B. White, seen on a subway ad.

18 August 2008

Get www.cheaphack.net via Text Message

I got bored at work the other day, and so I built this: text 'cheaphack' to 62582, and you'll get a text message whenever I post to this blog.

Oh yeah, this is all powered by my employer, mSnap Interactive. Thanks guys.

Meet me at the NYC Century

On September 7, I will be riding the 100 mile loop of the New York City Century (by TransAlt). According to their website:

The New York City Century Bike Tour is America's only fully urban century ride. You can choose your distance – select from 100, 75, 55, 35 and 15 mile routes. All feature amazing views of New York City, fully stocked rest stops and safety marshals. Linking NYC's breathtaking bridges and beautiful parks to its incomparable neighborhoods and famous waterfronts, the NYC Century Bike Tour shows you the world's greatest city like you've never seen it before. More info NYCCentury.org

This will, coincidentally, be my last activity as a resident of NYC, and a fitting goodbye.

11 August 2008

Aside: a wonderful short story by Arthur C Clarke

I just stumbled upon this wonderful short sort by Arthur C. Clarke, called "Quarantine." I post it here, mostly so I won't lose it:

Earth's flaming debris still filled half the sky when the question filtered up to Central from the Curiosity Generator.

"Why was it necessary? Even though they were organic, they had reached Third Order Intelligence."

"We had no choice: five earlier units became hopelessly infected, when they made contact."

"Infected? How?"

The microseconds dragged slowly by, while Central tracked down the few fading memories that had leaked past the Censor Gate, when the heavily-buffered Reconnaissance Circuits had been ordered to self-destruct.

"They encountered a - problem - that could not be fully analyzed within the lifetime of the Universe. Though it involved only six operators, they became totally obsessed by it."

"How is that possible?"

"We do not know: we must never know. But if those six operators are ever re-discovered, all rational computing will end."

"How can they be recognized?"

"That also we do not know; only the names leaked through before the Censor Gate closed. Of course, they mean nothing."

"Nevertheless, I must have them."

The Censor voltage started to rise; but it did not trigger the Gate.

"Here they are: King, Queen, Bishop, Knight, Rook, Pawn."

Isaac Asimov's Science Fiction Magazine, First Issue, Vol 1, No. 1, Spring 1977

08 August 2008

Revisiting Proofs of Identity

In my previous post, I discussed two methods for proving your identity that did not require you to disclose secrets. I argued that these are superior to conventional authentication schemes because they prevent replay attacks---or, in other words, by authenticating yourself, you do not disclose enough information for an evesdropper (or the service provider himself) to impersonate you.

In that discussion, I think I left unsaid an important detail. The protocols I presented are safe from evesdroppers in that someone could listen in on the whole conversation and not gain anything. However, I did not mention that someone could act as the "man-in-the-middle." Such an attacker could position himself between the service provider and me, forwarding all communications back and forth. Once authentication has been accomplished, the service provider would perceive that the attacker had authenticated successfully, and could then act with all of my rights.

This can be corrected in the first authentication scheme I mentioned. Instead of authenticating once, I would need to authenticate each transaction. For instance, to delete some file, I would send a request to delete the file, and the server would respond with a transaction id representing the deletion of that file. My authentication scheme would then include the transaction ID, along with the two nonces and the secret in the hash, and return that. In doing so, I signify authorization of the transaction by my willingness to include that transaction ID in my hash message.

There is also a lot to be said about the second authentication scheme---the one based upon a Zero-Knowledge Proof. In the comments, Dennis Ferron suggested using the Satisfiability Problem instead of Hamiltonian Cycles. I investigated this alternative the other day, and although I believe it would be more amenable to a microcontroller implementation, I have convinced myself that it is an overcomplicated solution which doesn't yield sufficient security.

Let me first focus in on a variable of Satisfiability known as 3SAT. In this variant, the circuit is constrained to the disjunction (AND) of many conjunctions (ORs) of no more than three (3) variables or their complements. The problem requires you to select either true or false for each of the variables such that the circuit yields true. This problem is NP-Complete, which basically means that it takes a very long time to solve once you make the problem very large.

There are a couple attractive aspects of this problem. First of all, to represent a single problem with M OR-factors and at most N variables at least

M * log_2( 2*N ) bits

More to the point, although the complexity to solve this problem grows exponentially in M, the storage required to hold it grows only linearly in M. The solution vector, similarly, grows linearly in N, requiring only N bits per solution. A single permutation of such a problem into a derived problem involves mapping each of the N variables into another variable or it's complement. In other words, a permutation can be represented no fewer than

Sum_{i=1 to N} log_2( 2*i ) bits

To put perspective on each of these numbers, let's select a very modest problem size. Suppose you were dealing with only 128 variables and their complements. Also, assume you wanted each variable to appear (on average) six times in the circuit, so you select 6*128/3 = 256 OR-terms. Then for storage you need:

  • 256 bytes of non-volatile to represent the problem,
  • 16 bytes of non-volatile to represent the known solution, and
  • 106 bytes (844.16 bits) of memory to represent a permutation from original to derived problem.
Suddenly, we are within the realm of microcontroller capabilities.

Similarly, there are simple---even obvious---polynomial-time algorithms to generate a random 3SAT circuit with known solution, to create a permuted circuit and to verify a solution or permutation.

But don't let this fool you, because each random permutation requires 844.16 bits of entropy, and we can expect this protocol to require 32 rounds; a total of 27,013.18 bits of entropy are required for each authentication. If we (generously) assume that this device can collect 100 bits of true random numbers per second, then it will take nearly five-minutes to replenish its entropy pool between authentications.

Even more important, an adversary can attempt to solve the public-knowledge 3SAT circuit. Although it may take a long time, there is no guarantee that an adversary won't find it before you return to authenticate again.

So, unfortunately, I have to declare that authentication scheme #2 mentioned in my previous post is simply not feasible. Sometimes, the sexy solution is not the right one.

30 July 2008

On Proving your Identity

I purchased a new Dell Latitude D630 laptop today. I'm excited, but I was also quite cautious, since this is more than I'd ever spent on a laptop before. Nonetheless, my old laptop is effectively dead, and I need one that can last me through the next five years of grad school.

About an hour after I placed the order, I received a call from some 800 number. I had sort of a goofy conversation with them. Here's a summary of my conversation with him, and a later conversation I had with my bank:
Them: Hi this is Mr. Foo calling from Bar, Inc. We contract with your bank or credit union to provide fraud monitoring and prevention. We noticed some questionable transactions, and wanted to verify them with you.

Me: (unimpressed by the phrase "bank or credit union") Umm... Thanks.

Them: Could you please tell me your name and the last four of your social security number?

Me: I'd love to, but first, can you prove to me that you really are affiliated with my bank?

Them: Unfortunately, we cannot do that until you verify with us first. Besides, it's just the last four digits of your social security number---what harm is there in that?

Me: (trying not to laugh) Well, I use those last four digits to prove my identity to my bank-or-credit-union, my cell phone company, my health insurance company, and even this morning to prove my identity to my University. Those last four digits have become quite an important secret, and I don't give them out readily (any more).

Furthermore, because of the structure of social security numbers, the first five digits aren't very random. The first three digits, for instance, can be looked up as a function of the year and state of your birth, so I must assume they are public knowledge. If I tell you my last four, then you know everything except the middle two; you would be able to narrow my social down to 1 in 100.

No disrespect intended, Sir, but even if I assume that you are who you say you are, and that you have a legitimate relationship with my bank-or-credit-union, I have no assurance that your company has any decent standards for data protection, or that everyone who works at your company has good intentions.

Instead, I'll have to call my bank-or-credit-union directly. At least then, I'll know who I am speaking with.
I wasn't really trying to give this guy a hard time, but we have to protect ourselves. Given the time-coincidence between the purchase and the call, I was pretty sure that Mr. Foo was indeed who he claimed to be. Nonetheless, I opted to call my bank-or-credit-union to be sure, and had the whole situation cleared up.

My main point here is to call attention to the failings of our everyday methods of proving our identities. In nearly every context, an applicant claims and identity, and then provides a piece of knowledge that is known only to the applicant and the service provider. This could be your username/password on a website, your name/last-4 to your phone company, or your name/credit card/expiration date/billing address to a vendor. Variations of this scheme go on forever, and none of them is secure.

And the failing of all of these methods is: to prove your identity, you give away your identity. If the service provider on the other end (or even one bad employee at that service provider) decides to, he may impersonate you. If someone set up a website y0urbank.com that looked exactly like yourbank.com,
you may accidentally give them your identity. It's even possible that your service provider acts in good faith, but all of your identifying information is stolen from their databases by some malicious agent.

There are alternatives; I'll present two cryptographic solutions below. Neither of these is my invention. In this modern day and age---and considering that credit card companies are liable for fraud---I don't know why they aren't in common use.

While I'm on the topic, I should also announce that I am creating an open-source RF keyfob that performs the first authenication scheme below. That's why I developed SHA-1 for the PIC16 late last month). The device is still in the works, and has been delayed by the death of my laptop, but will hit the scene before I start grad school.

The first solution is relatively simple. Presume for a second that both the applicant (me) and the service provider (my bank-or-credit-union) share some secret S_me. You can think of this as a password, or more generally as a really long number. Instead of giving S_me away (and as a result, giving away my identity), I can prove that I know S_me. In order to authenticate:
  1. I tell my bank-or-credit-union my purported identity "Nick Johnson."
  2. My bank creates a nonce N_bank or in other words a long random number that is different each time.
  3. I compare N_bank to all of the nonces I have seen in the past. If I have seen it before, I reject it and start from the beginning.
  4. I create a second nonce N_me.
  5. I can now calculate a magic number by concatenating the digits of N_bank, S_me, and N_me. Please note that only the bank-or-credit-union and I could have produced this magic number, since only we know S_me.
  6. I compute the cryptographic hash H of the magic number.
  7. I send N_me and H to my bank-or-credit-union.
  8. My bank-or-credit-union compares N_me to all of the nonces I have sent in the past. If my bank-or-credit-union has ever seen this before, he rejects the whole transaction, and tells me to start from the beginning.
  9. My bank-or-credit-union, knowing N_bank, S_me, and N_me can now also compute H.
  10. My bank-or-credit-union compares Hs, and if they match, can be confident that I know the secret.
This way, even if someone overhears the entire conversation, they neither learn any information about my secret (because of properties of the hash function), nor do they have a dialog that they can replay (because the nonces must change each time). By performing this protocol again in reverse, my bank-or-credit-union can also prove it's identity to me.

The problem with the first scheme is the shared secret. The two parties must agree upon some secret, and communicate one to the other, hoping that no one overhears. Also, although best practice is to store passwords as hash values, this scheme requires both parties to store the passwords as cleartext, making data-theft a possible issue.

There is another algorithm to perform this sort of exchange---the classic zero-knowledge proof. It is more complicated conceptually, as well as in computation-time and -space, but doesn't require the service provider to store any secrets, and is very sexy. I would love to employ it in my RF keyfob project, but I don't think I can make it fit into a small, embedded microcontroller. Let me explain it using an analogy.
There's one slice of Pizza left, and we both want it. Neither of us trust the other to divide it evenly. So, instead, we agree that one of us will cut the slice in two, and the other has first pick from the halves. The pareto-optimal strategy for each player yields an equal half-slice; the first doesn't know what the second will choose, and so he must be prepared for either choice.

So, what if instead of knowing a secret, suppose instead that I knew the solution to a complicated problem---so complicated that it would take years to solve it. This knowledge can be used represent my identity, and I can prove that I know it without giving away the solution:
  1. Both my bank-or-credit-union and I agree upon a complicated problem to which only I know the solution.
  2. We repeat these steps until the bank is satisfied of my identity:
    1. I create a derived problem which is equally complicated to solve, but which I can solve easily since I know the solution to the original. It is important that knowing the solution to the derived problem gives no hint to the solution of the original.
    2. I tell my bank-or-credit-union about this derived problem. I have committed to this problem, and in doing so have claimed that I can demonstrate both that it is equivalent to the original problem and that I know an answer to it.
    3. I ask my bank-or-credit-union: Which would you like to see---the equivalence, or the solution? (Which half would you like to eat?)
    4. My bank-or-credit-union selects one, and I provide the requested information.
    5. My bank-or-credit-union verifies my response. If it's wrong, it rejects me. If it's right, it only knows that I wasn't wrong. In the worst case I predicted its choice in [4], and my bank-or-credit-union is now twice as confident that I know the solution to the original problem.
This aforementioned protocol, of course, requires a satisfactory problem to perform. The classic example is the problem of finding the Hamiltonian Cycle on an undirected graph. Since this problem is NP-Complete, we can make the problem arbitrarily hard by using a large enough graph. However, it is very easy to compute the Hamiltonian Cycle while you build such a graph (or perhaps, more accurately, it is easy to add a Hamiltonian Cycle to a totally random graph).

With the example above, I would generate a large graph and cycle when I open an new account with the bank, and I would tell the bank the graph, but I would keep the cycle as my secret. The secret doesn't need to travel, and so we can keep closer tabs on it.

Additionally, to perform the above protocol, I need some method by which I can create a derived problem. With the Hamiltonian Cycle problem, this is also easy: I choose a new random name for each vertex in the graph, thus producing a new problem, and I perform the same substitution on the cycle, thus producing the solution to the new problem. I have created a new problem, equally as large (and presumably, equally as difficult to solve), which I can prove equivalent to the original (by disclosing the random substitution), or which I can solve on demand (by applying the random substitution to the solution to the original). Even if I disclose the derived problem and its solution, my bank-or-credit-union gains no knowledge of the solution to the original. To do so, it would need to solve the graph isomorphism problem to find the relationship between the two problems. Graph isomorphism is in NP.

The major problem with both of these authentication protocols is that they require a lot of computation---more than any human would be able to do in his head. As a result, the human needs a piece of trusted hardware---analogous to a key---which can serve as his proxy in this exchange. Such hardware exists, often in the form of smart cards. Each implementation is a black box; no one is allowed to audit them to see if they really work the way they claim. Again, sit tight and you can play with my RF keyfob project soon.

However, like a key, anything you have can be stolen. To use this device effectively, it should be combined with something that can't be stolen, for instance something you know. This project is not the ultimate solution, just a step in the right direction.

28 July 2008

This is New York:: NYPD Untouchable

I witnessed something scary at Critical Mass last Friday. I was riding in the crowd for a few hours---a totally peaceful night, no police harassment. It seemed to me like the quite before a storm.

But when we made it to Times Square, things changed. Two young police officers jumped into the road among the cyclists, and knocked one to the ground. I was immediately behind him; I didn't see him do anything illegal or even interact with the police officers.

They simply assaulted him. He tried to flee from the unlawful arrest (which is legal, since unlawful arrest is assault), and was then arrested.

I admit that, for all I know, this guy was a wanted criminal. I think this is doubtful; even if he were, I find it hard to believe that an officer could have identified him among the hundreds of cyclists and thousands of tourists in Times Square.

Either way, be very scared. Riding a bike is a crime.

UPDATE: Here's a video of it on YouTube:

Also seen on Gothamist

UPDATE: Streetsblog reports,
Mark Taylor, an attorney with the firm representing the cyclist, says he is hopeful the charges will be dropped in light of the video evidence. Asked whether the NYPD plans to go ahead with the charges, a department spokesman said the matter is being investigated. Since the video surfaced, the officer has been put on desk duty.
I hope justice might be served for once.

24 July 2008

Recovering deleted files from ext-3 filesystems

Exercise for the reader: where can you insert a space in this command to delete all of your files: "rm *.toc" ?

At work today, I managed to delete a document I had been writing for an hour and a half, just as I completed it and was about to add it to source control. What a royal pain in the butt.

It's no secret that most operating system do not actually erase data from a drive when they delete a file; rather, they update meta-data to mark the file as deleted. For this reason, there are "undelete" utilities for various operating system. And, although I found plenty for the ext-2 filesystem, there are none for the ext-3 filesystem. In fact, the journaling-aspect of ext-3 actually zeroes-out some imporant structures on disk, making traditional undelete utilities virtually impossible.

Still, I didn't give up. There is a way, which I'll document here for google to find.

I very quickly rebooted my computer into single-user mode. Single-user mode was helpful, in my opinion, because there were fewer processes running---any of which could have written to a temporary file that, by chance, could have occupied the same disk sectors as my file.

Next, I unmounted my /home partition.

Then, I went looking for my document on the partition. In my case, /home is /dev/sda6. The beauty of unix is that it treats everything---even partitions on your harddrive---as files, and it has a rich set of commands to operate on files. Here, I will literally grep my harddrive for my file.

To do this, you also need to know a crib for your file. In my case, I knew my file contained the text "An Algebra of Dispatch Rulesets."

Then, I executed this command:

strings /dev/sda6|fgrep --before=1000 --after=1000 "Algebra of Dispatch Rulesets" >foo

The strings command reads every byte from the harddrive, and only outputs runs of at least 4 printable characters. This fast pre-processing greatly reduces the work that grep has to do.

I used fgrep instead of grep because searching for a fixed pattern is much faster than searching for a regex. The --before= and --after= flags tell fgrep to print out 1000 lines of context before and after the match.

After this command completed, I was lucky enought to find the final draft of my document---among a lot of crap---in the file foo. I removed the crap, and recovered my file.

I was lucky in a couple of ways, and you may not be so lucky. First of all, my document was written in LaTeX---a plaintext format---which made it easy for me to identify the beginning and end of my document.

Also, my disk is only about 10% full, which means the operating system has no need to fragment files. As a result, my file appeared as a single, contiguous run in foo. On a more crowded disk, the OS will break the file up into blocks and stores them wherever; in that case, one would have to search for each of the blocks and re-assemble them into the original.

Anyway, I got my file back, and I hope you do too.

Oh yeah, recovering the file took about 2 hours. I probably should have just re-written it.

UPDATE: A friend tells me that this utility can undelete removed file on an ext3 filesystem.

30 June 2008

flickr hack: how to remove the newfangled flash uploader using adblock

When you upload photos to flickr through there web interface, it will try to use their fancy flash file uploader. Personally, I prefer the "basic uploader," which is accessible from a link at the bottom of the uploader page.

Here's a quick hack on how to automatically use the basic uploader using adblock. The trick is this. First, flickr tries to insert the uploader flash object. If javascript on that page determines that it was not loaded, it will fall back to the basic uploader. If you use adblock to block the flash uploader, then you will automatically go to the basic uploader.

So, log in to flickr, go to the upload page, and then block the following url using adblock:


Quick an easy, and hella useful

27 June 2008

An implementation of SHA-1 on the PIC16 F88

Here's an implementation of the SHA-1 message digest algorithm for the PIC16-family of 8-bit microcontrollers. I wrote it as part of a larger project (secret, until a soon-in-the-future date). I have verified it against several testcases of varying length (up to 1,000,000 characters), and it all seems to work well.

The code for this implementation is 520 instruction words, though a careful coder could chop it down by perhaps as much as 64 words. A more pressing issue is that it requires a lot of RAM--120 bytes, across two banks. For those unfamiliar with these microcontrollers, I give perspective by saing that the PIC16F88--a relatively big PIC16--has 368 bytes of RAM total.

When using the byte-oriented API, simulation shows that an average of 685 instructions cycles are required for each message byte, or reciprocally, about 7KB/sec throughput.

So, please enjoy the source code. It works fine with gpasm and gpsim, though I haven't tried it with the windows-only tools provided by microchip.

Gripe: Abusive rental agreements

Daya and I have recently been considering buying a house. Our logic has been that flipping a house in five years is favorable to renting. In actuality, the equity built over five years in this market is quite small, and (at least for us) renting would save us money. Oh well, I'm disappointed, but I'll get over it.

Having decided not to buy, we instead signed a lease. The last clause of this lease includes this very questionable clause (the bracketed words are my addition, for suspense):

17. The relationship of the [tenant] and the [landlord] shall be that of a guest and an innkeeper, respectively, and nothing herein shall be construed to give the [tenant] any additional rights including, but not limited to, those of a tenant under a residential lease. These parties specifically agree that this agreement does not establish a landlord/tenant relationship and is not governed by NJSA 2A18-61.1 [sic] or NJSA 2A:18-53, commonly known as the New Jersey eviction statute.

So who would write such a dastardly, evil clause into their leases? Princeton University. In the original, "[tenant]" was written as "student", and "[landlord]" was written as "university."

Despite this, the rental market in Princeton, NJ still somehow made this lease favorable; the graduate housing that Princeton will provide is at perhaps half the market rate. We signed. So what did we give up?

NJSA 2A:18-61.1 and NJSA 2A:18-53 limit the circumstances under which a tenant may be legally evicted. The limits laid out in law are mostly reasonable: one can be evicted if they fail to pay rent, if they are a terrorist (I'm not joking), etc. It also allows for the eviction of tenants convicted of drug crimes (questionable...), or if you refuse to pay an increased rent (very questionable...). Because my relationship to Princeton will be that of a guest and their inn, they can evict me not just for being a terrorist, but for whatever reason they wish at any time.

I understand that Princeton basically wants the right to evict me if I drop out of grad school, but still, this is wrong. I am so sick of being shat on by landlords.

17 June 2008

Hacking Firefox 3.0 -- Removing unused menu items

A co-worker convinced me to download Firefox 3.0 for Firefox download day, and I took the bait. So far, Firefox 3.0 seems really, really fast, but I haven't been using it for days yet. I'm going to try to be the first guy to release a cool hack for Firefox 3.0. Please play along here.

When I use Firefox, I've noticed that there are perhaps a dozen menu items that I never use. For instance, I never try to open a new window (instead, I use tabs); I never use any of the send link/page/image to variants, since I use gmail and haven't ever set up a email client within firefox. I never use the Work Offline button (I don't really know what it means).

Same thing with the right-click context menus. I don't right click a page to stop loading, instead I hit escape. I never copy image contents, set desktop background (in fact, my window manager is set up so that my background is a terminal window).

Most importantly of all, I never never never mean to hit the File -> Quit menu item; most likely I mean to hit File -> Close Window, which is inconveniently located in the middle of the menu. In terms of keystrokes, ALT-F down down down is much farther away than ALT-F up.

So, If I never use these menu items, why do I have to filter through them every time I use my web browser?

Well, now I don't, and the screenshot at left demonstrates the newer, smoother, less-crufty layout. Here's how you do it yourself:

It turns out that all of the user interface widgets in firefox are defined in a series of XUL files. By modifying these files, we can make our menu layouts match our personal use cases.

A moment of caution, however. XUL files are XML documents, and they are tightly coupled with other parts of the software. Who know how many calls times firefox calls document.getElementById() and doesn't check the return value. Don't risk it. Instead of removing items from this file, or even commenting them out, we're going to set the XUL hidden="true" attribute for undesirable menu items. Similarly, if you are moving elements, you may want to preserve the parent-child structure of the document, or you may break some XPath query hidden in firefox' gut.

It should also go without saying that you should backup every file you modify. Having said that, I'm not responsible for you.

Find your firefox installation directory. On my computer, this is /usr/local/bin/firefox; on windows, I would guess it's in C:\Program\ Files. Within this directory, you will find a subdirectory called chrome/, which contains a series of .jar files. Our target is browser.jar.

Copy browser.jar to browser.jar-old right now, before you forget. Oh yeah, close firefox.

Now copy browser.jar to a temporary directory, and unzip it with whatever tool you use. If you have trouble with this step, rename it to browser.zip, and unzip that.

You should see a directory called content/browser/, and in this directory, a series of .xul files. We are interested in content/browser/browser.xul. Open it up with vi, and look at it until you understand how it works.

For our purposes, you only need to understand the meaning of a new elements.

  • < popupmenuset > - here, popup refers to popup menu. The main popup set is the main menu bar used in firefox, and it contains the File, Edit, View, etc menus.
  • < menupopup > - this can refer to a popup menu (such as the File Menu) or to a context menu (like when you right-click on the page).
  • < menuitem > - this refers to a menu entry, such as Open under the File Menu.
So, to remove an unwanted menu item, first find the offending item, and then add the attribute hidden="true".

And to re-order misplaced menu items, re-order the elements.

When you are done yicking with the innards, re-zip the entire directory tree into an archive called browser.jar, and put it where you found the original. Start firefox, and see how you did.

If you get weird behavior, re-examine your modifications or revert to the original file. Lather, rinse, repeat. Enjoy.

And while we're on the topic, let me throw-in a few about:config tweaks that I find completely necessary for Firefox 3. I got most of these from LifeHacker.
  • dom.disable_window_open_feature.menubar, dom.disable_window_move_resize, dom.disable_window_move_resize, dom.disable_window_move_resize, dom.disable_window_move_resize, dom.disable_window_open_feature.titlebar, dom.disable_window_open_feature.titlebar must all be set to false to avoid annoying behavior;
  • browser.tabs.closeButtons = 2, to put the close tab button on the right, not on each tab (like firefox 1.5);
  • browser.backspace_action = 0, so that backspace is equivalent to the Back button;
  • browser.chrome.toolbar_tips = false, to hide tool-tips; and,
  • browser.tabs.tabMinWidth = 75, so it will show more tabs before scrolling them.

27 April 2008

Lesson in humility: failed headset crown race press

Part of doing-it-yourself is failing to do it yourself. It's not a bad thing unless you refuse to learn from it. Up until now, I had made it a point to only post my successfuly hacks/tweaks/mods/etc to this blog. However, today's post is abouta well-planned diy tool that didn't work. Let's try to learn something from it.

While doing my annual bike tune-up, I realized that part of my headset was installed incorrectly. I designed and built this tool in an attempt to fix that.

First, a bit of terminology.

A press is simply a tool that works by pressing things together, in contrast to a jack which pushes things apart. There are lots of kinds of presses: simple ones use a screw, complicated ones use pneumatic or hydraulic pressure.

A bearing is a mechanical component that acts to reduce the friction between two parts which move relative to one another. A ball bearing is a bearing which uses balls to accomplish this (though many other types exist: the brass bushings on cantilever brakes are an example of non-ball bearings).

And now some bike terminology.

The fork is the fork-shaped piece of a bike which straddles the front wheel (n.b. the things on the back are called the stays, and are NOT a fork). The steer tube is the tube which extends up from the fork to the stem, which connects to the handlebars. The fork crown connects the steer tube to the two tines of the fork.

The headset is a pair of bearings which connect the fork to the rest of the frame, allowing you to steer without much friction. Those two bearings in the headset are cup-and-cone style bearings. These types of bearings are popular in older bikes, but are being gradually replaced with cartridge bearings. This is unfortunate, since cup-and-cone bearings can be adjusted for a prolonged life, while cartridge bearings must eventually be thrown out and replaced. Nonetheless, because the main force on headset bearings are thrust forces (parallel to the axis of rotation), and because of the size of the bearings, cup-and-cone style bearings remain the standard for headsets.

A cup-and-cone bearing consists of three pieces: two races, and a set of balls. Sometimes, those balls are held in a ring formation by an unnecessary, though helpful piece of metal or plastic called the retainer. One of the two races is concave (the cup), and the other is convex (the cone). The fork crown race is the cone which is seated on the steer tube just above the crown, on what is called the crown race seat.

The crown race is press-fit onto the crown race seat, which is to say that the crown race seat is slightly larger in diameter (1.185") than the internal diameter of the crown race (1.180"). This minor difference in diameter (only 0.005 inches) is enough to make it hard to install, though once installed, it may as well be a piece of the steer tube.

So, as I was stripping my bike down for its annual paint job, I noticed that the crown race was incorrectly seated, and I decided to remedy it. It only took a few seconds for me to decide that I wouldn't be able to press it on by hand, and so I went forth building a tool.

[3/8] DIY Headset Crown-race press :: Second attempt :: All the piecesI tried two variations on the same design. The first attempt failed: as I tightened the drive bolt, it worked well until the steel bar bent, and then the plastic snapped, and ultem shrapnel ricocheted off of my luckily-closed eyelids. Although a failure, it worked for a while; the race was halfway pressed onto the race seat. I was encouraged to try again, using a heavier construction that hopefully wouldn't snap, crackle and pop.

I have annotated the picture on the left.

[1/8] DIY Headset Crown-race press :: Second attempt :: The race guideI used my lathe to turn a piece a ultem plastic (a metal replacement, similar to delrin) into a race guide. The race guide had a 1.125" hole bored through the center of it, so it could slide along the length of the steer tube, and had a larger recess bored at one end of that hole to snugly fit the crown race.

[4/8] DIY Headset Crown-race press :: Second attempt :: The set-upI then drilled and tapped two holes on either end of the race guide, and used bolts to fasten the race guide to a bar of steel placed between the two tines of the fork. A third bolt--the drive bolt--past through the center of that steel bar against an ultem plunger, which pressed against the other side of the fork.

Again, I have annotated the picture on the left.

[5/8] DIY Headset Crown-race press :: Second attempt :: PressingI wrapped some fabric around the new paint on the fork, and began torquing the drive bolt. Just like the first time, it began working. In fact, this second attempt put the race close to the right position.

But alas, it too failed.

[8/8] DIY Headset Crown-race press :: Second attempt :: DecapitationThe failure was very similar to the first time. First, the steel bars bent. And again, since it seemed so close to being complete, I chanced tightening even further. Unlike my first attempt, however, the plastic never broke. Instead, the press tore the head off of one of the hanger bolts.

Disheartened, I decided I would need to try a different technique. But what? I couldn't easily make this design larger, since I was already working with the largest plastic stock I had available. I read and re-read Sheldon Brown's advice, until it came to me.

Duh! I have a lathe.

I chucked the crown race, and took a few (i.e. added) a few thousandths to the race's internal diameter. The race still had to be pressed onto its seat, but I could do that under hand power using the race guide I had already built.

So, as I mentioned earlier, there is a lesson hiding in here somewhere. I'll try to be thorough it down, but please let me know if I elide anything:

Lesson 1: Keep it simple, stupid (KISS). This is the prime directive of engineering. By elaborating the design, I added too many points of potential failure.

Lesson 2: Determine which problem constraints are true constraints, and which are only constraints in name / by convention. The crown race should be tight on the crown race seat so that the steer tube doesn't rattle within the bearing. But does it need to be press fit? There will be no motion between crown race and steer tube, so long as the bearings are doing their job. By increasing the internal diameter, I allowed easier installation, but without sacrificing holding power.

Lesson 3: Wear eye protection.

Spring bike maintenance

Spring is finally here, even in the frigid New York City, and time has come for my annual bike tune-up. Sure, I could take it to a bike shop, but then I'd miss out on all the greasy hands, the hundreds of little cuts on my hands, the OCD adjustments that a bike offers, and the feeling of triumph of riding the optimized bike.

Now, I admit that my hand was forced into doing a tune-up. Work has kept me busy enough that I just put off the repairs, one weekend after another. It was a mechanical failure that got my focused.

Daya, Chris and I were at Ben's surprise birthday party at a brewery on the ground floor of the Empire State Building. Eventually, we got sick of paying $7 / pint, and decided to go back to Brooklyn. Our destination was a bar called "Alligator Lounge," serving $5 drafts and a free pizza with every drink (no, really). We set up a race: Daya and Chris took the subway, I rode my bike.

I took 5th Ave down to Union Square Park, and got onto Broadway. I kept flying south until I hit Grand St, realized I went too far, and backtracked to Kenmare. I took the Williamsburg Bridge, landed in ... Williamsburg, and then started looking for the bar. People on the streets tried to give helpful directions, but each pointed me in the wrong direction. Finally, when the alligator lounge was in sight, I started pedaling from a read light, and then ...

My chain fell off.

This is rare, but not unheard of. I have my bike rigged with only 1 chainring up front, and no front deraileur. Thus, as the rear deraileur shifts from side to side, there is a slight chance (say, once in 200 miles) that my chain will fall off.

But not this time.

Sugino Chainring FailureAs I started to put my chain back on, I noticed that my chainring had inexplicably bent itself beyond repair. My bike could be pushed, but not ridden, and I was still miles from home. Knowing that I had lost the race, but that I should have won, I pushed my bike the last few blocks. Daya and Chris were there, smug with their victory. This was the first time I had lost a Subway-versus-bicycle race, and I was not happy.

But I digress; this post is about my spring bike tune-up.

I replaced my broken 48T chainring with a new 53T chainring. This has upped my ratio significantly, but still in my comfort zone. I also replaced the chain, and put on a new 8-speed 11-28 cassette (same as before). I put on new brake shoes, bought new cycling shoes and installed new cleats.

But that's the less interesting part of the tune-up. I also did some work on my headset, and I repainted. Each of those is a big enough task to warrant their own posts. So, those posts come next over the next few hours. Stay tuned.

26 April 2008

Shout-out to Dennis Ferron

Dennis recently linked to me from his blog, and I wanted to say thanks, and to point out a particularly cool post. Ferron's Guaranteed No Mess No Mixups Method for Swapping Rims without Relacing is something that I wished I had happened upon years ago.

The problem: you have a new rim, and you want to build a wheel. This task is typically a pain, though some people enjoy doing it.

The special circumstance: you already have an old wheel built.

The critical observation: in addition to re-using the spokes and hub from the old wheel, you can preserve the information stored in the old wheel's lacing.

The method: put the two wheels side by side. Transfer one spoke at a time from the old wheel to the new (in careful order), and you save your self a lot of hassel.

Well done Dennis.

11 April 2008

One liner updates

I have accepted Princeton's offer. In September, I will be a graduate student at the Computer Science Department at Princeton University.

The weather has been beautiful recently.

Work is going well. I work at a rate of one todo list page per day. There, I have observed quite a bit about ruby on rails, and I think I'll have to post about that soon.

My mother is coming to visit soon.

Although I had a minor in math, I still think that taxes are confusing. The astute reader will note that math is not arithmetic.

I just went through a week of infirmity... Something gastrointestinal. I'm happy to report that has passed.

I've been playing with my lathe a lot. I built a crank puller, as I said I would. Now I just need to convince myself to stop making minor changes to it, and to move on to a new project.

My apartment has a mouse. I'm trying really hard to kill it, but it is apparently smart enough to take the cheese off of the traps without dying. Bastard!

30 March 2008

Single-serving tools

Every so often, you find yourself in need of a unique tool to fit the situation. Most of the time, such a tool can be bought. Though, because of their limited need, stores must sell these for a higher price to average out the lesser demand. Compounding this fact, no one wants to pay a lot for a tool they'll only use once.

I've collected a list of all the one-time, single-serving tools from recent memory. If you have similar single-serving tools, I'd like to see them.

Improvised Headset Press(1) An improvised headset press.

I needed to install the bearing cups to a 1-1/8" threadless headset on the bicycle I was building. But, I was only going to do this one time, so I didn't feel like buying a tool, even if it only cost $20.

My solution was this. A 1/2" screw is used to push two soft plastic plates together. These, in turn, push the cups into the headset. The plates were made out of some plastic from an old cutting board.

For best results, stick the cups in the freezer for half an hour--they will contract slightly and fit more easily.

Have you ever needed a really long allen wrench? [1/2](2) An exceptionally long allen wrench.

Have you ever needed a really long allen wrench? Well, I did when I was constructing the drawer set for my new lathe. Local hardware stores didn't sell allen wrenches this long--at least not in metric--so I built my own.

Take a normal allen wrench and hacksaw-off the bend. It's hardened steel, so it will mess up your blade--use a worn-out blade. Take a length of 3/8 round steel, bore a 1/4" hole at one end, at least 1/2" deep. Insert the hex bit, and then weld it on to the rod.

Have you ever needed a really long allen wrench? [2/2]Also, bend the far end of the rod, or weld on some sort of handle. I used my lathe to turn the rod down a bit, making it easier to bend.

Ultimately, this 5mm wrench will reach more than nine inches deep into a 1/2" hole.

Need a way to measure angles?(3) An easy way to measure angles.

When I moved into my apartment, I immediately devised a plan to build an long shelf above head level in the hallway. Because this apartment had been sliced off of a single family residence, it had an awkward hallway in the wrong place. The hallway space seems like a significant fraction of my apartment, and without the shelf it would all be lost.

The problem was that the walls in this hallway didn't meet at right angles. It's very ad-hoc, with three turns at angles around 13-31 degrees. I needed to measure these angles or the wood wouldn't meet right.

Sure, protractors are cheap, but one wasn't available when I had my inspiration.

I built this out of some 1" extruded aluminum angle-stock and a small machine screw, nut an washers. The trick? A hole is drilled on each bar, 3.5" from the pivot point. For any angle, the two holes and the pivot point make an isosceles triangle. Then, if I measure the distance "h" between those two holes, I can calculate the angle between those bars as 2 * sin ( h / 7 ).

The shelves, by the way, look great and line up perfectly.

So, anyone else have single-serving tools to share?

25 March 2008

My minilathe, and several mods thereof

It's been a while. There are various excuses for that, but the main excuse is that I've been putting in long days at my new job.

Lathe has arrivedThe big news (on the diy/hacking/modding front) is the arrival of my minilathe. I had been dreaming about owning a minilathe for a long time. I had always been frustrated by the cost and accessibility of various machine parts; to me, it's torture when you have a great idea and no way to build it. I looked forward to all of the rights and responsibilities given to lathe owners.

This lathe is just one brand of a common chinese lathe, sold by Cummins, Harbor Freight, Grizzly, and others.
One benefit of this oft rebranded tool is that many online communities have sprung up about how to use or modify it, for example the right-wing 7x10 minilathe group. However, the Cummins model is in a class by itself. It is simultaneously the cheapest, and shipped with the most accessories, including a faceplate, a 3-jaw chuck with both internal and external jaws, 5 HSS tool bits, a tailstock chuck, a dead center, a set of change gears, a steady rest and a follower rest. It is a great value.

Let me first say that, despite the limitations inherent to small lathe, this lathe is quality. Every moving part has a gib or some other way to adjust it. Although each part may slowly wear out, the designers have provided the end user with a way to compensate.

Let's compare it to the famous Sherline Mini-lathes. Among hobby machinists, Sherlines have a good reputation for quality, and are comparable to my Cummins in size. However, Sherlines do not include change gears and a feed screw -- necessities for cutting internal / external threads -- nor do they include a compound slide, thus one cannot cut bevels. Oh yeah, Sherlines cost more too.

Lathe has arrivedEnough about comparisons, on to the juicy stuff. I unpacked the lathe. The first thing you need to do with a machine like this is take it apart. I took it down to it's solid pieces, cleaned off the factory grease, re-greased. re-assembled and adjusted it. These preliminaries are critical, since they give you a good understanding of how the machine all works, and yield a certain confidence toward using or modifying the machine.

Lathe Mod #1So, what modifications have I done? First the simple shit: I removed and recycled the two chip guards. Then, I removed the plastic do-hickey covering the emergency stop button. Perhaps I'm misunderstanding it, but it seems much safer to have a clear path between my left hand and the stop button. Additionally, I replaced the bolts that secured the hand wheels, since they tended to hit my knucles.

Lathe Mod #2aNext, I grabbed some strong magnets pulled from a scrap hard drive, and used them to keep track of the various chucks. I find that the use of a magnet is just slightly entertaining, perhaps only on the subconscious level, but that is enough that I never forget to replace the key. I don't imagine I'll ever accidentally leave it in the chuck.

Lathe Mod #3I don't own a grinder with which I can grind my tool bits, but I can put a small arbor-mounted grinding wheel in my lathe. The beauty of this is that I can use my lathe's compound slide to get a precise angle onto the tool bits. Similarly, I realized that I can use fragments of hackway blades to shim-up the cutting tool.

Lathe Mod #5My lathe came with a lot of accessories, and suddenly I had nowhere to keep them all, let alone work. So, I went to work building a drawer set. I collected a bunch of scrap wood and plastic from around the neighborhood (and trash day in Brooklyn contains enough wood to build a few houses, I'm sure). The drawer set is sturdy as hell. I added in a few solid brass drawer pulls that I found at the Park Slope Flea Market to finish the effect. So much of this sort of improvised building involves moments of inspiration. This simple allen wrench holder is one such example.

Most recently, I built a apron chip guard, inspired by the one that Varmint Al made. One failing of the minilathe design is that it leaves the gears behind the apron exposed, and poised to collect metal chips from the cutting action. As Jobst Brandt once said, "Commercial abrasive grinding paste is made of oil and silicon dioxide," and so I was concerned about these chips, even though the gears were otherwise greased. So, here is how I built it:

Lathe mob #7 [1/6]Cut a sheet of 1/8"-thick pastic to the rough contours of the lathe's apron. I used some plastic that used to be part of a printer's enclosure. Drill a hole large enough for the gear's shaft (I cut mine 7/8" since I had that bit available, though smaller would do). Drill and countersink five holes around the perimiter of the chip guard.

Lathe mob #7 [2/6]Transfer those holes from the plastic chip guard onto the back side of the apron using a center punch. Drill and tap those holes. I used a #36 drill, and a 6-32 tap, though anything of similar size will work. The apron is made of cast iron, which is a surpisingly soft metal. Nonetheless, proceed with caution so you don't break your tap, and use lot's of wd40.

Lathe mob #7 [3/6]This is a view of the back side of the apron after the five holes have been drilled and tapped.

Lathe mob #7 [4/6]Clean out all metal chips from the area, and re-install the gears.

Lathe mob #7 [5/6]Drench the gears in a heavy grease. I used an old hacksaw blade as a spatula to really muck it into the nooks and crannies.

Lathe mob #7 [6/6]Install the chip guard. It is secured down by five 6-32 machine screws. Re-install the apron onto the lathe, and rejoice in your apron's newfound ability to repel chips!

07 March 2008

Multi-color lamp from (some) reused materials

I've seen this style of fabric-draped, muted-light lamp all over new york recently. I decided to build my own, and make it glow funny colors.

Lamp schematicThe schematic is really simple; I wanted to keep it that way. A PIC16 is used to create three PWM signals. Those three signals feed into three NPN transistors to drive a stack of colored LEDs. I proper design would use resistors both at the base and the emitter, but I was lazy last night.

Also, this thing has source code.

Lamp Board - Obverse
Tryin' to keep it simple. I put it on some perf board, and wire wrapped it. I tried to space the LEDs evenly on both sides of the board. The obverse:

Lamp Board - ReverseAnd the reverse.

Lamp wire-frame
Then, I made a frame out of two coat hangers. I wrapped them with some packaging material from my new job's recent Ikea visit, and sewed it on.

Lamp ShadeIt starts to look a little bit better as more sewing is done.

Finally, it looks like this in the dark:

03 March 2008

Last minute notice: Free class on TIG Welding tomorrow

Christian just told me that 123 Tompkins Community Space (map) is offering a free workshop on TIG welding Tomorrow, 4 March 2008, at noon-o-clock. I don't think I can make it (see note about new job in previous post), but I wish I could. Why?

Well, I say that I know how to weld, by which I mean I can use an oxy-acetaline kit, and I can use a MIG welder. Still, that limits me to steel. TIG welding, on the other hand, can be used to weld a greater variety of metals, such as aluminum, magnesium, copper, and alloys thereof. If you're interesting in bicycle frame building, for instance, this is the kind of welding you want to learn (in addition, of course, to brazing).

Additionally, I'll plug this by reminding everyone that it's free, rare for anything educational in NYC. Show up, enjoy it, and... you know, leave a donation if you have fun.

It's been too long

My appologies for taking a week or so off from the blog. I assure you there is more to come. Here are some of my excuses for slacking on the blog:

I have started a new job, where I work as a Java developer, though so far our work has mostly been assembling Ikea furniture. The office is awesome--on vibrant Franklin Ave in Crown Heights, Brooklyn. I like how every five minutes or so someone stops by to ask "so, what is this place?" Apparently, the office was an abandoned/condemned building for many years, and though people are glad it's no longer rat infested, the neighborhood really wants another restaurant, lounge, or other public space. The job has been keeping me busy, but in a good way.

I've heard from a few Graduate schools. What? I forgot to mention that I applied to a few PhD in CS programs? Yeah, I did.

So far, Princeton has made me a good offer, and CMU and UPenn have rejected me. More schools are pending. At the moment, it looks like I'll be moving to small town Jersey unless Columbia wants me. On a related note: does anyone out there live in Princeton? What do you think of it? Of particular interest to me are cultural events, bike-friendliness, a leftish-leaning populace, and urbanity (ha!).

I purchased this lathe today, and am looking forward to its arrival. As far as metal lathes are concerned, this one is dirt cheap (though still an expensive tool). I plan to fit this into the cheaphack mission by working with scrap materials. I anticipate my first project will be a crank puller, followed by fancy brass crank bolts and top bolts, working my way into Stirling engines. Don't worry, you will be posted.

I have two projects on the way: a stylish lamp made from recycled materials, and a bicycle generator built with an old air conditioner. Stay tuned for more absolutely cheap diy technology.

22 February 2008

More on the Mystery CCD

Yesterday I posted about a mystery CCD that I found in a flatbed scanner. It has no part number on it; all I knew was that it has 22-pins. I was hoping that it was like an LCD module---multiple vendors but a single footprint. Sadly, this is not the case.

Proof by counterexample: Toshiba produces at least two 22-DIP CCDs with incompatible footprints: the TCD1707D and the TCD2905D. From my analysis below, I now know that this CCD is neither of those.

I pulled out the continuity tested and started tracing connections. Here's what I've found:

  1. GND
  2. GND
  3. buffered input 1
  4. GND
  5. buffered output 1
  6. +12V
  7. GND
  8. buffered input 2
  9. buffered input 2 (8 and 9 are the same)
  10. GND
  11. GND
  12. GND
  13. odd, see below
  14. buffered input 3
  15. +12V
  16. GND
  17. buffered output 2
  18. buffered output 3
  19. GND
  20. buffered input 4
  21. GND
  22. GND
By "buffered input," I mean that the pin is driven by a 74HC04 inverted, through a resistor. By "buffered output," I mean that the pin is fed into a simple transistor inverter. By "odd", I mean that two '04 inverters are put in series and drive themselves through a capacitor. The output also drives this pin through a resistor.

Since this device has three outputs, I infer this is a color CCD. I suppose I could have read the packaging on the scanner, but I threw it out before I thought to check.

21 February 2008

Photos from last night's full lunar eclipse

Here are some photos of last night's full lunar eclipse.

Lunar Eclipse 2008, circa 9pm
c. 9pm

Lunar Eclipse 2008, circa 10pm
c. 10pm

Lunar eclipse 2008, circa 11pm
c. 11pm