ryePDX

Adventures in technology

Getting the Compaq nx6125 Broadcom Wireless card to work in Ubuntu 11.10

I remember trying to get Ubuntu to work on my Compaq nx6125 my freshman year of college. The first and biggest hurdle was getting the wireless card to work. Recently, after a few OS changes, I decided to go back to Ubuntu for that machine. Imagine my dismay when I discovered the documentation on the process hadn’t changed much since my freshman year! Fortunately with a little digging I was able to find a much simpler process. If you’re trying to get your Broadcom card to work in Ubuntu 11.10 (and possibly earlier versions, for all I know), simply run:

sudo apt-get install firmware-b43-installer

And that’s it. Your wireless card should work.

Edit: If you’re not using Ubuntu and want to get your Broadcom 43xx wireless card to work in your particular flavor of Linux, you can find more documentation on the subject on this particular page of the Linux Wireless website. That’s where I discovered that handy little bit of command-line wizardry.

Building Opa in 32-bit Ubuntu 11.10

Heard of Opa? It’s a full web app stack by MLstate. It focuses on allowing developers to create highly scalable, highly interactive, rich web applications as easily as possible.

Here’s “Hello World” in Opa:
server = Server.one_page_server("Hello", ( -> <>Hello web</>))

And here’s a chat room in 20 ELOC:
import stdlib.themes.bootstrap

type message = {author: string /**The name of the author (arbitrary string)*/
; text: string /**Content entered by the user*/}

@publish room = Network.cloud("room"): Network.network(message)

user_update(x: message) =
line =
<div class="row line">
<div class="span2 columns user">{x.author}:</div>
<div class="span13 columns message">{x.text}</div>
</div>
do Dom.transform([#conversation +Dom.scroll_to_bottom(#conversation)

broadcast(author) =
text = Dom.get_value(#entry)
message = {~author ~text}
do Network.broadcast(message, room)
Dom.clear_value(#entry)

start() =
author = Random.string(8)
<div id="#conversation" class="container">Network.add_callback(user_update, room)}&gt;</div>
<div id="#footer">
<div class="container"><input id="#entry" class="xlarge" type="text" />broadcast(author)}/&gt;
<div class="btn primary" onclick="{_">broadcast(author)}&gt;Post</div>
</div>
</div>
server = Server.one_page_bundle("Chat",
[@static_resource_directory("resources")],
["resources/css.css"], start)

In Opa, the Javascript, HTML, and database models are all generated from the same code.

I was intrigued, so I decided to give it a spin. Unfortunately my laptop was running Ubuntu 11.04 on a 32-bit processor. At the time of this writing, the only binaries available are for 64-bit Linux or OS X. But I decided to try building from source anyway. Haven’t quite got it figured out yet, but I’ve made some progress! If anyone can help me out, that’d be great.

My steps so far:

  1. Update Ubuntu to 11.10 if you’re running an earlier version. Opa requires OCaml 3.12, but the latest version of OCaml in the 11.04 repositories is only 3.11.
  2. Install dependencies:
    sudo apt-get install ocaml libssl-ocaml-dev libcryptokit-ocaml-dev libzip-ocaml-dev libocamlgraph-ocaml-dev ocaml-ulex camlp4 camlp4-extra
  3. Download and decompress the Opa source package from Github.
    wget https://github.com/MLstate/opalang/tarball/master
    tar -xzf master
  4. Configure and build.
    cd MLstate-opalang*
    ./configure -ocamldir /usr/lib/ocaml
    make

And that’s as far as I’ve gotten so far. At that point I get the following error:

File "buildinfos/buildInfos.ml", line 14, characters 0-3:
Error: Syntax error
Command exited with code 2.
Failure:
No cache, no trx exe: sorry, cannot build libnet/http/request.ml from libnet/http/request.trx.
You may want to re-run with TRX_OVERRIDE set.
Compilation unsuccessful after building 521 targets (512 cached) in 00:00:04.
make: *** [all] Error 2

I intend to do some digging about to solve this issue. I’ll keep this post updated, so keep checking back.

Prolog in Python (pt. 1)

I’ve recently become enamored with the idea of querying a Prolog program with a MySQL database backend from a Python script. Specifically I want to create a Django web app that will allow a user to ask for the price of a thing in terms of anything else. Prolog seems like an excellent choice for the value-finding engine as value-finding in this case will mostly consist of finding a path of trade between two things. For example, in order to find the price of apples in terms of bananas, the value finding engine will first query its database to see if it already knows that off-hand. If it doesn’t, it then has to see what it does know about the price of apples and then see if anything it can trade apples for can then be traded for bananas. It has to keep branching out until it finally hits bananas.

I was able to complete a proof-of-concept value engine with just 9 lines of Prolog, minus comments.

The next step, of course, was to find a way to allow Python to call Prolog functors. As I was using SWI-Prolog, I downloaded PySWIP.

PySWIP is a simple gateway between the SWI-Prolog interpreter and Python. The project was briefly orphaned for a while and the project’s author is actively looking for another developer to take the reins, so I can’t recommend this as an enterprise-grade solution. However, it seemed that for my purposes it would work just fine.

PySWIP did not work right out of the box. I had SWI-Prolog 5.10.4 installed on my machine and the latest version that PySWIP supported at the time was 5.6.34. Running

from pyswip import Prolog

resulted in

libpl (shared) not found. Possible reasons:
1) SWI-Prolog not installed as a shared library. Install SWI-Prolog (5.6.34 works just fine)

