Archive for July 2010

Doku: progress so far this week.

Alright, so I’m finally getting around to making a little more progress on my sudoku game.  so I figured I would post a few screenshots and show my progress and discuss what’s left on my todo list.  First of all, here is what I started out with:


This is an image of the program nsudoku which I shamelessly open-sourced from the AUR. I figured nsudoku would be perfect for this exercise in learning ncurses because it already is a perfectly functional sudoku puzzle creator, meaning I don’t have to reinvent the wheel too much. After playing around with nsudoku for a little while, it wasn’t long before I found a laundry list of things I thought needed tweaked and improved on it and I decided to get to hacking. First of all, I can’t stand the color, or that the user is locked into only one color scheme. one of my goals is to implement a feature (whether it be via command line arguments or a menu) that allows the user to specify a variety of color schemes to make things a little easier on the eyes. Another goal that I have in mind is to implement a game clock/best time feature. Basically I want a small clock displayed during the puzzle that keeps track of the amount of time the user spends on the puzzle, and then records this value and the difficulty level to a “best times” file which is displayed at the end of each game. Those are the two major additions I’ve been considering and haven’t quite had the time for yet. Of the progress I’ve made, however, I’ve managed to create a much better looking grid around the puzzle and I’ve also added ‘vim style’ key bindings for cursor movement:


I’ve also created a much more elegant solution to the difficulty selection. In the original nsudoku, the program had to be started with an integer argument between 1 and 80 equal to the number of cells the user wanted to have given initially. I didn’t really like this and decided instead to have a “choose difficulty” menu open at the start of the program, allowing the user to choose from 5 difficulty levels, each level randomly choosing an integer initial value within a small range just to add a little suprise.

here’s what I have so far for the difficulty selection menu:


So far it’s pretty basic, and I still need to implement colors, but for now I think this will work quite nicely.

I think that’s about it for my progress update on Doku, It’s going to be slow going over the next couple of weeks, I’ve got a new addition to the family who is taking up quite a bit of my free time lately, however, I should still be able to find some time to get through this project by the end of summer.

Doku: my new project.

Well, I’m waiting on some more spending money to come in before I can start working on any more interesting electronics projects; so I’ve decided to shift my focus temporarily and concentrate on learning the ins and outs of the ncurses library so that I can make some more robust and fun console based applications. To be honest with you, I HATE working with graphical user interfaces. almost all of my programming thus far has used either a line based user interface, or run in the background without need of a user interface. I think that most graphical user interfaces increase code complexity exponentially to the point where only part of the running code involves the programs functionality and the bulk of it is just there to make things pretty and “user friendly.” This is why my main choice for creating a user interface is ncurses. I use several ncurses based programs on a daily basis and I am very happy with their appearance, ease of use, and general all around simplicity, and now I’d like to learn how to implement some of these features in my own programming projects. The idea to learn ncurses has been a while in the making. With many of my projects (like learning Python and Perl) I start out with the desire to learn the skill, but no TASK to perform with the skill, usually causing me to lose interest in a project rather quickly. Occasionally, however, I derive a task that I want to accomplish, and manage to tie in the opportunity to teach myself a new skill along the way. This is how I came up with the idea for Doku, my new C/ncurses sudoku program. I came up with the idea this morning while doing the puzzles in the daily paper. I was thinking, “man, I love these puzzles, I should install a sudoku program. Hell, I’m a programmer, I bet I could MAKE a sudoku program!” So I went to my PC and started hunting around in the repositories for a nice simple sudoku program I could play around with to get me started. After taking a look at all of the options I settled on nsudoku from the aur. I figured this would be a great starting point because it is simple (written in C in less that 200 lines of code) and it already implements a basic ncurses interface.

