Home

Previous 20

Dec. 3rd, 2007

tachikoma valentines

♥♥♥ 100% WIN ♥♥♥


Lolcats + λ = ??

lambdacats!
♥♥♥

Tags:

Nov. 30th, 2007

tachikoma valentines

Quote of the Day

From a private correspondence, hopefully won’t get mad about posting this…
(“>” is me; the rest is the other party’s response.)
> If I had my say, nobody would use C++ or Java, the x86 architecture would be
> ancient history, and relational databases would actually be relational.
>
> Just saying.

Regretably, these things are decided by the paymasters, who are
usually so obsessed by next week's progress report that they can't
see beyond the end of their noses.  I speak as one who has seen it
many times.  Then the idiots end up pay ME to sort the mess out.

The problem with Java is that it is three things:

1.  A language with a crappy rehack of C++, allegedly making it more OO.
2.  A run time model that supposedly allows write once, run anywhere.
3.  A huge defined standard library of reusable components.

The problem is that when people say that they hate Java, they mean
(1).  When they say they love it, they mean (3).  As for (2) ...
well, to drop the tone of the discussion a little, I once saw the
remark that saying that Java is good because it will run anywhere is
like saying anal sex is good because it works with all genders.

I’m going to have to remember that one for future use.
Tags: ,

Oct. 13th, 2007

tachikoma valentines

Long time no blog~ (Part 2/3)

Here’s some lighter social commentary.

Tact Filters
All people have a "tact filter", which applies tact in one direction to everything that passes through it. Most "normal people" have the tact filter positioned to apply tact in the outgoing direction. Thus whatever normal people say gets the appropriate amount of tact applied to it before they say it. This is because when they were growing up, their parents continually drilled into their heads statements like, "If you can't say something nice, don't say anything at all!"

"Nerds," on the other hand, have their tact filter positioned to apply tact in the incoming direction. Thus, whatever anyone says to them gets the appropriate amount of tact added when they hear it. This is because when nerds were growing up, they continually got picked on, and their parents continually drilled into their heads statements like, "They're just saying those mean things because they're jealous. They don't really mean it."

When normal people talk to each other, both people usually apply the appropriate amount of tact to everything they say, and no one's feelings get hurt. When nerds talk to each other, both people usually apply the appropriate amount of tact to everything they hear, and no one's feelings get hurt. However, when normal people talk to nerds, the nerds often get frustrated because the normal people seem to be dodging the real issues and not saying what they really mean. Worse yet, when nerds talk to normal people, the normal people's feelings often get hurt because the nerds don't apply tact, assuming the normal person will take their blunt statements and apply whatever tact is necessary.

So, nerds need to understand that normal people have to apply tact to everything they say; they become really uncomfortable if they can't do this. Normal people need to understand that despite the fact that nerds are usually tactless, things they say are almost never meant personally and shouldn't be taken that way. Both types of people need to be extra patient when dealing with someone whose tact filter is backwards relative to their own.