Fortunately the fix was easy. After some Googling I surmised that the issue stemmed from the fact that libpl.dll had been renamed to swipl.dll in the versions after 5.6.34. Navigating to C:\Program Files\pl\bin and making a copy of swipl.dll named libpl.dll did the trick.

Here’s a little example of using an external Prolog program in Python.

from pyswip import Prolog

prolog = Prolog()

prolog.consult("appraise.pl")

# A couple preliminary assertions.
prolog.assertz("value(banana, 1 rdiv 4, bitcoin)")
prolog.assertz("value(bitcoin, 1 rdiv 30, namecoin)")
prolog.assertz("value(apple, 3 rdiv 4, banana)")
prolog.assertz("value(orange, 1 rdiv 5, apple)")

# Now, how much is an orange worth in bitcoins?
result = prolog.query("appraise_float(orange, Price, bitcoin)").next()
print "An orange is worth %s bitcoins." % result["Price"]

# And how much is a bitcoin worth in apples?
result = prolog.query("appraise_float(bitcoin, Price, apple)").next()
print "A bitcoin is worth %s apples." % result["Price"]

Running this results in

An orange is worth 0.0375 bitcoins.
A bitcoin is worth 5.33333333333 apples.

Next up: Prolog/MySQL integration.

Bitcoins: A rebuttal to Tim Fernholz

Tim Fernholz:

This is one of the worst-written articles about Bitcoin I’ve read so far. Certainly not worthy of your publication’s name. If you don’t understand something, don’t write about it. :-p

Your description of mining is so broken I’m not even going to try to fix it. Just do some more reading of low-level descriptions until you understand how very wrong your description of miners as “decoders” is.

“…it’s a massive experiment in group trust.”
Bitcoin is far from an experiment in group trust. It’s guiding principle is *distrust* of everything but the copy of the block chain residing on your own hard drive. Your statement seems to find its roots in your ignorance of the network’s mechanics.

“That’s a crazy amount of money to have stolen…”
Yep, that’s a lot of money to have stolen. The moral of the story is that if you have over a quarter of a million dollars worth of bitcoins sitting on your hard drive, *take some steps to secure them!* This is new ground for most people, but honestly it’s nothing that can’t be learned. To help the everyman, wallets will likely be encrypted and password protected in future versions of the Bitcoin client.

“Bitcoin is a libertarian’s dream come true…”
Not just a dream come true for libertarians. Also a dream come true for anyone who has ever pined for a convenient, politically neutral international currency, or an easy, cheap way of engaging in micro-transactions.

“So far, you can’t buy anything with bitcoins that you couldn’t purchase more easily with cash or a credit card.”
Aside from anything your government or credit card processor (assuming the vendor isn’t close enough for a physical cash transaction) doesn’t want you buying, that is. Most American citizens probably won’t care much about this one, save for all the folks who’ve had their PayPal accounts frozen at one point or another, or all those folks who support privately embargoed organizations like Wikileaks.

“…major exchanges like MtGox have fallen to hackers.”
The theft of $1,000 USD due to a *financial auditor’s* gaffe is hardly grounds for declaring Mt. Gox “fallen to hackers.” Also, can you point out to me one other exchange that has been similarly compromised? Because you’re using the plural, which implies there was more than one. Oh, there wasn’t? You mean you got your facts wrong *again?* Oh snap! :-p

