Friday, May 20, 2011

My foray into Quantified Self research

So this is really cool - with the advent of the high speed internet in your pocket smartphone, everybody can do their own quantified self research with ease and convenience. Forget apps, it's even simpler than that. Just make a google docs form . You can choose anything about yourself that you want to track - for instance, say water intake. You can make a form that has inputs (type of your choosing - check box, radio button, text, etc) corresponding to what you want to track. Every time anybody fills out the form, a line will be added to a google docs spreadsheet with the info that they filled out.
The trick here is, give yourself and no one else the url for your form. Bookmark it on your smartphone. Fill it out all day long, whenever appropriate. I've been tracking all my bodily inputs and outputs, as well as mood, sleep habits, and a couple other things. I generate about 10 or 15 lines on the spreadsheet a day. The form takes about 15 seconds to fill out, which I do during downtime (like while I'm peeing...).
At the end of the month, I'll have more than 400 datapoints. Since it's in a spreadsheet already, no extra tabulation is necessary. As long as you design your form/spreadsheet combo with some insight, you'll be able to learn things about yourself that you never knew before.

Friday, May 6, 2011

Internet exasperations

this one is like a 9 on the facepalm scale. Inexplicably, certain wireless networks (especially dsl and 4g) seem to work, but gradually stop connecting very often, throwing up network errors (could not load variety) on my browser, but then connecting again (quickly, even) after a couple attempts.
I thought I might have just made it better by switching to google's dns servers, but I'm not actually sure it's helped yet.
Note, of course, that I'm using wicd on ubuntu 11 (not network-manager, which was actually catastrophically freezing my computer once in a while).
ideas?

--edit:
Wow, looking back, realized I never shared my solution: turns out certain dell wireless cards have a problem with wireless standard n, but not g. wish I had all the appropriate linkage and help at my fingertips, but if you find this post, that should get you started. I disabled N for my card, and everything is fine (albeit slower than need be). Who knows, mayhap it be fixed by now. I don't remember how I disabled it, and I probably don't need to think about this whole issue anymore.

Sunday, May 1, 2011

Rails 3 Unobtrusive Javascript is Unintuitve

So what I wanted to do was link from a partial view to a controller method through a route which took a title parameter and from the controller method run a javascript file in order to append content to a div with a unique name defined by the title param.
In django it's pretty straightforward, but ruby on rails 3 had me scratching my head for a good long while.
Here's the solution, or at least the parts that were difficult:
the link:


<%= link_to "Comments", show_comments_path( :format => 'js', :comment_id=> session[:id] ), :remote => true %>
This whole :remote => true business tells rails 3 that this is an ajax call. The :format param does NOT get passed into the url, but DOES render the response as html, most of the time. Which is to say, rails will run the .js.erb file with the name matching your route.
Here's the route:
match 'show_comments/:comment_id', :to => 'deals#show_comments', :as => :show_comments
So first rails runs the show_comments method from the appropriate controller, which you can use to set state variables for the javascript. Then, whatever is in show_comments.js.erb will be run, and the current page will NOT be reloaded or redirected. No partial needed. No view needed. The controlling method will do all of this as the default return, so no return or render needed either, only the .js.erb file which has your prototype or jquery calls, or whathaveyou.
facepalms: 4 (steady, slow, only slightly infuriating progress)

Friday, April 29, 2011

more ubuntu fights

so I know I thought I fixed my virtualenv and virtualenvwrapper problems recently, but apt-get wasn't letting me install anything! This error:
Traceback (most recent call last):
File "", line 1, in
ImportError: No module named virtualenvwrapper.hook_loader
dpkg: error processing install-info (--configure):
subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
install-info


So it seemed like it had something to do with install-info, whatever that is, but NO - I'd forgotten about some lines in my /etc/environment file that had to do with virtualenv, before I started using .bashrc. took em out, all better.
facepalms: 2

Thursday, April 28, 2011

event data in jquery

this one stumped me for quite a bit. If you want to bind a click event to a div id in jquery to a preexisting function which takes arguments, you need:
$('#id').click({param: param}, function_to_run );

to bind it. Here, id is the id of the div or whatnot, param (the second one, the first one could be anything) is the variable you want to send, and the function_to_run is already written. No parens after the name, you're sending it as an object.

The tricky part is in the function itself:
function function_to_run(event) {
param = event.data.param;


get it? The click event sends the event itself as the one argument to function_to_run, and the parameters you give it are stored in data. just so you know.

around a 6 on the facepalm scale.

upgrading to ubuntu natty

annoyingness right off the bat. maybe a 7 on the facepalm scale.
1. the login screen allows you to choose between unity and classic, but only after you click the login name to get the password box out. before then, no indication of any possible choices on the bottom bar.
2. loaded up classic, but compiz settings were off.
3. my ATI graphics seem choppy (ouch).
4. virtualenvwrapper acting funky - specifically,
ImportError: No module named virtualenvwrapper.hook_loader
even though things generally seemed to work. Wow, I'm going to have to figure out how to inline code on blogspot here.
Anyways, the problem turned out to be that natty installed python 2.7.1 as default. Nobody warned me! I added the line
export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python2.6
To send everybody back to python2.6. Problem solved.

Unity isn't super annoying or buggy yet, but I'll give a shoutout if it becomes so.

Welcome to creature feature

yes, it's Yet Another Programming Blog.
I'll also throw in some deep thoughts once in a while.