Saturday, October 24, 2009

Brother MFC-7440N on Ubuntu 9.04

Mostly so I can remember if I need to do this again...

  • Go to http://solutions.brother.com/linux/en_us/download_prn.html#MFC-7440N and download the deb packages for the lpr *and* cupswrapper drivers
  • Follow the instructions listed at that link (http://solutions.brother.com/linux/en_us/instruction_prn1a.html), remembering you have to run them as root (that is, do 'sudo dpkg...')
  • When you get to step 5b, you have to get the IP address of your printer. The easiest way I found to do this is to go to the printer and print out the network configuration. Press the 'reports' button, press down until the screen says '6. Network Config', and press the 'OK' button. You want the 'IP Address' under the 'IP Settings' section.
  • The instructions say to enter 'your printers name', but I didn't really get that. After you pick your printer vendor (Brother), it gives you a list of printer models, but the 7440N didn't show up in the list for me. Where it says "Or provide a PPD file", I went to /usr/share/ppd and there was a "MFC7440N.ppd" file there, which I selected. (That's all I had to do, and after that if I went back into the modify printer screens the model showed up correctly.)

Wednesday, April 8, 2009

Reflections on Falling Blocks

There were various things I liked and didn't like about my code for Falling Blocks.

Liked:
  • The code for block rotation and row removal. The board code got a little complicated (due to an experiment that I kept), but I had tests that made getting that code correct a quick process. I got this working first and really didn't have to touch it again.
  • The way the current 'screen' is implemented - just functions in the game state. (Two functions - one like an OO MVC 'controller' and one like a 'view'.)
  • Relatively short. Under 500 lines without tests/comments. Probably could be shorter.
Didn't like:
  • Testing was hard. It seemed like there was a lot of setup for a simple test. I ended up exposing more of a given module than I wanted to make sure that functions that were just used in the module were working correctly. In the end, I wrote far fewer tests than I would have liked. I think a lot of this boils down to not factoring my code well - still trying to figure out how do to that in Haskell.
  • Also, not sure how to only test 'part' of something. If A uses B which uses C - how to test A without needing to test the rest. I want to stub or mock the rest, but don't know how.
  • Some of the code got too complicated (for example, the 'move' method isn't pretty). For a lot of the code, I didn't feel like I was 'gluing simple functions together'.
Any suggestions on the code are more than welcome.

Sunday, March 29, 2009

Falling Blocks - A Tetris clone in Haskell using SDL

Falling Blocks my first Haskell game. It is a Tetris clone that uses SDL.

While asking some questions on IRC, someone asked me if I had put the project up on Hackage. It hadn't really occurred to me before - I thought of Hackage mainly for libraries. But I decided that there could be more examples of using SDL and the Haskell bindings for it.

The code can be found as a darcs repo at:
http://patch-tag.com/publicrepos/fallingblocks

And can be found on Hackage here:
http://hackage.haskell.org/cgi-bin/hackage-scripts/package/fallingblocks

Play is simple:
  • Use the left/right arrow keys to move the block horizontally
  • Use the up arrow to rotate the block
  • Use the down arrow to move the block down more quickly
  • Press p to pause/unpause (0.1.4 +)
  • Press q to quit.
Thank you to everyone that helped me with this - especially those that helped me get the packaging working correctly.

A few screenshots:


Finally, a video Don Stewart put up on YouTube. Ignore the errors - those should be fixed now.