“…the system presents a huge opportunity for big fish to take advantage of the Internet everyman.”
You’re right, the central banking system is WAY better. Those bankers are so honest and adept at managing our money! They would NEVER take bonuses using taxpayer money right after tanking the global economy. SO much fairer.

Should I beat you over the head with that one some more, or do you get it? :-p

“…Bitcoin won’t work because it accrues such a huge advantage to people who can bring the most computing power to bear on clearing transactions.”
You mean kinda like credit card companies? Herp derp.

” If any single person or group controlled a majority of computing power in the network…”
…they could have hacked your bank account a long time ago.

“It’s hard to trust a monetary system concocted and managed by anonymous hackers…”
Not really managed by them. If anyone deviates from the network’s protocol, they isolate themselves from the network. The official client gets pretty features added to it every once in a while by a guy named Gavin Andresen and five other developers, of whom only Satoshi is anonymous, to help out herp derps like yourself, but the essential elements never change. Although there *is* a continuous stream of essentially anonymous code auditors who spend their spare time reading the client’s source code on the project’s Github page. Perhaps those were the “anonymous hackers” you’re talking about?

Or maybe it’s the guys running Mt. Gox. You know, the same ones whose security was compromised because they were trying to comply with government regulations and the freaking financial auditor ended up having a freaking virus on his system. Those guys are ano– oh wait, it’s run by K.K. Tibanne Co, a totally legitimate Japanese company.

To be fair, there are a lot of tiny garage startups that make up a good portion of the rest of the Bitcoin economy. I’d say that’s a good thing, though: I’ve never heard anyone complain about an economy having too many startups, or too much innovation, or too many opportunities. It’s ultimately an indication of the innovation and further democratization of the global economy that Bitcoin encourages.

“Bitcoin still offers a glimpse of a future in which the dollar is digitized…”
Oh, cool. So right after complaining about the pitfalls of a digital currency (“that’s a crazy amount of money to have stolen by someone essentially copying a file from your hard drive,” remember?) you’re then going to advocate a system that not only has THOSE pitfalls, but also the pitfalls of our current centralized banking system. Awesome. Well done. Herp to the friggin’ derp.

Idea

Here’s an idea I would like to play with if only I had more time. If anyone out there is interested and decides to play with it, or if you want to pick my brain, tell me.

I was thinking about the shortage of programmers and tech workers and the shortage of most other kinds of employment these days. It seems to me that if good technical education were more accessible, a lot of people would be a lot better off.

So why not create a system to automate the education of people in programming? That would be the easiest: teaching people how to program automatically. Just set up online lessons with live teachers at first. Have an “ideal” solution for each assignment. Let the teacher grade projects by hand at first.

As the teacher teaches and grades, let there be an algorithm monitoring and recording all the questions and answers students ask during and after lectures. Let it also record the errors made in assignments and the teacher’s notes when corrections are made. Let the algorithm suggest responses to the teacher based on past answers given. Let students directly question the algorithm for information given in response to questions during and after lessons, and for questions regarding assignments they’ve already completed.

Eventually the algorithm would be able to take over the teaching of most of the classes. Students should be encouraged to help each other after each lesson as well, to answer questions the algorithm could not. These too could be used to enhance the algorithm, though they would need to be screened for appropriateness.

The project should be supported by donations and volunteers. Those who graduate from the program in particular should be encouraged to help the new students that come after them. This could mean participating in after-lesson talks or simply responding to questions the algorithm can’t answer yet.

Lifestreaming

Boy, has it been a busy last couple months! I got a job at a startup so that’s consuming my life. The rock tour never took off, though I did end up going to Canada. Now I have a few seconds before I run off to participate in my writer’s group.

I’m starting up the first bits of the Lifestream project. To keep from annoying people too much, I’m relegating it all to certain channels. The first channel is up:

http://twitter.com/ryanslifestream

Check it out.

Ciao!

Microsoft kills the Courier

Behold, Microsoft hath declared the Courier dead:

http://www.engadget.com/2010/04/29/microsoft-confirms-kills-courier-in-one-fell-swoop/

This means that part of my plan for lifestreaming is no more. Still, I’m pretty sure I can find a way to work around it…

More news to come… sometime.

Keeping PEAR HTTP_Client session data across pages

I just spent three hours banging my head against this problem, so I hope I can save you the trouble if you’re where I was.

I was trying to save an HTTP_Client object in a PHP session so that it would maintain its session data as it got moved from page to page. The idea was to log into a website with it and then go to another page where it would be used by various PHP scripts called by AJAX to perform tasks on the website I’d logged into. The only problem: I was getting logged out of the ‘site every time I left the script which logged me in. Somehow the HTTP_Client’s session data was being lost simply by my storing it in $_SESSION.

