Work around I probably shouldn’t need

2008-06-24 00:39:16 PST

Tags: ,

I had to install amsn just so could video chat with a friend on MSN. Really? On the plus side, at least I could do it :)

Also, figured out how to use skype on Ubuntu. Skype really want /dev/dsp. And Ubuntu now uses pulseaudio. So basically if you've done anything with sound, Skype won't be able to get the sound. Which sucks. However, pulse audio ships with this handy utility 'pasuspender' which temporarily suspends pulse audio and it's lock on /dev/dsp. So to actually use skype

pasuspender skype

And skype can then seize and monopolize the sound card. So you can use it, but no other sound till you shut Skype down. So it's 2008 and we still can't share the sound card :/.

Mindstab Go AI competition status report

2008-06-22 11:02:17 PST

Tags: , , , ,

Well the Mindstab Go AI competition is really starting to heat up. You can watch the battles unfold over on the match page.

So far the only entered contenders are myself with "fink" and Rob with "RGB". He took an early lead for a while and was working towards beating our house bot, "Amigo" (found on the net, an old Go bot from the early 90s, was originally an Amiga gobot that was someone's PhD dissertation. It isn't super good, but it is fast), and making progress on that. I finally got some free time and have been working a ton in the last week and on friday got my bot up to a point where it could beat his, and thus took the lead. Now with some actual competition the two of use are both hacking away at a good pace and he's retaken the lead for now but neither of use can quite best Amigo yet.

I'm also pretty happy with myself as my entry is coded entirely in Lisp, and this is my first actual Lisp project. So things are sailing smoothly enough, and I'm also learning tons about Lisp. Also, I'm crediting the high level power of Lisp with letting me do more interesting things easily, which I'm going to attribute to the fact that my bot runs at usually 1/3 to 1/2 the time Rob's does, even when beating it, and his is written in C. So when it comes to thinking about optimizing, it seems algorithms are a lot more important than the speed of the language implementing it, and a language that lets you more easily use more complex algorithms is possibly better. We'll see though once everything is all said and done .

We're hoping a few of the other people who have expressed interest will soon get enough code together to join the competition, and we're always looking for more interested people. The more the merrier!

Lisp (SBCL) on Hardened Gentoo

2008-06-20 23:07:16 PST

Tags: , , , , ,

My server, mindstab.net, runs Hardened Gentoo. I like it. It provides nice features from grsecurity and PaX like memory randomization, non executable writable memory, etc. However, it really doesn't get along so well with Lisp. Lisp in general seems to like executable and writable memory, and SBCL at least also doesn't like randomized memory. So it took a bit of work to get Lisp onto my server.

Approach 1: Failure
I spent a bunch of time trying to patch the build process in portage to coax SBCL into building. First, of course, I used gcc-config to disable the hardened gcc profile, and just use the vanilla one. Then I created a suid root shell script to call "paxctl -m -p -r -e $1" so that the sandboxed build process could disable PaX features on the SBCL binaries. I added the command to the ebuild, and created a patch to insert the command into SBCL's build process. The process goes like this, portage download's the SBCL source and a pre-compiled SBCL binary. The patched ebuild then calls my suid root script which disables PaX on the pre-compiled binary so it actually runs (as opposed to crashing under PaX) and then a new SBCL binary is built from the source and the pre-compiled binary builds a core file from the SBCL lisp source. The patched SBCL make.sh then again calls the suid root script on the new binary, so it will run. Then it should load the new core and recompile the system for itself. Sadly, while it runs at least, it chokes on the core file and hangs while using 100% cpu. I couldn't get past this so I eventually gave up. If anyone has any suggestions that'd be great.

Approach 2: Success
So the actually solution was as follows: Download the most recent precompiled SBCL binary from the website (1.0.15 for x86), run "paxctl -p -e -m -r -x -s " on src/runtime/sbcl (to cover all the bases). Then run "sh install.sh" to install SBCL to /usr/local. That's it.

The problem with this is you can't emerge lisp packages in portage, you have to install them by hand (unless maybe you want to fake inject the package into the portage database).

I downloaded a copy of slime, untarred it and popped it in my .emacs and I had a full lisp environment ready to go, and on my hardened machine no less. Not so bad.