Copyright © 1996, 2006 by Jeff Bigler. Permission is granted to redistribute this text in its entirety, provided that this copyright notice and either the URL for the page (http://www.mit.edu/~jcb/tact.html) or a link to it is included. All other rights reserved.
I like this argument in oh-so-many ways.  Simple: check.  Invokes nostalgia-tinted rememberances of childhood: check.  Has apparent application to reality: check.
Tags:
tachikoma valentines

At last!

I finally got some round tuits.
Tags:

May. 5th, 2007

tachikoma valentines

Now for something different

BP2-like grammar | Alex McLean @ YouTube

Now that’s just cool.

Also, I sorta promised [info]explodedbrain that I would share some of the really interesting stuff I’ve been reading today.  They’re all linked from HaskellWiki’s Functional pearls page:
Red-Black Trees in a Functional Setting [.ps]
In the realm of binary trees, red-black trees can’t be beat.  However, they are usually complex beasts in implementation.  In this paper, though, they are described by about 20 lines of Haskell code, and it gave me the sudden feeling “I understand rbtrees!”, which [info]explodedbrain likened to Neo’s “I know kung-fu” moment.
I don’t know if the average CS student can write an rbtree without a reference.  Probably not the average CMU CS student, since our 15-211 likes to focus on splay trees instead.
And as for me… well, I never put in the effort to really internalize any self-balancing binary tree other than AVL trees, which I regarded as “good enough”, and went off to B+ trees instead.  They’re so much better than binary trees in every aspect except simplicity.
But now I feel confident that I could write an rbtree if I chose to!  Not bad for two minutes of reading.
Inverting the Burrows-Wheeler Transform [.ps.gz]
Similarly, everybody has to study Huffman coding, and maybe Lempel-Ziv, while Burrows-Wheeler remains magical.  At least, that’s my impression of it.
But here, with a well-annotated unBWT in under 10 lines of code, it’s only taken me about 30 minutes of staring at it to be convinced.
Enumerating the strings of regular languages [.ps.gz]
This is just fun.  They went about it the exact same way I would have, which is pleasant validation.
Explaining Binomial Heaps [.ps.gz]
This is weird.  I keep trying to extend this into Fibonacci heaps, of which [info]weitzman has been known to be a proponent, and it feels like there’s just a tiny bit missing, I just need to throw an additional constraint and a little more thinking power at it.
That aside, it’s an interesting introduction to “normal” binomial heaps, in a step-wise way, where each step has a rationale or proof of correctness.  I don’t think it’s all that useful, but it’s nifty.
So I started running out of steam near the end, since I’ve now been up for 23 hours in a week with very little sleep.  The purity and similarity to mathematical structure that Haskell has, though, makes it such that demonstration “pseudo-code” is often real, executable code, making it even easier to reason about.

So yeah.  Learn Haskell first, then everything else is easy.  ;-)
Tags: ,

Apr. 5th, 2007

tachikoma valentines

Just off the top of my head

 KEY |        PLAIN         |        SHIFT         |         CTRL         |         META
space|      page down       |                      |                      |
     |       (pager)        |                      |                      |
  a  |insert after character|    append to line    |  beginning of line   |
     |         (vi)         |         (vi)         |       (Emacs)        |
  b  |    previous word     |                      |                      |
     |         (vi)         |                      |                      |
     |       page up        |                      |  previous character  |    previous word
     |       (pager)        |                      |       (Emacs)        |       (Emacs)
  c  |    replace range     |    replace to EOL    |        SIGINT        |
     |         (vi)         |         (vi)         |        (term)        |
  d  |     delete line      |    delete to EOL     |   delete character   |     delete word
     |         (vi)         |         (vi)         |       (Emacs)        |       (Emacs)
     |    half-page down    |                      |                      |
     |       (pager)        |                      |                      |
  e  |      skip word       |                      |     end of line      |
     |         (vi)         |                      |       (Emacs)        |
  f  |    find character    |reverse find character|    next character    |      next word
     |         (vi)         |         (vi)         |       (Emacs)        |       (Emacs)
  g  |                      |    goto line/EOF     |                      |
     |                      |         (vi)         |                      |
  h  |  previous character  | beginning of screen  | backspace character  |    backspace word
     |         (vi)         |         (vi)         |       (Emacs)        |       (Emacs)
  i  |        insert        |                      |         tab          |
     |         (vi)         |                      |        (term)        |
  j  |    down one line     |                      |       new line       |
     |         (vi)         |                      |        (term)        |
  k  |     up one line      |                      |                      |
     |         (vi)         |                      |                      |
  l  |    next character    |    end of screen     |      form feed       |
     |         (vi)         |         (vi)         |        (term)        |
  m  |                      |                      |      line feed       |
     |                      |                      |        (term)        |
  n  |  next search result  |previous search result|      next line       |
     |         (vi)         |         (vi)         |       (Emacs)        |
  o  |    new line after    |   new line before    |                      |
     |         (vi)         |         (vi)         |                      |
  p  |      put after       |      put before      |    previous line     |
     |         (vi)         |         (vi)         |       (Emacs)        |
  q  |     record macro     |                      |         XOFF         |
     |         (vi)         |                      |        (term)        |
  r  |                      |      overwrite       |                      |
     |                      |         (vi)         |                      |
  s  |  replace character   |     replace line     |         XON          |
     |         (vi)         |         (vi)         |        (term)        |
  t  |                      |                      |      transpose       |
     |                      |                      |       (Emacs)        |
  u  |     half-page up     |                      |                      |
     |       (pager)        |                      |                      |
  v  |         edit         |                      |                      |
     |       (pager)        |                      |                      |
  w  |      next word       |                      |                      |
     |         (vi)         |                      |                      |
  x  |   delete character   |                      |      completion      |
     |         (vi)         |                      |         (vi)         |
  z  |                      |                      |       SIGSTOP        |
     |                      |                      |        (term)        |
  0  |  beginning of line   |    next paragraph    |                      |
     |         (vi)         |         (vi)         |                      |
  4  |                      |     end of line      |                      |
     |                      |         (vi)         |                      |
  5  |                      | balancing structure  |                      |
     |                      |         (vi)         |                      |
  6  |                      |    start of line     |                      |
     |                      |         (vi)         |                      |
  9  |                      |  previous paragraph  |                      |
     |                      |         (vi)         |                      |
 0-9 |        count         |                      |                      |        count
     |         (vi)         |                      |                      |       (Emacs)
  -  |        option        |                      |                      |
     |       (pager)        |                      |                      |
  =  |       reformat       |                      |                      |
     |         (vi)         |                      |                      |
  [  |    previous block    |                      |                      |
     |         (vi)         |                      |                      |
  ]  |      next block      |                      |                      |
     |         (vi)         |                      |                      |
  \  |                      |                      |       SIGQUIT        |
     |                      |                      |        (term)        |
  ;  |                      |       ex mode        |                      |
     |                      |         (vi)         |                      |
  ,  |                      |        indent        |                      |
     |                      |         (vi)         |                      |
  .  |    repeat insert     |       outdent        |                      |
     |         (vi)         |         (vi)         |                      |
  /  |        search        |    reverse search    |                      |
     |         (vi)         |         (vi)         |                      |