I made sure I was serializing and unserializing:

$_SESSION['client'] = serialize($client);
...
$client = unserialize($_SESSION['client']);

Still nothing. I scoured the Internet for people who were having similar problems. The only thing anybody could tell me was “are you remembering to serialize and unserialize?” I scoured the pitifully scant documentation on pear.php.net, trying to glean some shred of insight.

Still nothing.

So I decided to brute force the thing and trace the HTTP_Client’s code by hand. After mangling my beautiful PEAR classes with debug code, I noticed line 78 of CookieManager.php:

function HTTP_Client_CookieManager($serializeSession = false)

“Wait, a minute,” I thought, “you’ve got to be kidding me.” I changed that sucker to:

function HTTP_Client_CookieManager($serializeSession = true)

And it worked!

Now before you go hacking your PEAR modules, here’s the *right* way to do it:

$manager = new HTTP_Client_CookieManager(true);
$client = new HTTP_Client(null, null, $manager);

Roll Your Own Shoestring Rock Tour

Well, I’ve done it. I’ve broken the whole “responsible” path I’ve been hellbent on since I was a youth. I’m going on a rock tour across the USA with my band this summer. Sleeping on couches, eating on just $4 a day… oh this is going to be good. :-)

You can keep updated on my adventures as we plan this thing out and finally carry it through to execution at http://shoestringtour.blogspot.com

Life streaming and ryepdx.com

I was reading a few tech articles today and watching some cool videos when I realized I consume way more tech knowledge than I disseminate. I started thinking about whether it would be possible to disseminate as I learn, whether I could expedite that process. This converged with what I’d been reading about (data rot and the loss of historical artifacts to neglectful storage techniques) and an idea that has been tugging at the corners of my mind since I was in grade school: personal historical documentation, the idea that my experiences and environment could be preserved indefinitely for the benefit of future historians. On top of all this I encountered an article last night about “life streaming.” It talked about Storytlr which, as far as I could tell from the brief glance I gave it last night, amounted more or less to a feed aggregator.

My long shift in the CS lab was today and I forgot to bring the charger for my laptop. I started playing on the whiteboard instead and this is what I came up with:

Life streaming

  • Phase 1 – the immediately achievable
    • Browser plugin for Chrome & Firefox (my browsers of choice) which tweets and social bookmarks pages I like at the press of a button. Option to comment as I share. Tweets should be tagged with “#visited” or something. (I have a feeling this functionality might already be out there, but I’ll have to check.)

      Also allow for the upload of the set (i.e, no duplicate URLs) of my browser’s history at the end of the day, minus all my visits to Gmail and Facebook.

    • Use Shazaam and my laptop’s microphone to automatically tweet what I’m listening to. (Tagged with “#listening_to”)
    • Publicly accessible SVN repository (or at least a public folder) for non-proprietary code I’m working on. Integration with Drupal (or Storytlr, if I make the switch), maybe with TRAC or SourceForge as a middleman for categorization and ease of use purposes.
    • SVN for written works, possibly with “time travel” slider in a Drupal/Storytlr module.
       
  • Phase 2 – the possible future:
    • Integration with the soon-to-be-released Courier to allow you to flip through anything I write in that particular notebook.
    • Armband/glasses cam and mic with “point of interest” button to mark video data for expediting/automating the creation and upload of video blogs.
       
  • Phase 3 – the future fantastic:
    • Shazaam integration with armband/glasses for real-time and portable “what I’m listening to” data.
    • Add GPS to armband/glasses to record location information. Could be used to automatically create 3D models of surroundings via PhotoCity-like software.
    • Book recognition via cover (front or back, image recognition or ISBN extraction) or example text extrapolated from image via OCR and identified via Google Books. Could allow automation/expediting of a “What I’m Reading” function.
    • Speech recognition in armband/glasses for on-the-fly (if possible) creation of todo lists and appointments.
    • Movie recognition for “What I’m Watching” feature.
       
  • Notes
    • Twitter to be used as an event alert service, using hash tags for categorization. (i.e, #read, #wrote, #coded, #updated, etc.)
    • Organizing all the data which will be produced may prove to be an enormous challenge, especially as life streaming gets smarter. A way to zoom in and out to various levels of detail may be useful, as would some kind of search engine capable of handling multimedia information.