May 24, 2011, 5:28 am
Spell checking and typeahead are two of my top gripes with modern software. URL or bookmark completion is ok, that is when I’m in the ‘trying to remember’ mode. But when I’m in the flow of writing, having the computer guess what I’m trying to say is incredibly distracting and annoying.
Originally, I thought gmail was running auto-spellcheck for me, but it was the browser, in this case Google Chrome.
In Chrome, you turn off spellcheck under chrome://settings/language ; uncheck the ‘Enable spell checking’ box underneath the list of languages.
(You can also get to this screen advanced settings screen by clicking on the wrench in the upper-right, select ‘Preferences’ and ‘Under the Hood’, then click ‘Languages and Spell-checker Settings’ )
May 19, 2011, 7:32 am
Update 7/14/11 – I believe this is fixed in rturk 2.4 – thanks Mark!
http://rubygems.org/gems/rturk
***
rturk, the Ruby gem for making calls to the Amazon Mechanical Turk API, uses a REST transport layer. That’s fine, but all calls are currently performed by a GET, which has a length limitation. When making calls that include long strings of data – such as the XML for a QuestionForm structure in a qualification tests – errors may occur with the non-explanatory message ‘400 Request Error’.
Was able to patch it by making a change to lib/rturk/requester.rb :
46,47c46,50
< RTurk.logger.debug "Sending request:\n\t #{credentials.host}?#{querystring}"
< RestClient.get("#{credentials.host}?#{querystring}")
---
> # RTurk.logger.debug “Sending request:\n\t #{credentials.host}?#{querystring}”
> # RestClient.get(”#{credentials.host}?#{querystring}”)
>
> RTurk.logger.debug “Posting request to #{credentials.host}:\n\t #{params.inspect}”
> RestClient.post(credentials.host.to_s, post_params)
A more robust fix might be to use POST only for longer requests, or make it an explicit option on the RTurk object
April 29, 2011, 2:28 pm
I’m not sure where the bug is, but when saving some binary data that was generated in a Rails3 before_create callback, it kept getting truncated in the actual INSERT INTO statement (though it appeared fine even in after_save callback, it was truncated in the database). Using PostgreSQL 8.4.7 with pg (0.9.0) and activerecord 3.0.5
Seemed like it could be related to this fixed bug, but my problem is on the save itself:
https://rails.lighthouseapp.com/projects/8994/tickets/611-cannot-write-certain-binary-data-to-postgresql-bytea-columns-in-2-1-0
In any case, found a simple workaround: uuencode the data first, and uudecode on loading.
before_create do
... stuff that builds my_hash ...
self.my_hash = Base64.encode64(Marshal.dump(my_hash))
end
Then later, to reconstitute the hash,
loaded_hash = Marshal.load(Base64.decode64(@record.my_hash))
April 24, 2011, 10:55 am
Trying to shoehorn some data from the back into the wp_connections database, I needed a perl equiv to the md5(uniqid(rand(), true) function. From some general suggestions at http://www.experts-exchange.com/Programming/Languages/Scripting/Perl/Q_26773756.html came up with the following snippet:
use Digest::MD5 qw (md5_hex);
use Data::Uniqid qw (suniqid uniqid luniqid );
sub gen_token {
# approx equiv to md5(uniqid(rand(), true));
return md5_hex(uniqid);
}
Will also need to use Scott Hurring’s http://hurring.com/scott/code/perl/serialize/ to get it fully into the needed format…
April 11, 2011, 7:55 am
Perhaps this is somehow due to my config…but if it happens to me, it could happen to you:
I have a model, say table_one with a belongs_to: table_two. It happens that table_one and table_two each have a column named ‘datafile’. The two columns are intended to refer to entirely separate datafiles, and thru lack of imagination I named both the same. Now when I edit a row from table_one, it shows the associated row from table_two, and uses an identical name for the input fields for both ‘datafile’’s! record[datafile]
The result is that the datafile for table_one is wiped out on edit, as it is replaced by the blank datafile input for the associated record for table_two. Ouch!
Workaround of changing the name of the column in table_two fixes the problem.
Using activescaffold 3.0.5 for Rails 3.0
April 7, 2011, 10:33 am
Seems to me the key is creating a language that lets you efficiently express what you need to. Well-designed dsl’s (domain specific languages) have a lot of power. But these guys are the ones that apparently know:
http://www.readwriteweb.com/hack/2011/01/secrets-of-backtypes-data-engineers.php
April 5, 2011, 8:21 am
Found a real effort to doc the rails framework! Not all filled in, but a huge improvement over the tutorial-as-doc approach:
http://apidock.com/rails
ie link_to
Thanks APIDock!
April 5, 2011, 12:11 am
In the helper file, ie tablenames_helper.rb, override the render_action_link method
def render_action_link(link, url_options, record = nil, html_options = {})
if link.parameters[:association] == :my_association
# special handling here
else
super # in case you have other associations for which you do want the default behavior
end
end
This confounded me for a while as it was easy to create a helper to override the link to associated records, but if the records did not yet exist the ‘Create New’ appeared hardcoded. After inspection of ./bundler/gems/active_scaffold-45451d963672/lib/active_scaffold/helpers/list_column_helpers.rb and ./bundler/gems/active_scaffold-45451d963672/lib/active_scaffold/helpers/view_helpers.rb the above override became apparent. Is there an easier way to determine this sort of thing?
April 4, 2011, 3:07 pm
…is that they are too important to take time for the grunge work that makes a technical book useful.
Agile Web Development with Rails is essentially a book-length tutorial, and imho not worth either the money or time. The entire book is narrative. It admits as much in the introduction: “This book isn’t meant to be a reference manual for Rails…reference manuals are not the way most people learn.” Maybe so, but they are extremely helpful productivity tools when trying to do actual work! (The narrative itself is so patronizing and self-aggrandizing its painful to plow thru, though probably does have some value if you can stomach it.) An auto-generated code API is no replacement for a human edited reference manual with context. It seems Rails requires you to ‘read the code not the docs’ in order to do anything nonstandard, which works, but…not exactly productivity enhancing as advertised.
Browsing a good reference lets you see immediately the structure of a framework.
PHP.net is beautiful and so efficient, I’ve never bought a PHP book either – but for the opposite reason I’d advise not buying this one.
April 1, 2011, 1:12 am
After a bit of refactoring of one of my controllers in a Rails3 app, the layout mysteriously disappeared, with
Rendered vendor/plugins/active_scaffold/frontends/default/views/list.html.erb (188.5ms)
replacing
Rendered vendor/plugins/active_scaffold/frontends/default/views/list.html.erb within layouts/application (192.1ms)
in the Rails debug output. Turned out to be a simple error – I added a routine to initialize some instance variables and forgot the ’super’ at the end to call the parent class initializer:
def initialize
... my instance vars ...
super
end