So I had a great idea for a JQuery plugin. What's better, I was going to write it too.
A single line initializes and adds the plugin to your page, which then allows people to tweet from said page, including a shortened link to said page, hash tags of your choice - but that's just the beginning. Then, the plugin retrieves all tweets with the same shortened link, organizes them using create_date and @whoever, and displays them on your page as hierarchical comments.
Basically, a totally painless and free commenting system hosted and authenticated by twitter, displayed on your page with one line. I like. Except for one problem - twitter search doesn't work for included URLs.
If anybody knows how to possibly retrieve all tweets about a given url (or the last 200), please let me know. It's a terrible wasted potential not to allow this.
For instance, here's a twitter account of mine from another project: . The last couple tweets have bitly links. You'd think a twitter search for the link would show up the tweet, but NO! nothing going. Even when you switch from their ridiculous "popular tweets" to "all tweets". What kind of tweet search misses on unique text from a tweet?
facepalms = only 2, but general annoyance is through the roof.
UPDATE:
I take it back - some urls hit, some don't. Even better. Possibly, broken urls don't hit? But I'm not sure.
Saturday, July 30, 2011
Tuesday, July 12, 2011
holy sweet victory
Just figured out something that's been bugging me nonstop for weeks, which has no documentation online: the jquery plugin fancybox doesn't like to have its stuff overwritten, which is to say, you shouldn't define something like this:
In one function, and then soon after define:
in another. You'll get a wholly unhelpful error about href being undefined.
All better now -
#facepalms only 4, because I already had a lot of trouble with this previously, I'm over it now, and the sweet release of figuring it out is worth so, so much.
var fancy_box_options = fancy_box_defaults;
fancy_box_options.type = 'iframe';
fancy_box_options.width = 696;
fancy_box_options.height = 499;
fancy_box_options.scrolling = 'no';
fancy_box_options["onStart"] = function(link){
var new_link = $.param.querystring($(link).attr("href"), "gmail=" + $("#gmail").val());
$(link).attr("href", new_link);
};
$("a.iframe").fancybox(fancy_box_options);
$("a.iframe_defaults").fancybox();
In one function, and then soon after define:
<% if current_user && @popup_help %>
var fancy_box_options = fancy_box_defaults;
fancy_box_options.type = 'iframe';
fancy_box_options.width = 696;
fancy_box_options.height = 499;
fancy_box_options.scrolling = 'no';
fancy_box_options.href = '<%= popup_help_path(:gmail => current_user.email) %>';
$.fancybox(fancy_box_options);
in another. You'll get a wholly unhelpful error about href being undefined.
All better now -
#facepalms only 4, because I already had a lot of trouble with this previously, I'm over it now, and the sweet release of figuring it out is worth so, so much.
Monday, July 11, 2011
ubuntu problems
so for the last while my wireless card has been acting up _sometimes_, on certain wireless networks but not others. I finally got a clue as to what might be going on: wireless N. It's an N card, but the driver/kernel stuff going on in ubuntu has a known problem with certain wireless cards.
Edited my modprobe.d/options.conf with the line:
options iwlagn 11n_disable=1 11n_disable50=1
and then (hopefully won't have to restart) ran:
sudo rmmod iwlagn
sudo modprobe iwlagn
And that seems to have improved things. So far.
#facepalms: like a lot. Until now. Hopefully.
Edited my modprobe.d/options.conf with the line:
options iwlagn 11n_disable=1 11n_disable50=1
and then (hopefully won't have to restart) ran:
sudo rmmod iwlagn
sudo modprobe iwlagn
And that seems to have improved things. So far.
#facepalms: like a lot. Until now. Hopefully.
Sunday, June 19, 2011
rails fields_for, object sorting
So what I needed to do was select a subset of one model which happened to have a key into another, sort it by an attribute of the other model, and display a list of the results in a form.
here's the query to find, filter, join, and order:
and here's the bit of the form:
and then to access the objects:
Things to notice:
the fields_for uses a parameter :user_categories which references the name of the model, followed by the object which is actually a list of objects of type Category, so I'm assuming this is to let rails know how to treat it. Also, note that to reference the actual objects, you have to use model_class.object.method. the model_class is actually some sort of form builder helper before the call to .object.
This only took an hour to figure out - #facepalms = 3.
here's the query to find, filter, join, and order:
@user_categories = Category.joins(:user_categories).where('user_categories.user_id' => current_user.id).order("name asc")
and here's the bit of the form:
<%= f.fields_for :user_categories, @user_categories do |user_category| %>
and then to access the objects:
<%= user_category.label :name, user_category.object.name %>
Things to notice:
the fields_for uses a parameter :user_categories which references the name of the model, followed by the object which is actually a list of objects of type Category, so I'm assuming this is to let rails know how to treat it. Also, note that to reference the actual objects, you have to use model_class.object.method. the model_class is actually some sort of form builder helper before the call to .object.
This only took an hour to figure out - #facepalms = 3.
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.
Labels:
android,
google docs,
nerd,
Quantified Self,
smartphone,
trick
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)
Subscribe to:
Posts (Atom)