Re: A Timeless, Desert Island Language

2008-06-04 21:01:56 PST

Tags: , , ,

You know, dear internet, I'm very impressionable some times. Anyways, I was leafing through my feeds when I found this neat blog post by fellow name Dave Roberts, entitled A Timeless, Desert Island Language in my Planet Lisp section. And it's a quick neat fun read, with a conclusion you might not expect.

And if you read it, you'll probably be able to predict what shinny new idea/project has caught my attention, especially if you were already familiar with my kink for computer languages.

I want to find some time to take a quick stab at writing a simple Lisp interpreter!

Turning your laptop into a wired to wireless router for your wirelessly challenged friends

2008-05-25 12:23:29 PST

Tags: , , ,

Say you're at a party and the only internet is a wireless router and for whatever reason, no one can plug into it. Wireless internet only. You with your fancy laptop are sitting pretty and this is just fine. They your friend shows up lugging his clunky old desktop that only has an ethernet port for internet connectivity. Is he out of luck? Turns out not, because you an come to the rescue!

It's really easy, especially with Ubuntu.

To start with, you need to be a router, so you need firewall software that can do NAT (network address translation). This is part kernel side (NAT and iptables options enabled and modules loaded) and part user space side, in the form of the program 'iptables', so make sure it is installed, which it is by default on Ubuntu (I think).

Now all you really need to do is add two routing rules, one says anything coming on the ethernet port should go through the NAT procedure, which basically means it's IP headers are tweaked to make it look like they originated from your computer and then you send them along to the internet. The second rule helps facilitate this (I'm a little less sure what it does, but it's needed).

In this case we are assuming the interface eth0 is the wired network and eth1 is the wireless. Change as required.

iptables --table nat --append POSTROUTING --out-interface eth1 -j MASQUERADE
iptables --append FORWARD --in-interface eth0 -j ACCEPT

Next you just need to tell the kernel port forwarding should be turned on, and you can do this through the wonderful /proc filesystem.

echo 1  > /proc/sys/net/ipv4/ip_forward

Now you're pretty much ready to go. Connect to the wireless, presumably though NetworkManager or your wireless toll of choice. Then enable the wired network manually.

ifconfig eth0 up 192.168.1.1

This turns on eth0 with a local network address of 192.168.1.1. Now plug your friend's computer into the ehternet port with a crossover ethernet cable or into a hub and then the hub into you with regular ethernet cable and have them manually pick an address on 192.168.1.* (or whatever local network you chose, it doesn't matter) and set you (192.168.1.1) as the gateway router.

If this is a little much for them or they are running an OS that makes this non trivial, than its really another easy step for you to set up a DHCP server and do all the configuration for them :).

So install dhcpd, on Ubuntu it's 'dhcp3-server', on Gentoo I think it's just 'dhcpd'.

Now we have to configure it. We have to tell it the gateway router, which is us (192.168.1.1), the nameservers (the servers in /etc/resolv.conf) and the pool of IPs to use and what interface/network to listen on.

Open the config file, on Ubuntu '/etc/dhcp3dhcpd.conf'.

The relevant parts are as follows

...
# servers in /etc/resolv.conf
option domain-name-servers 192.168.0.1;

...

# the local network you created
subnet 192.168.1.0 netmask 255.255.255.0 {
        #IPs free to assign
        range 192.168.1.100 192.168.1.200;
        #your computer, the router
        option routers 192.168.1.1;
}

And that's it. (Re)Start the server

/etc/init.d/dhcp3-server restart

And you are now serving all the information your friend's computer will need to automatically connect properly.

They should now be online once they restart their internet connection.

One annoying thing about Ubuntu vs Gentoo is that on Ubuntu, the init system is a bit more kludgy and old fashioned. Any server software installed is automatically configured to start at boot time, forever, which in this case isn't what you want. You only want the dhcpd server to run very rarely, at parties, the rest of the time it's a waste. So we need to turn it's auto starting off. Apparently the /ubuntu init system barely supports this, we have to force it.

update-rc.d -f dhcp3-server remove

Now just turn it on when you need with its init.d file.

I can hear birds chirping out …

2008-05-24 02:54:10 PST

