• Recurring Madness: Functional Bash

    There are some ideas that have a will of their own. All the mighty strength of these wills is focused on a single goal, with a narrow-mindedness comparable only to a surgical laser. That goal is to become reality. You know this is so because these crazy stupid ideas keep happening again and again to different people.

    One of these ideas is functional programming in bash.

  • PlayStation 3 Jack Audio Output

    Waiting for the PS4 I realized that (1) it's still a while until it arrives, (2) it'll probably be a bit expensive at first and (3) there won't be a huge number of games for it. Conclusion: had to buy a PS3, and play some things I missed.

    Having been a PC-only gamer, I had a screen and great headphones. Note: not a TV; a computer screen with no speakers built in. I asked about the video, and got a DVI-HDMI adapter. Simple. Surprise: I noticed after all else was et up that there's no jack output on the thing. There are plenty of other outputs though. If you want 5.1, you can use the HDMI or optical digital output. If you want 7.1, you need to use HDMI. I just wanted my headphones to work, so I used the simple RCA output (which supports only stereo).

  • Django REST Framework: Add id in HyperlinkedModelSerializer

    from rest_framework import serializers
    from models import MyModel
    class WithPkMixin(object):
        def get_pk_field(self, model_field):
            return self.get_field(model_field)
    class MyModelSerializer(WithPk, serializers.HyperlinkedModelSerializer):
        class Meta:
            model = MyModel

    If that's enough for you, glad to be of service. Some context follows, and also a way to wrap JSON top-level list responses in a JSON object.

  • Relocating a hsenv

    If you have a hsenv environment (kind of like virtualenv, except it’s for Haskell), you can easily move it to another location and use it there; all you need to do is change a few strings in a few files. Here’s how, assuming you’re in the directory containing the .hsenv folder:

        for file in ghc_package_path_var path_var_prependix bin/activate; do
            sed -e "s,$old_location,$new_location,g" -i .hsenv/$file
  • Bacon.js on the Server

    Using Bacon.js to escape from Butcher Bay callback hell has been quite a pleasant, if mind-bending, experience. However, there hasn’t been too much talk about real usage on the server-side. I’d like to remedy this situation with some examples and tips I learned while converting a simple hand-coded REST API to Bacon.js.