Friday, January 11, 2008

multiurl

like tinyurl but with multiple pages. Pop page with previews, ask users if they want to open all, one, some, or play slideshow-style in frame?

Perhaps a bookmarklet interface, along the standard HTML paste-in-urls.

Edit: Already exists, ManyURL, works nice from what I see. Could use a bit more, though! Too simple, not complicated enough.

Friday, December 14, 2007

When you're serving static files...

Never link http://yoursite.com/foo/bar/x to:

A) plain http://static.yoursite.com/foo_bar_x.ext

B) Never use plain hashes of the ID. e.g. .../hash_of_id_here.ext

C) Borderline, but even static salts are bad: .../hash_of_id_plus_'foobar'_here.ext

Basic is, use a variable salt for every item. It can ever be public info, like the title, creation time, or anything that varies sufficiently per-item. That's the beauty of salts.

Or, alternatively, as better people than I have mentioned, use bcrypt with a set difficulty value, and all your rainbow table type fears go away.

Thursday, October 18, 2007

Emacs...

Biggest reason to switch to emacs I've found so far is that the commands work by default in bash, too.

Friday, September 7, 2007

Code on the Road: Navigating The Minefield that is Visual Source Safe

Code on the Road: Navigating The Minefield that is Visual Source Safe

Such a no-brainer. Why do you even try VSS to begin with? Get the Subversion plugin, grab SVN, and 99% of these things go away.

If that's not enough, git, darcs, bzr, and mercurial provide reasonable distributed solutions. Miles ahead of VSS (Actually, three generations, but who's counting.)

Seems to me, if you're really running an 'ex-pat' office, you'd want distributed. That way you can all trade changes around without having to fight conflicts. Best part is, you can stage to production without branch/tag.

Basically, there's no excuse these days for using an old VCS. Or, dare I say, a Microsoft VCS.

Thursday, September 6, 2007

On convergent evolution, and the invocation of holy wars.

Python and Ruby are the same thing.

There, with that out of the way, let me explain myself.

I was looking at a post about scene carving image retargeting which thoughtfully includes a link to his python implementation of scene carving all nicely packaged into git.

So I grabbed it, used emacs to import it into a new file, and started converting it to Ruby, since that's the language which is hitting my happy button right now (Haskell is for when I want to hurt myself). (NB said conversion I plan to post here, or at least, link to SVN for it.)

Take a look at an excerpt:


class CostMatrix(ndarray):
def calculate(self, energy_map):
if not energy_map.shape == self.shape:
raise Exception, "Wrong shape"
(h, w) = self.shape
self[0] = energy_map[0].copy()
self[0] = self[0]
for y in range(1, h):
for x in range(0, w):
bestcost = inf
bestx = x
for dx in range(x - 1, x + 2):
if dx >= 0 and dx < w:
if self[y - 1, dx] < bestcost:
bestcost = self[y - 1, dx]
bestx = dx
self[y, x] = self[y - 1, bestx] + energy_map[y, x]
self._calculated = True

def _get_max_index(self, row, startcol = 0):
maxx = startcol
maxval = self[row, maxx]

for x in range(0, len(self[row])):
if self[row, x] > maxval:
maxx = x
maxval = self[row, x]

return maxx

def find_shortest_path(self):
(h, w) = self.shape

x = self._get_max_index(-1)
path = [x]
for y in range(h - 2, -1, -1):
bestcost = inf
for dx in range(x - 1, x + 2):
if dx >= 0 and dx < w:
if self[y, dx] < bestcost:
bestcost = self[y, dx]
x = dx
path.append(x)

path.reverse()
return path


def get_image(self):
scaling = 0.03
(h, w) = self.shape
im = Image.new("L", (w, h))
im.putdata(self.flatten() * scaling)
return im


Now, if you're a python person, that should be fine. But what if you're a ruby person? That looks like ruby, where someone added in a lot of colons, and didn't remember their end tags. Oh, and someone's using paretheses oddly.