So I downloaded the source this morning and immediately started hacking away. I have quite a few ideas for what features I would like to implement and change. here are the ideas I’ve had so far:

  • create a better grid around the puzzle
  • implement VIM key bindings for movement
  • implement a better system for selecting puzzle difficulty
  • implement timing on games, and best times for each difficulty level
  • extend the colors, and provide the option of changing colors
  • I’m also going to be dividing the code up into more manageable chunks to better facilitate code reuse.  Essentially, the original author wrote some great code for generating/solving puzzles, I’m just going to be hacking in a bunch of simple features,  making things a little more elegant, and making an awesome sudoku program that everybody is going to want to play!

    I’m also thinking that when I make some good progress on this project I’m going to be throwing the source on github, cooking up a PKGBUILD, and putting it in the AUR so that everyone else can have a chance to play with it and hack it up a little bit.  but all of that will be a few days/weeks down the road I think.  If anything it will keep me busy in my freetime for a while :)

    Added Some Links

    This is just a quick post, I added a couple more links over to my “Favorite Electronics Sites” section.
    Check out the Electronics Club for loads of information great for getting started with hobby circuitry. This site contains lots of tutorials, guides to parts, and projects. It is British, so expect a few minor differences from American electronics terminology (like Ground = Earth, Antenna = Areal, resistors are rectangles and not squigglies, and the metric system) but regardless, a great great great resource! I’ve also added a Link to The Datasheet Archive which provides component datasheets free of charge! This site is my best friend. If you aren’t familiar with data sheets, they are documents containing all of the technical specifications for any given component (think Man Pages for your parts!) learn to use them! Okay, that’s it for now.

    Hacking My MAC Address, And Recovering Photo's off of an SD card.

    For those of you anxiously awaiting my new addition to the tutorial series, I just want to say sorry that it’s been a while. Sometimes life has to come before hobbies and my life has been pretty exciting this past week. First of all, my family has moved across town into a new house, so most of my time has been taken up by unpacking, spending money, installing appliances etc. Also my wife and I are both a little on edge because we only have a couple more days left before we have a new addition to our family, my second son Clinton. Honestly, with all of this going on it’s a miracle that I managed to get my new motherboard installed and my computer up and running again!

    The installation of the new mother board went about as smooth and flawlessly as I could have possibly hoped for. After getting the hardware all hooked up, I just hit the on button and everything booted perfectly. The only problem that I ran across, and the first topic of this post, was that my Ethernet card’s MAC address, for whatever reason, wasn’t being recognized by my router when trying to add my PC to the reserved IP list. Of course I started out with a google search, which resulted in several people trying to fix this same problem in Windows, and mostly failing (sadly for them this fix involves registry hacking apparently) and a bunch of results saying “the mac address is built into the hardware, you can’t change it!” which I called BS on.

    So then I moved onto my next resource, the Arch Linux Forums. Here I found about 100 different solutions to my problem, none of which really suited my needs.
    I learned that the command to spoof your mac address is ifconfig {interface} hw ether XX:XX:XX:XX:XX:XX which is great, did the job. However, to run this command, the interface must be down, and then brought back up again afterwards. Also, the change is not persistent, as in the minute you reboot, your mac is back to the original factory defaults! LAME! So then I looked into sticking this command into one of the start-up scripts somewhere. The first thing I tried was inserting the above command into /etc/rc.local. This did achieve the desired affect of changing my MAC, however it performs this after the network daemon has already started, meaning that once booted, I would have had to re-bounce my network connection to get the reserved IP assigned to me. double lame. I finally settled on sticking the above command into /etc/rc.multi prior to the “Start daemons” loop. and now I have the desired mac address, and can have my reserved DHCP.

    The next most interesting thing I’ve had to do this week is recover all of my family photos for the past few months off of a corrupted SD card. For whatever reason, the camera that we purchased back around Christmas occasionally tends to completely destroy the SD card filesystem for no reason at all (this is the first time it has ever happened to us, we learned that it is a commonly existing problem from product reviews on-line). My wife had the first go at recovering the data from the disk. After a while she came across a “free” program on-line that would recover the data. It turns out that it worked! but to “get” the photos that had just been recovered by the software, you had to download their $30US “download” software. What a scam. So she passed the task onto me. After a little bit of hunting around I discovered this fun program for rescuing data and photos from corrupted volumes called “testdisk” (available in the Extra repository for Archers) which includes a software called “photorec” specifically designed for hunting down and recovering photographs and movies. It worked like a charm :) took about 5 minutes, and recovered all of my photos from the last year flawlessly. I looked at the product documentation and it seems both testdisk and photorec are going to be pretty handy additions to my Linux tool set. I suggest trying them out some time!

    New Toys Coming!

    Alrighty, So I’ve finally got my new motherboard coming in the mail and I can’t wait to get my PC up and running again!  Thank god I back everything up regularly, getting my baby back on her feet shouldn’t be too much of a headache.

    In other news, I’ve bought some new toys from so I can get to work on some of my new project ideas.

    One of the cooler toys is the avr-p28B programmer shown here:

    This is going to be a much more elegant solution to the home brew hacky kluge of a development board that I have built on my proto-board. which is awesome, because that frees up a protoboard for other tinkering projects. My next set of projects that I’m going to be working on involve basic robotics based off of AVR micro-controllers. I’ve found a few good sources for parts, and now I only need to find a cheap/good quality PCB manufacturing house to produce the boards once I have them designed. My idea is just to start with a basic solar powered platform with the capability to extend with new ideas as they come. It probably won’t have anything more fancy than a couple of wheels and some sensors, and if I get board, I may add a speaker to it as well. but right now all of that is just an idea, I’ve got to get my workstation back up so I can start drafting some designs and I’ll be ready to go.

    now I need a new mother board.

    ugh.  So I got my new power supply this weekend, and the good news is that it works perfectly. The bad news is, however, that my motherboard is apparently also fried.  Now comes the fun part, mobo shopping.  I hate shopping for a motherboard with a vicious passion.  First, I visit, my normal source for computer parts, and go to the mother board section.  awesome, now I just need to find a motherboard that meets all of the criteria I need.  first, let’s find one that has 4 RAM slots and is in the micro-atx form factor.  sweet, 3 pages of results, okay, now lets narrow that down to one that works with my almost out-dated processor, crap. only a small handful, all with crappy reviews.  So the search continues, I’ll get my box up and running eventually…