I can hear birds chirping out the window at the morning as i go to bed

Adventures with Ubuntu and XP and the family computer

2008-05-17 12:54:46 PST

Tags: , , , ,

So my folks Windows XP box started having difficulty booting. Most of the time it would go to boot and suddenly you'd be back at the BIOS, then the "Windows didn't shutdown properly last time" menu and then once you selected "boot normally" the cycle would begin again. Usually eventually you'd get lucky and Windows would boot (but sometimes they gave up first). Not good. This started a while ago and seemed to get worse (I think, I never use the box so I don't know). Anyways, eventually they figured (hoped actually because otherwise it was hardware failure) that their XP install was corrupted and asked me to reinstall Windows for them.

They gave me the CD that came with the box and I loaded it up and first things first, no harddrive detected. Yep, that's right, no harddrive. To be fair, XP is old, it's from 2001, and pretty much all computers come with SATA harddrives now, which didn't even exist in 2001, so it's not entirely fair to expect XP to support them. This is one of the downsides of only doing releases every 6 years. Being not terribly invested in this "install XP" project I tossed my hands up and said it's a no go and offered Linux as an alternative. My Dad was definitely interested in Linux but wasn't sure it would be all there for his business software, so I said, "no fear, let's just do a trial run, and if it doesn't work, no worries, you can, you know, always buy Vista". The thought of having to spend money to make a computer that did work, work again, for no good reason vs. the low commitment of a trail run sold him on the project.

So I burned a copy of Hardy Heron, the newest Version of Ubuntu, released just last month. It loaded up and recognized all the hardware and installed, no trouble. I'm old fashioned so I opted for a separate root and home partition, but other than that, a vanilla install. Then we booted up and everything just worked out of the box. Even the printer. So I loaded all their data on from one of my boxs from whence it had been backuped to and let them at it (after a few tweaks, like my mom's desktop).

fuzzybear

The results?

Mom loved it. For her, it turns out the killer feature was desktop icon stretching. She really liked the larger icons. And of course, no difficulty using it for her normal uses which are nearly entirely Internet look ups. The other big hit was Eye of Gnome, the photo viewer. Last year we had about 1600 of my mom's parents family slides turned into digital photos (at no small cost) and the stock Gnome photo viewer is perfect and intuitive enough for her to use and enjoy (the newly added left right buttons to scroll a directory are crucial here, so good work guys).

My moved out sister dropped by and gave it a try, and she too was sold. For her, the large stock puzzle/games selection was the seller. It worked just fine for her net usage, but the large selection of games got her attention and kept it just on introduction for over half an hour and she only explored a few of the games in that time. She'll be back. She also was amused by compiz eye candy.

