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)