HNHacker News
TopNewBestAskShowJobs

Locke

764 karma · joined March 28, 2007

[ my public key: https://keybase.io/ericidema; my proof: https://keybase.io/ericidema/sigs/lXdL8-79O5kKnqKbs5KrqgjqCSqnOm8p_I3S7M_hxo8 ]
submissionscomments
Locke··on Nethax: An AJAX implementation of Nethack
In what way? I've heard that a couple times, but it's worked fine for me in chrome so I'm not sure what I'm looking for...
Locke··on Nethax: An AJAX implementation of Nethack
Nice. I've been lurking quite a bit on rec.games.roguelike.development lately. I'm surprised more roguelike developers haven't started targetting javascript / web browsers. Still a lot of C / C++ and curses.

So, anyway, I've always wanted to make a roguelike so a couple weeks ago I started this:

http://eki.github.com/jquery.roguelike/

I really need to refactor and start documenting the code soon, but I'm trying to get the basic game play done first. Right now the dungeon is 5 randomly generated floors that can be navigated with the arrow keys (or wasd), but no enemies yet.

(Oh, and the canvas stuff won't work in IE)

Locke··on An easy way to use GNU Screen over SSH
Indeed, it is really basic. I guess I could see value in aliasing that to save typing. In my case, I have a "Screen" menu in fvwm with menu entries like this:

    + %terminal.png%"caspian" Exec exec xterm -geometry 80x25+30-28 -T "screen : caspian" -e ssh -t eki@caspian.vying.org screen -x -R
I have menus for local screens as well, with entries like:

    + %terminal.png%"dorothy" Exec exec xterm -geometry 80x37+30+60 -T "screen : dorothy" -e screen -x -c $HOME/.screenrc-dorothy -R dorothy
I usually create a new screen config for each project that launches shells in the right directories, etc. For example, here's my .screenrc-dorothy:

    chdir $HOME/projects/dorothy/lib/dorothy
    screen -t lib           1 zsh

    chdir $HOME/projects/dorothy/test/dorothy
    screen -t test          2 zsh

    chdir $HOME/projects/dorothy/ext
    screen -t ext           3 zsh

    chdir $HOME/projects/dorothy
    screen -t irb           4 zsh
    at        irb#            eval 'stuff "irb -r dorothy\015"'

    chdir $HOME/projects/dorothy
    screen -t zsh           0 zsh

    hardstatus alwayslastline "%{rk}%H %{gk}%c %{yk}%M%d %{wk}%?%-Lw%?%{bw}%n*%f %t%?(%u)%?%{wk}%?%+Lw%?"
That gives me shells in the directories I'm likely to be working from, and starts an irb session in another shell.

I guess this is only newsworthy if you're not the type to customize your environment to your liking. Well, that and the fact that gnu screen is somewhat difficult to learn and researching it is a pain because "screen" is such a poor, generic name for a project.

I'd love to see this turn into a thread of neat things that can be done with gnu screen.

Locke··on Ask HN: Do you have any code or projects of your own you would like to talk about instead?
I've been working on my Z-Machine interpreter library again. It basically started as a project to turn Frotz into a Ruby extension (Frotz, probably the most popular interpreter, is written in C).

The code has undergone quite a few transformations now. Frotz uses a lot of static memory -- it's basically setup to run a single zcode program at a time. Which makes sense, of course.

For my library, I wanted to be able to run more than one program (or multiple copies of the same program) at the same time. So, I basically rewrote the core of Frotz. All the memory for a Z-Machine is broken up into structs which are passed around.

There were some fun memory management issues related to running multiple programs. The typical zcode program consists mostly of static memory (lots and lots of strings and code), so that static memory can be shared between programs. I have a test where I load something like 100,000 copies of minizork into memory and the process size "only" jumps to 118MB. Of course, normal code doesn't need that many simultaneous Z-Machine instances so garbage collection keeps memory pretty reasonable.

Last time I worked on dorothy, I setup a demo webapp here:

http://ifrotz.org

Which illustrates why I wanted to be able to run multiple programs. The demo runs minizork, dynamic memory is dumped and restored between requests. The hints, exits, and history feature is possible because the server "listens in" on your game and the games others have played.

Lately I've been working on more memory inspection stuff, and now I have to work on some of the unfinished Z-Machine features (I've only implemented the v3 screen model).

The code is on Github:

http://github.com/eki/dorothy/tree/master

Locke··on I'm Sick of This
In my own library, I use inject instead of adding Array#sum. But, I know that's sidestepping the issue, not solving it.

Honestly, I'm not sure how Rails uses #sum. I'm not sure whether they really need it or not. I suspect not.

I'm not a big fan of a lot of non-standard additions to Ruby. For example, all the #try, or #returning, or even your #andand. I don't consider any of those to have enough intrinsic value to be worth the risk of collisions with someone else's subtly different implementation.

Locke··on I'm Sick of This
Usually, I think, people write sum with inject:

    [1,2,3].inject { |s,i| s + i }
Which is presumably why sum doesn't exist.
Locke··on I'm Sick of This
I'd almost blame this problem on Ruby not having its own standard Array#sum method (or more likely it should be a method on Enumerable?). I'm guessing a lot of projects add their own, so it's a natural source of conflict.

Secondly, it seems like most conflicts like this occur between Rails and some other library. Rails, via ActiveSupport, adds a lot of extensions to core Ruby. I kind of wish it didn't. Framework or general purpose library developers should recognize that their library will likely be combined with many others and avoid conflicts by sticking to what's available in the standard, namespacing their code, etc.

I like Ruby, but I'll readily admit it's not a perfect language. I'm sure someday a better Ruby-like language will come along. Hopefully, it'll be a language with better support for avoiding these kind of conflicts without removing support for open classes. I'm sure it's an interesting technical challenge.

Locke··on IP Address Geolocation database
Someone on reddit claims it's an exact copy of this:

http://www.maxmind.com/app/geolitecity

I haven't verified that claim.

Locke··on The Most Unusual (and Best) Computer Language Book I've Ever Seen.
Yes, I meant mainly that it doesn't cover Ruby 1.9 or some newer libraries. While the Ruby landscape has changed a little since it came out, The Ruby Way still covers the core language and many still relevant libraries quite well.
Locke··on The Most Unusual (and Best) Computer Language Book I've Ever Seen.
Poignant is fun. That's all.

Probably the best book for really learning Ruby is The Ruby Way by Hal Fulton. Hal clearly gets Ruby.

The book is thorough (although possibly a little out of date now), introduces a lot of idiomatic Ruby, and has just the right amount of geeky inside jokes.

Locke··on Javascript Framework for 2D Game Development - GameJS
Am I reading this right? Are you actually saying ExplorerCanvas (canvas on top of VML) is faster than native canvas in firefox, webkit, etc?

I have some experience with this -- my site uses canvas / ExplorerCanvas quite a lot -- ExplorerCanvas is both buggy and extremely slow for any kind of animation. Particularly long running animation (as in games). I wish it wasn't so.

VML may or may not perform well, but it's a different kind of api than canvas. In VML, like SVG, you're intended to draw a bunch of shapes and then manipulate them. To animate a circle crossing the screen, you draw the circle and the move it every tick. The library manages the redraws, etc.

With canvas, you redraw every frame. So, to animate that circle you draw it in a different position every tick.

If you run canvas on top of VML you end up redrawing a lot of extra elements which get reinserted into the dom at every step.

They're just fundamentally different approaches and the impedance mismatch kills ExplorerCanvas's performance. If this has changed recently, btw, I'd love to hear about it!

Locke··on On Git's lack of respect for immutability and the Best Practices for a DVCS
Here's, I think, the big philosphic difference: Some people only want good code in the repo. Some people want every change in the repo.

I'm in the second camp. I'll gladly commit broken code and then fix it later. I don't push broken code, of course, but sometimes it's useful to have a snapshot of the broken code before you start fixing it.

For example, let's say I'm accepting a patch from someone or I found a useful snipit of code on the internet. I integrate the code and it breaks a unit test in some non-obvious way. I like to commit the code as it was from the original source before I start trying to fix it. That way I can quickly revert if my fix attempt is way off base.

Further, I have in my history who / where the code came from and how it was fixed (in a later commit, complete with an easy to get diff).

I'm not saying Eric's best practice is wrong. Some people prefer to only commit good code, some prefer to commit early and often. I don't think either practice is inherently better than the other.

Edit: I realize I didn't really respond to the immutability issue... I don't really have an opinion on that.

Locke··on When anonymous attackers went after two Yale law students, they struck back
I'm not convinced there was anything illegal about the threatening / abusive postings. I think we need to be careful about protecting our freedom of speech.

However, I'm very happy that those individuals who were identified have faced social repercussions for their behavior. I would not want anything to do with any of those posters. If I were hiring, I wouldn't hire any of them. I would probably boycott any businesses that work with them. If they're free to be jerks, I'm free take my business elsewhere.

Therein lies the more interesting issue. Anonymity. It's hard to exert social pressure on bad behavior if you can't identify the people involved. Do we have a right to be anonymous online? Do the pros outweigh the cons?

I really don't know...

Locke··on Daily Routines: How interesting people organize their day.
The role of mundane activities is interesting: A cup of tea, reading the newspaper, taking a walk, smoking a cigar, etc.

People who have trouble sleeping are, among other things, supposed to establish a routine. Repeating mundane activities (brush teeth, lock doors, turn down thermostat, etc) in the same way every night seems to prime the brain for sleep.

I suspect it doesn't matter what you do before you settle in to work, simply that you establish some "it's time to work now" cues and then take advantage of them.

Locke··on Ma.gnolia.com crashes hard -- no backups?
The best situation for me has been one of my personal projects. It's a gaming site that I use everyday. The database dump is less that 100MB gzipped, so I load it in my development environment every week or so. That way as I develop I'm verifying (to some extent) the quality of the backup.

As a baseline, you should at least restore from your backups occasionally.

It helps that I'm familiar with the data -- so after restoring the backup I expect to see games, messages, forum posts, etc that I've just seen in production.

I do some more thorough automated tests on the backups less frequently. App specific things, like replay games and verify results, etc. This process is more about assuring backward compatibility with the code though.

I think verification should ultimately be somewhat app specific. That said, I'm sure you can find tools to help with verification.

Locke··on Ma.gnolia.com crashes hard -- no backups?
Verifying backups is almost always many times more difficult than setting up the backups themselves. Checking that replication was in fact working turned out to be fairly easy to automate (although, short of checksumming all the records in all the tables you can't really be 100% sure everything is okay).

That's the thing with backups, they can fail or become corrupt in many ways. If you don't use them for something on a regular basis or have some regular verification process you may not know what you have until it's too late.

And, of course, I've also seen situations where subtle data corruption in the master database leads to weeks of subtly corrupt backups. By the time the corruption was discovered we faced the choice of rolling back several weeks to the last good backup or fixing the corruption. In the end we had to do a kind of merge -- it was a real pain.

Locke··on Ma.gnolia.com crashes hard -- no backups?
It's easy to say, "What? No backups... how stupid can you be?" But, without knowing the particulars, I wouldn't necessarily jump to that conclusion. It's very easy to have regular automated backups fail in some way.

Unfortunately, it's not enough just to have backups. You have to actually verify that they're correct and up-to-date. Verification is easy when your database is small (for example). You can just load it in your development environment occasionally. But, how do you verify your backups if you have hundreds of gigs or even terabytes of data?

As an example, I've seen cases where backups were successful every night... but, they were being run against a slave db and replication had failed. The result: Excellent backups of weeks old data.

Locke··on Lua vs Ruby benchmarks (similarly "high-level" languages, insanely different performance)
Which version of Ruby? 1.8 or 1.9? With my own projects Ruby 1.9 performs much better. Lua is well known for being small and fast, so I doubt Ruby 1.9 would beat it... Nevertheless, it'd be a lot more interesting comparison that Lua vs Ruby ???.
Locke··on Tag Clouds of Obama's Inaugural Speech Compared to Bush's
I think it's fascinating how interested people are in quantitative analysis of speeches. How many times did he use the word "I". Which president said "I" the fewest times in an inauguration speech? What's the tag cloud look like.

Obama gave a beautiful speech today -- no doubt the use of language and delivery are a large part of that, but I find the beauty of his speeches is in the ideas.

Too often politicians fall back on flowery, patriotic language that lacks meaning and substance. Obama's speeches seem, to me, full of purpose and direction. They clearly communicate values, priorities, and objectives.

Locke··on When newspapers are gone, what will you miss?
I'll miss the quiet "me time" of reading the newspaper in pyjamas in the morning, or at a restaurant on my lunch break (not in pyjamas).

I'll miss the local sports coverage, box scores, etc. All of this is online, more or less, but it's just not the same.

I'll miss the local news. Our local newspaper plays a valuable role as watchdog. They recently brought down a corrupt mayor, for example. But even the mundane news is useful: road construction, a new restaurant opening, what's playing at the local theatre, etc.

But, I was raised in a home where both my mom and dad read the newspaper everyday. So, I've been reading the newspaper for almost my entire life. Whenever I move, I leave one local newspaper behind and start reading a new one. It gives me a sense of place. A sense of community.

So it's hard for me to imagine a world without newspapers. Sadly, it appears to be inevitable. My local paper recently announced that they'll be cutting home delivery to 3 days per week...

Locke··on JQuery pageSlide
Neat.

It took me a while to figure out how to "undo" the slide. First I tried clicking the link that triggered the slide, then I tried clicking around the side pane itself, then I looked for links that might close the side pane, then I finally clicked the original page and it slid back into focus.

And, that's the unfortunate problem with cool javascript UI enhancements. Unless they win the javascript lotto and become really popular / prevalent, users often don't know know what to do... Which is a shame.

But, nevertheless, nice effect.

Locke··on Slashdotter on the value of ideas versus execution
IIRC, that was a scene in the British version of The Office.
Locke··on Datapocalypso (RE: Eviction, or the Coming Datapocalypse)
It depends on how you define "lose". To keep all your data for a long time takes effort. Storage formats change. Disks die. Hosted storage bills need to be paid, billing needs to be updated (credit cards expire), etc.

You really need more than one copy in more than one place if you want to be really confident that your data won't be lost.

Is all your data worth the effort? Is it healthy to try to hang on to everything?

Locke··on Datapocalypso (RE: Eviction, or the Coming Datapocalypse)
On the other hand, perhaps it's good to allow data to be lost occasionally... I've lost old emails, source code, and other documents that I thought were really important (to me at least). Turns out I was wrong, I don't miss any of it.

It's a shame when people lose stuff for reasons other than neglect, but it happens. Start over or work on something new (and treat it like an opportunity, not a chore).

Locke··on GitCred: PageRank applied to the GitHub users/followers graph, implemented in Clojure.
Interesting list. At a glance I recognize a lot of ruby people near the top which is a pretty good indicator of how popular git / github have been in that circle. Github has really become the code hosting source for ruby developers. I wonder how popular it is for other languages?

Also, looking at this list is looks like the quickest path to the top is to develop open source software for other programmers. Perhaps a javascript library or a web framework or software used by github itself.

Locke··on Rails and Merb Merge
Wow, I almost wish it were April Fools Day...

For someone who loves Merb and had decided to leave Rails behind (as much as possible), I have very mixed feelings about this. If this means Rails will start to feel more like Merb, fantastic! Otherwise?

I have a feeling it'll be a long while before I really know how to feel about this...

It'll be interesting to see how well this merger actually works in practice. It seems like when large companies merge the results are often underwhelming. Can a merger of large open source projects work? Will the different cultures clash?

Locke··on A tiny interpreter for a stack-based language
Stack-based languages can be fun to play around with.

Way back when, I used Quartus Forth (http://www.quartus.net/products/forth/) to write a few small games for my Palm. Quartus is (was? looks dead...) an onboard Forth compiler -- Forth is a very compact language which is handy when you're writing code with a stylus.

The thing I remember most about it was that the actual coding was probably more fun than that playing the games I wrote. There's a kind of puzzle solving element to learning a stack-based language. I already knew how I'd write such-and-such function in a C-like language, it was all about arranging words in the most succinct, efficient manner possible to create the equivalent function.

I don't think I'd go back to Forth or another stack-based language for a project these days, but I'm glad for the time I spent playing with it.

Locke··on GitHub Launches Pages: Static Project and Personal Hosting
Yeah, this might make a nice tool for publishing any api docs (checkout a separate branch, generate, commit, and push your api docs), or code coverage reports, etc.

I don't know if it's really taken off, but a bug tracking tool like ditz could really benefit from this (it can generate an html report based on the bug "database" stored in your git repo).

http://ditz.rubyforge.org/

Locke··on Why Ruby is not my favorite language
Another (old?) rant about open classes aka "monkey patching". There's a lot of fear and hand wringing over open classes. It's certainly a language feature that can be abused, but it's also incredibly useful. There are things you can do to be safe:

Check for the existence of methods before adding them. Don't overwrite existing standard lib methods. If you do overwrite one, alias it, call the alias from your replacement which should add something without noticeably changing the original behavior.

If you write unit tests, it shouldn't be too difficult to detect that a library you depend on has changed the behavior of a standard method in an unacceptable way. I've encountered collisions like this, maybe, a handful of times and each time finding and resolving the problem was not difficult.

I've been writing ruby software for several years now, and there are definitely libraries that annoy me (ahem activesupport), but the utility of having open classes has far outweighed any of the negatives. Let's face it, in any programming ecology there are going to be some awful libraries. Bad programmers don't need open classes to do damage.

Locke··on Tetris Challenge
So what's the story behind this site? Has anyone tried it yet?

Partially answering my own question:

http://www.gossamer-threads.com/lists/python/python/696912

← PreviousPage 2 of 5Next →