A few of the vi entries probably only exist in Vim.  As you can tell, I use Vim far more than Emacs; I only know a few Emacs keybindings because libreadline/Bash uses a lot of them.  Most of the pager entries probably only exist in less, which also copies quite a few of the vi keybindings.

This is all you need to know to navigate around most terminal-based interfaces.  Most programs imitate some subset of these.  In fact, all of the Emacs keybindings I listed should work exactly as-is in any standard text field in OS X.  (Did NeXT do that?  I dunno.)

Things are less consistent on UNIX desktops… most newer GUIs are influenced by the shortcuts that Windows came up with, while older ones still do their own thing.  For example, with KDE’s defaults, Ctrl-A maps to “Select All”, but if you unbind it, it suddenly becomes “Start of line”.
Tags:

Mar. 31st, 2007

tachikoma valentines

Not fair!

For last semester’s Networks project, I managed to subvert Perl’s Test::Harness into running our unit tests in C, and tied it into our Autoconf/Automake build system.

This semester, I recreated the same framework, using TAP::Parser and plain ol’ GNU make.  It’s all well and good and makes me happy.  ^_^

However, our larger volume of code this semester has far more comprehensive tests accompanying it.
On my laptop (1.25GHz G4, 167MHZ FSB, 512MB RAM) where I do most of my development:
dtlin@vola:~/441p3$ make check
             lib/runtests [+x]
runtests --execrc=t/execrc  t
t/graph..........ok
t/heap...........ok
t/ipforward......ok
t/ll.............ok
t/ospf...........ok
t/routed.........ok
t/rtable.........ok
t/rwlocks........ok
t/tcp............ok
t/tree...........ok
All tests successful.
Files=10, Tests=12565, 72 wallclock secs ( 0.67 cusr +  0.23 csys =  0.90 CPU)
On my desktop (2.80GHz P4/HT, dual 800MHz FSB, 1536MB RAM) where I do additional testing:
dtlin@burnup:~/441p3$ make check
             lib/runtests [+x]
