Friday, January 9, 2009

Atheros AR928x and Ubuntu

Ok - so school is waaay more time consuming than I thought / I'm lazier than I like to admit, and I haven't updated this in ever, as you can see.

However, I just spent forever trying to get ubuntu working with my Atheros AR928x wireless card. Here's the secret... just add these two lines to your "/etc/rc.local" file:
echo 0 > /sys/devices/platform/asus-laptop/bluetooth # disable bluetooth
echo 1 > /sys/devices/platform/asus-laptop/wlan # enable wireless
I found this posted on a forum somewhere, however I was browsing on another computer at that time, and I can't find the post any more. If someone wants to take credit for this, they can have it. I'm just glad it finally works! :)

TaaDaa!

Friday, August 1, 2008

Require a Directory

I've started learning Ruby. This being my first post here I guess I should tell you all that I'm basically a C# developer, with a bit of Java. I had the good fortune to learn some Smalltalk from a co-worker and half-built an application in it (the project was canceled). I haven't done much web development, but I'm planning on letting the Ruby learning take me there eventually. Last week I started reading Ruby tutorials, blogs, and documentation, playing with irb whenever I wanted to.

Today I started building my first program, and, coming from a Visual Studio background, was finding it really annoying to have to require each and every new class I made (I'm following the .NET one class per file convention - don't know if that's Ruby standard or not). So I Alt-Tabbed to Google (who really closes it?) and started learning about require. Apparently, it's just a statement like any other that can be executed from anywhere. Then I used the "ri" command to learn about the Dir.entries method, and well... came up with this file I'm finding quite convenient:

Behold 'requireDir.rb'!
#dropping this file in any directory and then requiring it
#(ie. typing "require 'DIR\requireDir')
#will require all files in the DIR directory

dir = File.expand_path(File.dirname(__FILE__))
Dir.entries(dir).select { |f| f =~ /.*\.rb/ }.each { |f| require File.join(dir, f) }
The code comments explain what it does. I don't know if there's a better way to do this, or reasons I shouldn't do this. Like I said, I'm brand new to Ruby, but I thought it was cool how easy it was to make something like this. I figure it shouldn't be hard to make recursive either, if I want to later on.

Oh - and if you're wondering how I posted the code like that in that nice little scrollable window... it took me 20 minutes Googling. If you don't have that much time, just click here. :)