So, having converted those things, I'm confronted with a syntactically valid chunk of ruby code. It no longer throws parse errors.

This is pretty mindblowing, to me. Maybe it's something that's long since been obvious to the old hands...

Anyway, this makes me wonder why Python and Ruby aren't implemented on the same core compiler/interpreter. I know Microsoft is doing something akin to this with their Dynamic Language Runtime, but why aren't the Ruby people stealing like mad from the Python people, and vice versa?

That said, this, to me, is only the midway step between Python and Haskell. Ruby will probably take a week to do anything fun with it, so, much as I might like to throw up a free image resizing service, I'm thinking I'd rather do it in HAppS, where at least it will be fast.

Any thoughts? Am I an idiot for not seeing this already?

PS there's also another implementation of scene carving based resizing that I've been looking at.

Tuesday, August 28, 2007

Lunar Eclipse

Total Eclipse
Total Eclipse

Taken last night. If I had a better camera, I'd have taken Mars during the eclipse too.

Friday, August 10, 2007

Eliciting rational thought on the internet

Ok, this is very much a work in progress at the moment, I'd appreciate feedback a lot.

I'd like to take some time today to write about the way I interact on the internet. I'm doing this partly as a way of clarifying to myself the goals that I'm pursuing. Another part is, when people accuse me of being deliberately obtuse, argumentative, or 'debating unfairly', I can point them here, as not a means of excusing myself, but rather a means of explaining the reasons. Finally, I think the world would be a better place if people examined the way they interact with others more often, so I'd like to be less of a hypocrite by spending some time in the pursuit of that goal.

Firstly, let me lay out my goals:


Learning.

This is always high on the list. Everyone teaches you things.

Teaching others.

Again, I'm not sure this is as noble as all that, given that most people don't like to be taught a lesson even if it's good for them.

Developing communication skills.

This is something that I, as with, I think, most technical people, have problems with.

Getting others to think before they comment.

I'd like to see more people think to themselves 'No, that's silly, I shouldn't say that' or 'Hmm, is that really true?' before they spout off about the topic du jour.


So in pursuit of these, I do a few 'not so nice' things, though I believe, as is the call of petty tyrants throughout the ages, 'the ends justify the means'.

Feigned ignorance.

This is probably my favorite thing to do. Most people, in the course of explaining what 'everybody knows' will end up realizing that they don't have a firm grasp on the topic at hand. I end up doing more research myself this way...

Questioning of basis.

I've been accused of being a dirty debater for asking people a pretty simple question: "Why do you think that? Do you have any evidence or proof?" People come up with the most marvelous sources when you ask them this, especially when they're experts in the field.

Employing logical fallacies.

This is almost a test: Do you recognize when someone is using these? I wrote about one that always bothers me in Sunk Cost: Fallacy and Dilemma, but there are many more. People don't seem to realize that this is one of the key tools of a demagogue. Immunizing people against them should be one of the key tasks of education, but I'm fairly sure my school didn't even mention them once.

Playing Devil's Advocate.

This is the classic trick of the troll. Take a deliberately extreme position, and defend it well. In doing so, you're far more likely to solidify people's current beliefs than change minds. In a lively debate, often both sides come away better educated, perhaps having gained a modicum of respect for their opponents.

(This is one of the key problems with politics now: nobody can put themselves in the other person's shoes, everything is a life or death issue)


Anyway, I've got to sleep now, but there it is: When I talk to people on the internet, it's often with goals in mind.

Tuesday, August 7, 2007

From a friend's recommendation letter...

New post on this subject: How to write a letter of recommendation






I was helping a friend write a recommendation letter and came across these gems:

- "Self Goal Oriented"

- "Most plausible vehicle for my goals"

- "Practice my compassion"

Yep, lessons in what to avoid when talking to literate people.

Also, I'm still alive out here and plan to have another post up with real content soon.