Jonathan Barnes's blog



Ask for Help

*"when using the css3 pseudo selector nth-child followed by a nested selector e.g.

td:nth-child(4) > p

some times (but consitently) they do not match to the correct element. Has anyone using nth-child experienced this before and know why it sometimes works and other times not?"*

For now the solution is to use jQuery to get to the nth child and apply the styles that way.

Interesting Things

  • jQuery 1.4.2 ajax json responses with a response code of 200 and responseText:" " (note the non empty string) causes jquery to trigger the failure callback instead of the success. Previous versions would handle this as a special case and still trigger the success callback. Most people agree this is proper as an empty string is not valid json, but be aware!

  • Perseids is a metor shower happening right now (July 23 – August 24) so look up!

Jonathan BarnesJonathan Barnes
Standup 08/12/2010: (Text encoding issues)
edit Posted by Jonathan Barnes on Thursday August 12, 2010 at 10:34AM

Ask for Help

"We have a file claiming to be ISO-8859-l encoded, but having characters that don't seem to be encoded that way. Every editor we try to open it in shows the bad characters. We have tried to use the iconv utility to change it to a UTF8 file type but it keeps crapping out whenever it hits an unknown character for that encoding. Any ideas how to fix these files??"

There were multiple suggestions:

  • Try running iconv to encode it to its current encoding and see if that works i.e. latin1 -> latin1
  • Manually fix the characters that iconv complains on. (this was rejected as there were thousands of fils that needed fixing).
  • Try pasting the file into a WYSYWIG editor that may fix the bad characters and then copying them out again (using mechanize or similar to automate)
  • Try opening it in MS-Word or similar and saving it back out.

Interesting Things

  • the ':contains' pseudo selector in jQuery & webrat behave differently with regards to commas. in jQuery it treats it as a string, in webrat (probably because it is converted to xpath) it is treated as separator.
  • spec.opts << --format profile will show you the 10 slowest specs after the suite is run.
  • Rails versions > 2.3.x use HTTP only cookeis so you cannot use selenium to clear them out. You can turn that off in your test environment to fix this. while a slower you may also just want your sleenium tests to open a fresh browser for every test in case there are other side effects in the browser like local data stores etc.
  • If you are using RubyMine and are experiencing a perpetual 'Attach gems' problem you may be able to fix it by clearing out older gem versions. gem clean
  • Riak is a distributed hash table data store solution. They are working on a project that is going to implement the SOLR api but be backed by Riak instead of lucene
  • If your using Rails 3/Passanger and you would like to have a production like environment but not call it 'production', say 'demo' You will need to change not only the RAILS_ENV but also the RACK_ENV variable to get it to work. Someone also mentioned that there may be a Passenger config that will also do this.

(Title: Standup 11/31/2000: Something Interesting from the post)

Ask for Help

"I have a paid for iPhone app in the app store and I want to deprecate the paid for feature and release the next version as a free app with ads. How can I continue give the users who have paid an add free version while keeping all new/future downloads free-with-ads?"

So far the only idea has been to release a second app that is free, but that has the problem of loosing all positive press/feedback for the existing app. And would seem to double the effort to provide upgrades for all users.

"We are getting 'Connection reset by peer' errors using Rescue to kick off some background jobs. It seems to be happening even for jobs that run only locally on the machine. They seem to happen randomly for various bg jobs. Has anyone else experienced this or have ideas on what is causing it?"

The connection reset by peer error is most often thrown by TCP/IP connections being closed by someone other than the client. Either the remote service close the connection or the network failed to keep the connection open. No one seems to have ideas on why/how it would be happening for local BG jobs.

"Devise + Selenium == 'you are being redirected'. When trying to selenium test log in, rather than redirecting correctly post login as it really does, the selenium test fails with a page stating 'you are being redirected'. Why is it not doing the actual redirect?"

There is a config somewhat deep in SeleniumRC config that tells selenium whether or not to follow redirects, it may be that it is set wrong. (the default should be to follow them and if you have not messed with it, not sure if this is your problem)

"We would like to be able to run our full and long-running test suite in the background while still having the 'test' environment free for doing BDD/focused testing. There are many potential solutions for this but what is the easiest/best to implement?"

solutions include:

  • Create a VM image that has your dev/test environment setup on it, push the changes to it and run you full suite in the through a terminal window. This has the drawback of a fair amount of time/effort setting up the vm correctly but that is a one-time-cost. You also need to do some interesting things with your hosts file and ssh keys to make access between your main system and the VM easier, and tends to require to commit the code somewhere in order to push it to the vm which, depending on your workflow, may be exactly what you don't want to do.
  • Create a new env & db call 'test_suite' and run your full suite against that environment. This solution generally requires you to clone a bunch of the default rake tasks which have the 'test' env hard coded in them such as db:test:prepare and related. if you look at db.rake for how often the test env is hard-coded you will see that it is non-trivial. Also once you have duplicated all those tasks you are stuck maintaining them as you upgrade rails.
  • Someone mention a project called Vagrant as a variant on the VM solution. This may solve some of the main pain points with doing it that way.
  • Someone else mentioned a plugin called Parallel Tests that utilizes the multiple environments approach. Maybe it can be tweaked/referenced as a solution to run all tests in an alt test environment

"I have upgraded to Selenium 2 pre-alpha 5 and seem to be unable to use 'click' in chrome?"

Most suggestions involved "... then don't use click" or "... try double-click"

"We are trying out the new bluetooth only 'magic mouse' from apple but in this office with lots of macs it is taking for ever to connect the mouse. why?"

It seems that a lot of the machines have bluetooth enabled and have discoverability turned on at all times. It would be bets to turn bluetooth off if your not using it and if you are to turn off discoverability except when connecting a new device.

"after using 'tail -f' my terminal window no longer shows keyboard input. why?"

It is possible that you have a complex and buggy PS1 defined and there is some data being printed in whatever you are tailing that is messing with that PS1. Try greatly simplifying your PS1 and see if that resolves the problem then do a binary search on your old PS1 to find the offending portion. If you are unable to find the root cause you can try one of the following. Try resetting your terminal using the unix command 'reset' and see if it fixes your terminal window. Try using the tailing option in Less 'less -F [file]'

Interesting Things

  • VCR is a great way to fake out an external dependency to run your tests against. It is an especially good/easy way to fake out external api's