As for my Dad? Sadly neither of his business apps worked under Wine. Maximizer 8 failed to install (a little sad since it's reasonably popular and not so new) and D--------, which is from what I can gather an in house piece of software from his company, also failed to install. A few tales from his trials installing it under Windows were horrific thought, like for the first time install you are required to turn off the firewall. 0_o In house software can be scary and shoddy stuff.

So Linux failed to satisfy everyone of my family's needs, so back to Windows. I was disappointed but resigned. And then came mom to the rescue. She chimed in she didn't want to go back. She liked her new Ubuntu desktop! So that was all I needed to float the idea of dual-boot. And thankfully we had two partitions already. Dad was sold too. He does want to learn more about Linux and so looked forward to the opportunity, but also needs his business software.

So I popped in a Gentoo LiveCD, because there really is no better system recovery and maintenance CD than a Gentoo LiveCD. I copied the Ubuntu root over to the second partition, moved /home and edited fstab and grub/menu.lst and reinstalled grub (from within the Ubuntu chroot because the one thing that particular LiveCD was 'missing' was Grub) and then changed the partition type of the first partition from Linux to NTFS and volia, we were ready to go.

Then back to Ubuntu because the Gnome Device Manager is actually full of awesome and gave me all the hardware information I needed so that I could get the appropriate drivers for Windows (remember when it was the reverse and it was crucial to go into Windows System Manager to get all the hardware info so Linux could install?). Then off to the net to find the Sata drivers, and then I tossed those onto a floppy disk and tried the XP install again. Sure enough, after loading the drivers from the disk, XP install found the harddrive and was happy enough to install onto the partition I had marked for it.

Then it booted into Windows XP SP1 glory. Which was surprisingly not glorious because it had no drivers so we had a 640x480 low colour screen with no sound. And no programs. Dad and I spent the rest of that day and the next few after that running Windows Update and downloading and installing drivers and programs manually from the net. The Windows Update website actually pretty much continually stalled out and failed when it came time to get service pack 2 which was disconcerting but by then the update manager had been installed and it was able to get and install SP2 for us. Shortly after which my dad horrifyingly noticed the Windows booting bug was back! We were horrified. All this work and no fix? Was it hardware failure? But Ubuntu was still booting fine. So we kept at it and apparently now with SP3 installed it's gone back to booting normally.

So yes, that means Microsoft in one of their post SP2 updates introduced some bug that rendered our computer nearly unbootable, which drove us to Linux which was brain dead easy to install. And then when we discovered Linux didn't quite fulfill all our needs, they made the migration back to XP as painful and full of near hopeless despair as possible.

So thank you Microsoft for driving my family to try Linux because they've found they like it, and thank you after that for highlighting exactly why we don't want to be hooked on Windows. It's been educational for my family, and now ever computer in my house has Linux installed on it and my family is interested in learning about it! And I owe it all to Microsoft.

(It should be pointed out that my dad's work still has a ban on IE7 and Vista because it doesn't work with their software yet which is a mark against both Microsoft and Vista, and my dad's company's computer department because, lets face it, it is the future and it has been out for over a year. But this did mean Vista really wasn't a viable option on the fact that it would have cost us more money and it wouldn't have accomplished the one goal we needed it for, which was running my dad's business software. XP was our only option.)

Emacs and Slime highlight changes and how to control it

2008-05-14 18:23:26 PST

Tags: , ,

Massive thanks to durka on #lisp on irc.freenode.net.
New versions of slime for emacs have had enabled by default a new feature, essentially a light highlighting of uncompiled changes to a file. At first I found it annoying but then I got used to it. It is kind of handy. However I wouldn't find out how to turn it on or off. Oh well.

Then I went to use emacs on the console and the subtle light grey background highlight was suddenly grey text on a white background and completely unreadable. Very annoying, suddenly this little feature rendered -nox emacs useless.

Hours of google searching turned up nothing so finally I resorted to the irc channel. In only 10 minutes we got the answer.

<durka> aha
 customize emacs - applications - slime - slime mode - slime mode faces
 change highlight edits face

Thank you.

Mindstab Go AI competition really starting now

2008-05-10 02:10:44 PST

Tags: , , , ,

Ok, so I know we announced it at around Christmas, but *now* the Mindstab AI Go Competition is starting to get under way. Both Rob and I now have entries that can compete, though mine is mostly just an over engineered random bot, until I get even more framework in place.
Still, everything has really started happening this week as now that school is over, I've had some time to devote to this, so my bot finally got off the ground. And then we got together to day and hacked on the server some more cleaning it up, and making an 0.2 release of out Go client/server software.
Finally, and most fun, we whipped together a Matchs page where you can see all the results of games so far. See, real proof that things are happening!
So with this out of the way I can really start to focus on the bot. To that end I've defiantly come up against some quicks in Lisp and SBCL. But then today we were also working in C, Python and PHP and we certainly came up against some quirks in the first two (oddly PHP really does manage to get out of your way and let you do your thing). Still, I think I have things mostly worked out and I can focus on the bot. Which is fun because I'm finding for the most part I'm really enjoying coding in Lisp and Slime+Emacs is pretty rocking. As for the bot, I'm excited. I've got some fun plans for it and I haven't done nearly enough fun coding since school's been on.

Note for C developers on Ubuntu

2008-05-09 11:57:13 PST

Tags: , ,

Right, so when doing C development on Ubuntu I suddenly noticed something was missing in the pan pages department. Like all the C api.

apt-get install manpages-dev

ah that's better. Someone might want to make it part of the 'build-essentials' package.

Valid XHTML 1.0!
Valid CSS!
Mindstab.net is proudly powered by WordPress
Entries (RSS) and Comments (RSS).
16 queries. 0.503 seconds.