runtests --execrc=t/execrc  t
t/graph..........ok
t/heap...........ok
t/ipforward......ok
t/ll.............ok
t/ospf...........ok
t/routed.........ok
t/rtable.........ok
t/rwlocks........ok
t/tcp............ok
t/tree...........ok
All tests successful.
Files=10, Tests=12565, 36 wallclock secs ( 0.65 cusr +  0.37 csys =  1.02 CPU)
And on the Linux machines (3.40GHz Pentium D, 800MHZ FSB, 2048MB RAM) that the school gives us shell acounts on:
dtlin@unix32:~/441p3$ make check
             lib/runtests [+x]
runtests --execrc=t/execrc  t
t/graph..........ok
t/heap...........ok
t/ipforward......ok
t/ll.............ok
t/ospf...........ok
t/routed.........ok
t/rtable.........ok
t/rwlocks........ok
t/tcp............ok
t/tree...........ok
All tests successful.
Files=10, Tests=12565, 11 wallclock secs ( 0.26 cusr +  0.17 csys =  0.43 CPU)
That’s just unfair.
Tags:

Mar. 27th, 2007

tachikoma valentines

In the footsteps of wmii

dtlin@burnup:~$ wc dwm-3.8/*.[ch]
  402  1274  9459 dwm-3.8/client.c
   99   593  3859 dwm-3.8/config.arg.h
   97   588  3862 dwm-3.8/config.default.h
  136   448  2911 dwm-3.8/draw.c
  147  1003  6186 dwm-3.8/dwm.h
  365  1025  8124 dwm-3.8/event.c
  255   779  4816 dwm-3.8/layout.c
  325  1066  9123 dwm-3.8/main.c
  154   425  2836 dwm-3.8/tag.c
   54   142  1053 dwm-3.8/util.c
 2034  7343 52229 total
dtlin@burnup:~$ cat dwm-3.8/*.[ch] | gzip -9 | wc -c
13749
dtlin@burnup:~$ wc xmonad/*.hs
   97   584  3787 xmonad/Config.hs
  184   848  5877 xmonad/Main.hs
  223  1242  7822 xmonad/Operations.hs
  179  1334  7148 xmonad/StackSet.hs
  114   567  3708 xmonad/XMonad.hs
  797  4575 28342 total
dtlin@burnup:~$ cat xmonad/*.hs | gzip -9 | wc -c
9073

(I failed at counting the first time I tried to compare them.  Computers are really much better at this than I am.)

Both dwm and xmonad are minimalistic X11 window managers, roughly equivalent in goals.  Not that comparing anything to C is ever fair, but note that dwm, written in C, is nearly triple the line count of xmonad, written in Haskell.  xmonad even supports Xinerama, which dwm doesn’t do.

Surprisingly, dwm only contains about 20 lines dedicated to memory management and not much more dealing with linked list management, while xmonad contains 180 lines for a rotating stack data structure.  i.e., dwm is unusually small and xmonad is unusually large, for C and Haskell projects.
Tags:

Mar. 7th, 2007

tachikoma valentines

First bug fix of the day

makes me sad.
Tags:

Mar. 4th, 2007

tachikoma valentines

Not that I'm superstitious, but...


I wonder if this means anything.
Tags:

Mar. 1st, 2007

tachikoma valentines

Making the most of a waste of time

In our networks programming project (speaking of which, I really ought to be studying for that class right now, the test is in a few minutes), we have to write some code which will be used in a multithreaded environment.

Now, how would you go about generating unique, incrementing IDs?

#if defined(__powerpc__)
// SCARY!  Only for powerpc.
#define atomic_inc_int(ptr) ({                            \
    int __atomic_inc_int_ret;                             \
    asm volatile(                                         \
            "eieio\n"                                     \
            "retry:\n"                                    \
            "lwarx      %0, 0, %1\n"                      \
            "addic.     %0, %0, 1\n"                      \
            "stwcx.     %0, 0, %1\n"                      \
            "bne-       retry\n"                          \
            "isync\n"                                     \
            : "=&r" (__atomic_inc_int_ret)                \
            : "r" ((ptr))                                 \
            : "cc", "memory");                            \
    __atomic_inc_int_ret;                                 \
})
#elif defined(__i386__)
// SCARY!  Only for i486 and up.
#define atomic_inc_int(ptr) ({                            \
    register int __atomic_inc_int_ret = 1;                \
    asm volatile(                                         \
            "lock xaddl %0, %1"                           \
            : "=r" (__atomic_inc_int_ret)                 \
            : "m" (*(ptr)), "0" (__atomic_inc_int_ret)    \
            : "cc", "memory");                            \
    __atomic_inc_int_ret + 1;                             \
})
#else
#define atomic_inc_int(ptr) (++*(ptr)) // HAHAHAHA
#pragma GCC poison atomic_inc_int
#endif

int unique() {
    static int counter = 0;
    return atomic_inc_int(&counter);
}
++counter has an obvious flaw: it’s compiled to “load; increment; store”, and if this thread is pre-empted, wrong things could happen.  Rare and unexpected, but possible.

The most common solution is simply to serialize access with a mutex or an rwlock.  Boring〜

unique.o:     file format elf32-powerpc

Disassembly of section .text:

00000000 <unique>:
int unique() {
   0:        94 21 ff d0         stwu    r1,-48(r1)
   4:        93 e1 00 2c         stw     r31,44(r1)
   8:        7c 3f 0b 78         mr      r31,r1
    static int counter = 0;
    return atomic_inc_int(&counter);
   c:        3d 20 00 00         lis     r9,0
  10:        38 09 00 00         addi    r0,r9,0
  14:        7c 00 06 ac         eieio

00000018 <retry>:
  18:        7d 20 00 28         lwarx   r9,0,r0
  1c:        35 29 00 01         addic.  r9,r9,1
  20:        7d 20 01 2d         stwcx.  r9,0,r0
  24:        40 a2 ff f4         bne-    18 <retry>
  28:        4c 00 01 2c         isync
  2c:        7d 20 4b 78         mr      r0,r9
  30:        90 1f 00 1c         stw     r0,28(r31)
  34:        80 1f 00 1c         lwz     r0,28(r31)
}
  38:        7c 03 03 78         mr      r3,r0
  3c:        81 61 00 00         lwz     r11,0(r1)
  40:        83 eb ff fc         lwz     r31,-4(r11)
  44:        7d 61 5b 78         mr      r1,r11
  48:        4e 80 00 20         blr
The PowerPC solution does the obvious thing.  “load with reservation, increment, store with reservation, retry if somebody else interrupted”.  (There’s “I’m about to do something that shouldn’t be reordered”, “it’s unlikely that you’ll branch here”, and “tell everybody else that they should probably sync up memory” hints in there, but those aren’t truly necessary.)

unique.o:     file format elf32-i386

Disassembly of section .text:

00000000 <unique>:
int unique() {
   0:        55                           push   %ebp
   1:        89 e5                        mov    %esp,%ebp
    static int counter = 0;
    return atomic_inc_int(&counter);
   3:        b8 01 00 00 00               mov    $0x1,%eax
   8:        f0 0f c1 05 00 00 00         lock xadd %eax,0x0
   f:        00
  10:        40                           inc    %eax
}
  11:        5d                           pop    %ebp
  12:        c3                           ret   
x86, on the other hand, is a CISC architecture rather than a RISC processor, so it has a set of specialized opcodes for this purpose.  “lock xadd” means to first signal “LOCK#” to all other processors, which is an announcement of “nobody else do anything for a while!”, then exchanging, adding, and storing.

Personally, I like the PowerPC variant.  Even though it’s longer, it will usually be faster, and the architecture is righter.  However, it will go to waste in our networks programming project, because it isn’t going to be run on anything but x86.  ;_;
Tags:

Feb. 24th, 2007

tachikoma valentines

Working hard to make non-sense

Read more... )
Apparently Conelead has more stuff than I do, at least in the physical realm.  Not that I’m complaining; he’s had more disposable income for longer than I have.

That’s not the point.  “Look!  Isn’t my desktop so pretty now?” is more like it.  In addition to the background and colors and style from last time, it’s got the Lila icon and cursor theme, Kasbar replacing the taskbar (with the panels made transparent and reorganized), and Superkaramba running the GlassMonitor on the desktop.

Ever since popping that new hard disk into my machine, I’ve been experiencing very low uptimes.  I’ve gone through various hypotheses, and my current hypothesis is that my machine is overheating.  So I set up lm_sensors and fancontrol, and stuck KSysGuard onto my panel to monitor.  But KSysGuard is ugly!  So I went and redecorated, resulting in the above setup.

One of the nice (and geeky) things about having multiple computers is that while one is unusable, the other is still available.  My laptop is fine, but it’s been working like a really hard-working thing over the past few days.

It’s taken a long time to build a cross-gcc (--host=powerpc-linux-gnu --target=i486-linux-gnu), even with the help of the Debian Wiki, because I’m doing this on a 1.25GHz G4.  Even longer if debian/rules.defs insists on trying (and failing) to build a x86_64 cross-compiler too, but I eventually got it working.

For our present 15-441 Computer Networks project, we are given a kernel in which we are meant to implement IP and routing and stuff.  Most of this kernel comes as x86 binary archives without source.  Which is really annoying, because it means I can’t build, run, or test it on my laptop.

Well, the cross-compiler takes care of the building; theoretically QEMU can take care of the running; and I rewrote their build system, in part so that I could tie in a unit test framework based on TAPx::Parser, inspired by a Test::Harness-based framework I wrote last semester.

Read more... )Yeah… that’s not good.

Ah, that reminds me of part of my ~/.bashrc.  I think it’s pretty clever, if I do say so myself.
_PS1() {
        local PRE= NAME="$1" LENGTH="$2"
        [[ "$NAME" != "${NAME#$HOME/}" || -z "${NAME#$HOME}" ]] &&
                PRE+='~' NAME="${NAME#$HOME}" LENGTH=$[LENGTH-1]
        ((${#NAME}>$LENGTH)) && NAME="/...${NAME:$[${#NAME}-LENGTH+4]}"
        echo "$PRE$NAME"
}
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]$(_PS1 "$PWD" 20)\[\033[00m\]\$ '


And to finish off today’s wandering discourse:
The Official God FAQ – all you need to know.
The Universe of Discourse : A new proof that the square root of 2 is irrational – that is a lot more elegant!
mihmo: A profound statement
OpenMoko Press Information – yes, they announced this product last year, waaay before the iPhone.  It’s better and it should have been first, but they’ve had some unfortunate issues with personnel and manufacturing.
TYC 9350-1626-1 - Star - WIKISKY – it’s Stellvia’s Hydrus Beta!
2007-01-15 -- science vs faith.png – I dunno.  What happens if you apply Occam’s Razor to this one?
Tags: ,

Feb. 18th, 2007

tachikoma valentines

Today's news


I love how KDE supports and ships with SVG wallpapers.  Right now We Are Gear is my background.  Uncolored, it would look like the image left, but it has transparency, so with a background under it, it becomes the image right.

This was prompted by my discovery of the awesome Domino theme today.  Put together with mxcl's "Pretty Good" Purple Scheme and Kicker PurpleLight, my desktop looks like this.

I like it.



My desktop used to contain an 80GB IDE drive and a 150GB SATA drive.
/dev/hda <[/boot:40M] [SWAP:1.5G] [/:10G] [/home:68G]>  /dev/sda <[/home/Shared:150G]>
The IDE drive died, so I bought a 400GB SATA drive.
/dev/sda <[/boot:60M] [SWAP:2G] [/:147G]>  /dev/sdb <[/home:373GB]>
I disassembled the dead drive just for fun.  Platters are shiny ^_^.



By the way – 新年快樂!
Tags:

Feb. 13th, 2007

tachikoma valentines

Dance for joy!

Putting together the FIT is hard.  Not only are the units time-consuming to craft, but the open tetrahedron isn’t all that stable, and you have to put five of them together under adverse conditions.

Thomas Hull’s instructions for assembly are quite difficult.  You need a solid understanding of the symmetrical structure, and a lot of patience.
Thomas Hull’s construction
[1][2][3][4][5]

I managed it once, but I couldn’t replicate it.
Instead, while I was studying the first one I built, trying to piece together the second, I realized that it would be a lot easier to exploit the regularity of the ring-like thingies.
My construction
[1][2][3][4][5][6][7][8][9]

Both methods yield in the same, beautiful end result.
Completed FIT

I’ll see if I can get some real pictures up.  My POV-Ray skills are not all that high.
Tags:

Feb. 3rd, 2007

tachikoma valentines

mod_rewrite can do anything

Maybe I’ve have, maybe I haven’t, mentioned that Darcs is my favorite revision control system.  Simple interface, powerful operations, written in Haskell…

I have a bunch of Darcs repositories; some of them are my own projects, lots are just converted-to-Darcs mirrors of other projects.  I run a darcsweb interface because it’s really nice.

[info]explodedbrain brought up the point that it’s probably not a good thing for all of our revision-controlled schoolwork to also be publically viewable.  I had ignored this in the past, since nobody but me really knows how to reach the site, but I changed my mind overnight and so today I made Apache block access from non-local networks to private repositories, while keeping the public ones publically-viewable and allowing us to see our work locally.

Alias /darcs/repos /var/darcs
<Directory /var/www/localhost/htdocs/darcs>
        AllowOverride None
        RewriteEngine on
        RewriteBase /darcs
        RewriteCond %{REMOTE_HOST} !^(192\.168\.\d+\.\d+|127\.\d+\.\d+\.\d+)$
        RewriteCond %{QUERY_STRING} r=([^&;]*)
        RewriteCond /var/darcs/%1/.private -f
        RewriteRule (.*) $1 [F]
        RewriteCond %{REQUEST_URI} ^/darcs/(.*)
        RewriteCond /var/www/localhost/htdocs/darcs/%1 !-f
        RewriteCond %{REQUEST_URI} ^/darcs/(.*)
        RewriteCond /var/darcs/%1 -f
        RewriteRule ^([^?]+) repos/$1
        DirectoryIndex darcsweb.cgi
        <Files darcsweb.cgi>
                Options ExecCGI
                SetHandler cgi-script
        </Files>
        <Files ~ "^config\.py">
                Order allow,deny
                Deny from all
        </Files>
</Directory>
<Directory /var/darcs>
        AllowOverride None
        RewriteEngine on
        RewriteBase /darcs/repos
        RewriteCond %{REMOTE_HOST} !^(192\.168\.\d+\.\d+|127\.\d+\.\d+\.\d+)$
        RewriteCond %{REQUEST_URI} ^/darcs/repos/([^/]*)/
        RewriteCond /var/darcs/%1/.private -f
        RewriteRule (.*) $1 [F]
        SetHandler default-handler
        DAV On
</Directory>


That’s a bit of a lie; currently the repositories are sitting in /home/dtlin/darcs, not /var/darcs, but that’s because my current /var partition is a bit small.  I just bought a new 7200RPM 400GB SATA HDD, so everything should be organized a bit saner soon.

Annoyance: I ordered the HDD from Newegg, and it was pretty cheap and came quickly.  I was worried that it might not come with mounting screws, but it did.  However, I expected it to come with a SATA cable, and it didn’t, so now I have to go find one…
Tags:

Jan. 5th, 2007

tachikoma valentines

DVD ripping

Stealing from here and here, here’s a script I wrote recently to rip DVDs with subtitles into multi-language AVC+AAC MP4s.  (H.264/MPEG-4 AVC is so amazing.  And so painfully slow to encode.)  It uses faac, gpac, and mplayer.
(In a soon-to-come post: why I needed to do this.)

-e to exit on error, -x to print out every command
#!/bin/bash -ex

run lsdvd manually to determine which titles to rip
# lsdvd

for each title to rip
for i in {2..6}; do
dump the MPEG-2 stream
        mplayer dvd://$i -dumpstream -dumpfile title$i.vob
dump the subtitles
        mencoder dvd://$i -nosound -ovc frameno -o /dev/null -slang en -vobsubout title$i

for each audio track
        for j in 128:e 129:j; do
dump the audio stream
                mplayer title$i.vob -ao pcm:fast:file=title$i${j#*:}.wav -vc null -vo null -aid ${j%%:*} -vo null
convert it to AAC (mp4a)
                faac -q 90 title$i${j#*:}.wav -o title$i${j#*:}.aac
and clean up
                rm -f title$i${j#*:}.wav
        done

run this manually to detect the cropping region
        # mplayer -vf cropdetect title$i.vob

first encoding pass
        mencoder \
                title$i.vob \
                -vf pullup,softskip,crop=704:480:10:0 \
                -ovc x264 -x264encopts subq=4:bframes=3:b_pyramid:weight_b:turbo=1:pass=1:psnr:bitrate=1000 \
                -nosound \
                -of rawvideo \
                -o title$i.264
assert size ≠ 0
        ((`stat -c%s title$i.264`))

second (final) encoding pass
        mencoder \
                title$i.vob \
                -vf pullup,softskip,crop=704:480:10:0 \
                -ovc x264 -x264encopts subq=6:partitions=all:8x8dct:me=umh:frameref=5:bframes=3:b_pyramid:weight_b:pass=2:psnr:bitrate=1000 \
                -nosound \
                -of rawvideo \
                -o title$i.264
assert size ≠ 0
        ((`stat -c%s title$i.264`))

clean up the DVD dump
        rm -f title$i.vob

mux all the streams together
        MP4Box -add title$i.264\#video -add title${i}j.aac\#audio\;lang=jap -add title${i}e.aac\#audio\;lang=eng title$i.mp4
and clean up
        rm -f title${i}e.aac title${i}j.aac title$i.264
done


All the streams are re-encoded separately.  In theory this shouldn’t present a problem, but in practice, the media files I produced in this run have quite large A-V timing skews.  Unfortunate.  (It should be fixable without re-encoding, though I’m not entirely sure how, yet.  In the meantime, three cheers for mplayer’s ability to change audio and sub sync to whatever you want, whenever you want.)

In the future I may simply use VLC, which can do just about everything (despite its relatively lacking documentation).  (Just see this.)  VLC used to have the problem of refusing to transcode faster than realtime, but not only is that not an issue here (AVC is expensive!), but I hear it’s been fixed.
Tags:

Dec. 20th, 2006

tachikoma valentines

Frozen-Bubble 2.1.0 Online Play

I actually managed to play against lots of people online today.  It was pretty awesome.  (Probably because of time zones.  Most of the people online today were French speakers.)

So awesome that I didn’t notice that 4 hours passed while playing it.  Wow!  I never spend that much time on a single game alone.

All you non-*NIX folks are missing out.  Frozen-Bubble 2.1.0 was developed on, runs on, and has not been ported away from, Perl/SDL on *NIX.  (It’s open source, so feel free to do so yourself if you want.)

Yes, Hashi, you did mention the Frozen Bubble - Java Port, which does run on other OSes.  That’s not so much a port as a look-alike, act-alike rewrite.  And it isn’t anywhere as complete or cool as the new Frozen-Bubble 2.1.0.

So everybody, install Linux and play Frozen-Bubble 2.1.0 online today!  =^_^=
Tags:

Dec. 17th, 2006

tachikoma valentines

Jonathan Coulton's Code Monkey

Sadly, I appear to be 8 months slower than /. in discovering this song.  Not that it decreases my enjoyment of it in any way, though.  I just feel a little silly posting something some of my readers (all 2¾ of them) may already know of.

Code Monkey [mp3] [lyrics] Read more... )
Tags: , ,
tachikoma valentines

Something I stumbled across today

sub is_prime{$_='x'x+pop;/xx/^/^(xx+)\1+$/}
Perl.  Yes, it actually works.

[EDIT]Read more... )
Tags:

Nov. 6th, 2006

tachikoma valentines

wakarunai

I have discovered the best smiley ever.  Better than ;-), better than =^_^=, it is:
(see the Unihan database @ Unicode.org if you lack proper fonts)
The katakana for “tsu”.  Tilt your head about 30° to the left…

On a related note, while watching Kanon 2006 ep.5, I think I heard Sayuri say 悪い(Sounded like 佐祐理悪いです, though I’m not completely sure.  At least it’s consistent with the fansub.)
Usually I don’t pay much attention to the audio track, seeing as how I don’t understand any of it, but this one jumped out at me.  Isn’t that what Mom calls me all the time?
Tags:

Previous 20

tachikoma valentines

November 2009

S M T W T F S
1234567
891011121314
15161718192021
22232425262728
2930     

Advertisement

Syndicate

RSS Atom
Powered by LiveJournal.com