
My name is
David Robins:
Christian, lead developer (resume), writer, photographer, runner,
libertarian (voluntaryist),
and student.
This is also my son David Geoffrey Robins' site.
Using the Goodreads API
Technical ·Monday March 30, 2009 @ 23:51 EDT (link)
I was playing around with Goodreads' API. Their only example uses Ruby, which is way to schizo a language for my tastes. So I looked around on CPAN and found Net::OAuth, which I had some trouble with, but then I found OAuth::Lite, which was easier to use. OAuth is "an open protocol to allow secure API authorization in a simple and standard method from desktop and web applications." It's only necessary for calls that need to modify data; read-only requests just need a developer key.
I ended up using WWW::Mechanize (and WWW::Mechanize::Gzip) since I needed to do some screen-scraping, or thought I did. One thing I noticed when looking at the source is that Goodreads' site is much better organized (cleaner, better URLs, less badly-written Javascript) than weRead. I looked at the source of the Ruby OAuth module to find out about some defaults, and came up with this OAuth::Lite constructor call:
my $oalc = OAuth::Lite::Consumer->new(
consumer_key => YOUR KEY HERE,
consumer_secret => YOUR SECRET HERE,
site => 'http://www.goodreads.com',
request_token_path => '/oauth/request_token',
access_token_path => '/oauth/access_token',
authorize_path => '/oauth/authorize',
);
I had a lot of trouble since Goodreads was randomly failing my authentication attempts; first I thought it was timing out the access key really fast, or that I was sending invalid requests, but then I determined (through much experimentation, and showing that the same request can both fail and succeed) that it just randomly fails (401 Invalid OAuth Request, without a WWW-Authenticate header). When that happens, you just need to keep trying.
For the first (OAuth) request, you need to get a request token which can be parlayed into an access token:
my $reqt = $oalc->get_request_token;
my $url = $oalc->url_to_authorize(token => $reqt->token);
The user has to go to that URL and approve your application (if it's a web application, you can redirect them there and pass a callback URL for it to send the user to afterward). When it's approved, get an access token:
$oalc->get_access_token;
This token (available as $oalc->access_token) can be persisted (e.g. to a file or database: save the token and secret data) and then next time used to create a token to use to authenticate:
my $acct = OAuth::Lite::Token->new(token => $token, secret => $secret);
$oalc->access_token($acct);
Now you can make requests, using code like this, which returns a hash of information (id, link, name) about the current user:
sub get_user {
my $res = $oalc->request(url => 'http://www.goodreads.com/api/auth_user');
unless ($res->is_success) {
print "Failed to get user: ".$res->status_line."\n".$res->content."\n";
return;
}
my $u = $xs->parse_string($res->content)->{user}; # id, link, name
return $u;
}
Even after the first successful request, subsequent requests can randomly fail. I have no idea why this is happening; I've asked Goodreads in the developer forum and elsewhere, but they aren't saying anything, although they were very helpful with some other requests, e.g. documenting some undocumented functionality for adding a read date to a review.
Ways to starve the beast
Political ·Monday March 30, 2009 @ 22:15 EDT (link)
The beast is, of course, the Federal government. As tax time approaches, this CLAMS conversation is apropos and possibly even instructive.
KM: You actually believe Obama wants to reduce the deficit? I think you are all delusional if that's the case.
Obama wants to increase the size and scope of government, no matter the costs. The more problems that government can create, and that liberals and their media lapdogs can attribute to other causes, the more people will think that they NEED the government to get more involved. I completely believe that the complete and utter devaluation of our economy is the goal here.
JD: The only way to kill this snake is to cut off its air supply. Stop giving the government money, and it will fail more quickly and we can rebuild.
You can't have a Phoenix without Ashes, time to ash the joint.
LC: That would be a lot easier if taxes were not withheld from our paychecks to sustain the beast!!
HD: There are a couple of ways to do this:
- Take less money as pay and use other systems to supplement income. Barter and trade is not taxed (yet). Maybe have an employer pay you less but they buy you stuff or pay for services.
- Being efficient. Sometimes can be associated with being green. The car driving reductions and gas usage reduction are great examples. Being efficient means less driving, less waste and less resource uses… so less taxes. Less taxes means less power. Every transaction you don't make means less money for the state.
- Borrow. There are plenty of borrow sites for tools and equipment. You don't have to buy a saw, you can join a borrowing co-op and swap items. Members submit items they have and they are checked out by other members then returned when done.
- Always vote against any government increase if possible regardless of the altruism. There is no altruism; it's just government trying to increase its scope and control, and buy votes.
- Figure out ways to eliminate any government job by avoiding government services. This is called "counter economics". essentially use or provide services that make the government useless, redundant, unnecessary and more expensive. For example, don't use the city garbage service, take garbage to the dump yourself. Don't use the schools. Don't use the post office to mail letters (email or use a private service like UPS). Don't use public transportation. Anything you can do to bypass public services works.
- Vote to deregulate everything even if it drives you nuts. Regulation requires money, power and adds legitimacy to government. Every opportunity you have to strip government of power robs it of control, money and legitimacy.
- Always owe the government in taxes. Don't over pay. States are now lobbying to keep over payments.
"Tell him I forgive him"
News, Theology ·Monday March 30, 2009 @ 00:59 EDT (link)
A couple of stories about Christians persecuted for their faith.
Heartbreaking testimony of a Christian survivor of Lebanon's Muslim takeover (video). A Lebanese Christian talks about how Lebanon went from a Christian nation to a Muslim majority nation through multiculturalism, open borders, unrestricted immigration, and unspeakable violence (StumbleUpon).
Back in November, a Christian in San Francisco's Castro (majority homosexual—not prejudice, just fact) district was attacked by a gay activist while she was with a Christian music group. She said, "Tell him I forgive him".
First time cleaning the AR-15
News ·Sunday March 29, 2009 @ 21:53 EDT (link)
I finished cleaning my AR-15 for the first time today, using the Rock River Arms manual and these guides (there is also an AR15.com guide, but it's not as good, since it has small black and white diagrams and terse descriptions instead of large photos and detailed instructions).
Since it was the first time, it went somewhat slowly, but it's actually pretty easy: remove the takedown pin (or both), remove the charging handle and bolt carrier, disassemble the bolt carrier (by removing the cotter pin (firing pin retaining pin) and bolt cam pin), clean everything with solvent, clean the chamber with my pistol rod and chamber brush, and clean the bore with my rifle rod, alternating jag with patch and bore brush. I had to cut down my 9mm (2"?) patches so they'd fit. Apparently I cleaned the gas piston rings a bit too vigorously, because when I went shooting with the Microsoft group on the weekend it failed to fire because they had been misaligned; fortunately KA was able to fix it (he took it apart then and there with his knife, unsurprisingly a lot faster and easier than someone doing it for the first time; it was educational).
The birth of liberty
Technical, Political ·Sunday March 29, 2009 @ 21:49 EDT (link)
On Friday (27th) I picked up the computer I'd ordered from Hard Drives Northwest. I tried to install (Gentoo) Linux on it; it failed the same as the Costco machine.
I eventually figured out why it won't boot (VFS: cannot open root device): it needed SCSI disk to be enabled (for a SATA drive; apparently libata uses SCSI); kernel option CONFIG_BLK_DEV_SD. As I understand it (documentation is a bit scarce; the libATA Developer's Guide was somewhat helpful), libATA implements the ATA standard and translates to the SCSI command set, which allows the use of various low-level transports such as SATA and SCSI.
The new machine will be named liberty—in hope that liberty will return to this nation: that the grassroots efforts by the Campaign for Liberty, the tax protest tea parties, the various conservative and libertarian discussion groups and book clubs and the groundswell of support to overthrow creeping socialism, to fight the liberal fascism of the left, will triumph and return freedom to these United States of America. It's a grand aspiration: but these are interesting times, ripe for revolution.
Facebook chat + multiple tabs = dead CPU
Technical, Political ·Saturday March 28, 2009 @ 20:13 EDT (link)
Does it have to open the chat window in every tab? Argh. It slows Firefox to a crawl even with as few as 5 (Facebook) tabs open. It must be doing a lot of fast polling—maybe they should switch to long polling, or perhaps they are, but Firefox isn't very efficient at it.
Short Answers to Tough Questions (Libertarian Party of Minnesota FAQ). (They had "principal" for "principle" once, in "Party of princple"; I dropped a line to the webmaster and he fixed it up.)
"You cannot multiply wealth by dividing it"
Political ·Saturday March 28, 2009 @ 03:36 EDT (link)
You cannot legislate the poor into freedom by legislating the wealthy out of freedom. What one person receives without working for, another person must work for without receiving. The government cannot give to anybody anything that the government does not first take from somebody else. When half of the people get the idea that they do not have to work because the other half is going to take care of them, and when the other half gets the idea that it does no good to work because somebody else is going to get what they work for, that my dear friend, is about the end of any nation. You cannot multiply wealth by dividing it.
—Dr. Adrian Rogers (1931-2005)
Dr. Rogers was the senior pastor at Bellevue Baptist Church, down the road from where we used to live in Cordova, Tennessee (east of Memphis, off I-40 at exit 15B).
DVDs finished: M*A*S*H: Season Six.
From my cold, dead hands…
Political, Guns ·Friday March 27, 2009 @ 21:32 EDT (link)
Erich von Holder is trying to use the chaos in Mexico to erode gun rights. Liberals never let a crisis go to waste.
Octopus Multi-User Chat
Technical ·Thursday March 26, 2009 @ 21:56 EDT (link)
Octopus Chat, my first Facebook (web) application, can communicate between users. It's not very polished—it uses user IDs instead of user names, for example, doesn't style the chat names, and doesn't do emoticons like standard 1:1 chat, but those are easy to fix. No link, because it's still private. Also, my server isn't equipped to handle the demand for a decent multi-user Facebook chat application—and the same goes for the other Facebook multi-user chat applications (either that, or they're so bad nobody wants to use them).
My test users and I tried it out, and Honey tested it, then our friend Chelsea tested it and it didn't work. Why? Internet Explorer. Argh. Same problem when I tried it on Internet Explorer locally, so at least it's reproducible, but debugging tools for IE are really poor (or really expensive). Seems I'll need to install Visual Studio to be able to debug and fix things. It may not be worth the effort… I learned how to build a Facebook (web) application (I'd already built a proof of concept desktop application), and do inter-user chat (although I'd like to find out if there's any way for Postgres to generate events on row insertions etc.; I suspect I'll probably need to use a stored procedure). (Update: Postgres can do events, using LISTEN and NOTIFY, although I may want to use a stored procedure to generate the events.)
Blog mocking parents obsessed with their kids discovered via LJ childfree: STFU, parents.
Peter F. Conrey Fine Photography
Photography ·Wednesday March 25, 2009 @ 22:07 EDT (link)
A guy I used to work with at Hilton in Memphis (and is still there), Peter Conrey, has started a photography business: Peter F. Conrey Fine Photography. He has some great shots on the site, which is very polished; take a look. The blog has some nice pictures of the snow in Memphis.
Internally, he's using the jQuery Javascript library, which seems to be the PHP of Javascript libraries (it's not as clean and consistent as Prototype, and they made some bad decisions early on that they have to live with now for backwards compatibility; as a Word developer, I can empathize). I suggested he provide width and height attributes for his thumbnails to make pages lay out faster.
At time of posting this (early April), his site is down; I hope it's only a temporary issue. The hosting company seems to be TW Telecom Holdings, Inc., headquartered in Littleton, CO, but with a Memphis presence.
I came across a SOAP programming article by Peter while trying to find out what was up with his domain. It's not bad, but why mess with the hulking horror that is SOAP when better alternatives like YAML, JSON, or XMLRPC exist?
<Previous 10 entries>