
Sedtris: Tetris in sed - waterhouse
http://uuner.doslash.org/forfun/
======
waterhouse
For learning about sed, this is the best resource that I've seen so far:

<http://www.grymoire.com/Unix/Sed.html>

~~~
bluesmoon
Programming patterns in sed: [http://tech.bluesmoon.info/2008/09/programming-
patterns-in-s...](http://tech.bluesmoon.info/2008/09/programming-patterns-in-
sed.html)

------
bluesmoon
Weird, I posted this exact same link with the same title a month ago:
<http://news.ycombinator.com/item?id=2303109>

Does HN use the URL as a primary key or something else?

~~~
silentbicycle
IIRC* , posts get rejected if the same URL is in the part of the history in
memory. HN loads its data off disk on-demand, and it gets restarted every once
in a while. Dupes can get submitted more easily after a recent restart, if
nobody else has caused that comment thread to load. This means there isn't an
explicit time-out for reposts, just a non-deterministic cut-off. I'd guess
it's roughly 6-9 months.

* Please correct me if I'm wrong!

Also, it's all too easy for a good post to get buried by a bunch of lame
submissions, then fall off the new page before getting enough upvotes. It'd
probably be worth making submissions cost a few points karma; the current
system blindly rewards submitting anything others are likely to post.

------
pkrumins
If you want to learn sed, I once wrote a multi-part article explaining various
sed one-liners:

[http://www.catonmat.net/blog/sed-one-liners-explained-
part-o...](http://www.catonmat.net/blog/sed-one-liners-explained-part-one)

Personally one of my favorite article series that I have written.

------
w1ntermute
Bash one-liner to play sedtris:

wget <http://uuner.doslash.org/forfun/sedtris.sed> && curl
<http://uuner.doslash.org/forfun/sedtris.sh> | bash

~~~
tkahn6
You should be piping that into bash instead of sh.

With sh, it infinitely prints out

    
    
        [: 48: unexpected operator
        read: 48: Illegal option -s

~~~
w1ntermute
Haha, I take it you're on Ubuntu? Ubuntu uses dash[0] as its default shell to
speed things up. Funny thing is I've run into this same issue before in
another context with sh vs bash on Ubuntu. In any case, updated.

0:
[https://secure.wikimedia.org/wikipedia/en/wiki/Debian_Almqui...](https://secure.wikimedia.org/wikipedia/en/wiki/Debian_Almquist_shell)

~~~
ez77
_Ubuntu uses dash as its default shell to speed things up._

Actually it is (sadly) the major reason, but not the only one:

 _The Debian policy manual has long mandated that "shell scripts specifying
'/bin/sh' as interpreter must only use POSIX features"; in fact, this
requirement has been in place since well before the inception of the Ubuntu
project. Furthermore, any shell scripts that expected to be portable to other
Unix systems, such as the BSDs or Solaris, already honoured this requirement.
Thus, we felt that the compatibility impact of this change would be minimal._
[1]

Personally I think that assuming nothing but POSIX is a more compelling reason
than efficiency.

[1] <https://wiki.ubuntu.com/DashAsBinSh>

------
benatkin
I downloaded and played it. It didn't disappoint!

I was left wondering whether the game speeds up, though, and if so, how it
works. Anyone know?

~~~
ars
It doesn't speed up. The sed program will wait forever for input, so it has no
set speed.

The helper bash script gives it input once a second.

It uses the "read" command to check for input from you, and it will wait 1
second. If it gets no input it sends the sed program an enter.

Unfortunately "read" can not have timeouts less than a second (it doesn't
support fractions of a second).

If you want, you could replace "read" with a different program that accepts
shorter timeouts. And presumably you could have the bash script slowly
decrease the timeout.

------
zorked
Sokoban in sed: <http://aurelio.net/soft/sedsokoban/>

