Capybara save_and_open_page not working

Ever gotten this one?

save_and_open_page # yields:
Failure/Error: save_and_open_page 
  NoMethodError: undefined method 'end' for nil:NilClass`

Hit this once or twice now, and it's annoyingly difficult to debug. The problem is that the request has an error in Rails, but for some reason it vomits out the error info / stack trace as plain text, and not as a Rack response object. Capybara captures the text, but doesn't treat it as html, so you get this weird nil error.

The solution is just to print the page's text.

puts page.body

And that will give you at least the location of the error.

Sprinting to Hell

Just to lead off - if you need support from Sprint, go to their live chat. That link is mostly a bookmark for me, because it's not on their web site anywhere. Certainly not in the "Contact Us" section. If you get on the phone, you'll be there for an hour or so, and they're not nearly as good at solving problems. The retail stores are worthless, even though customer support reps will tell you to go there. Don't bother.

  1. Nov 2 - I upgrade my old iPhone 5 to the new iPhone for Life plan. This will get me a shiny new iPhone 6+ with no money down, and actually save money on my bill, especially with the "loyalty discount" I would get for being a Sprint customer who upgraded.

  2. Nov 6 - I get my new iPhone 6+, but I cannot activate it from the iPhone setup or Sprint's online portal. Thanks, guys. They also can't swap the line when I call customer support since I'm on the phone with them. I go through chat support, and they get the new phone activated.

  3. Nov 7 - Well, shit. They activated it with a new number and added a line to my account. That's not what I wanted. I've had the same number since high school - not exactly time to give it up now. I get on chat again, and they port my old number to the new phone, but the rep tells me to call back because another department has to cancel the additional line.

  4. Nov 14 - I call back to disable the unwanted new line, and the rep informs me that the iPhone for Life contract is tied to the physical device, so they cannot deactivate the line unless I return my iPhone 6+ and they exchange it for a new one. In the meantime, they'll put a $900 charge on my account until they get the old one back. Oh, and I have to call back to another department to get the bill delayed, or they'll cut off my service because of the $900 charge.

  5. Nov 22 - My service gets suspended. Thanks guys. I get back on chat support and get the payment delayed. Again. My phone gets reactivated.

  6. Nov 26 - Sprint emails me a confirmation that the old device has been received, and they will process it and take the ridiculous charge off my account soon. I'm thinking 3-4 days, I mean, how long could it take?

  7. Nov 30 - My shiny new iPhone 6+ gets stolen. Fucking San Francisco - I'm really starting to hate living downtown. This is the second phone I've had stolen in two years. Believe me, Find My iPhone is worthless. They can narrow it down to an apartment or street corner, but the cops can't go after it because that's not specific enough. The device gets wiped or something within a few hours, and is never heard from again.

    After the last one got stolen, I got Sprint's "Total Equipment Protection" plan for $11 / mo just in case this sort of thing happened again. I got in touch with Sprint support, who directed me to another company that manages that part of the plan - Asurion. Enter a whole bunch of identifying info, create an account, and it turns out there's a $200 deductible on their plan. $11 / mo * 12 months + $200 = $322. Great. Well, cheaper than a new iPhone. Sort of.

    They email me and say it may take 1-3 days to ship the replacement. I buy a Skype number, because I have no phone and I'm paying for a Sprint account I can't use.

  8. Dec 1 - Asurion emails me to say the 6+ is on backorder, and it may take 7-10 days to ship the new one, and they will provide updates via voice mail. Are you kidding me? My phone got stolen and you'll keep me informed by voice mail ?

  9. Dec 4 - I got my old iPhone 5 back. I had given it to a family member, who shipped it back to me. I was ready to do without, but they insisted.

    I drop by the Sprint store to get the number switched back to my old phone. They tell me my account is suspended pending a $1200 charge. What the fuck? I thought we had already been over this. Then they tell me that even if they get that cleared up, I would have to pay $36 to get the old phone activated, then another $36 for the replacement 6+ whenever I get that. We're up to $322 + $72 = $394 now. Still no ETA on that.

    I explain the story so far, and they literally sit me down at on the phone and call customer support, who offers to put me on hold for 30 minutes. I cannot believe how much bullshit this is. I leave.

    Chat support has worked much better, so when I get home I go online with them. It takes over an hour, but the results are acceptable. They tell me the returned phone charges will show up on Dec 10, and create a payment plan so they can delay the charges until after then. But (and you knew one was coming) the plan is separate from the account, so I have to get back in touch and argue about it more when the charges are reversed.

    After an hour, my representative can no longer deal with me and sends me to her supervisor. He gets my number reactivated on my old iPhone 5. He swears up and down there will be no extra line or extra charges, but would you believe them at this point?

  10. Dec 8 - still no update on the replacement phone. I call in to Asurion, and they tell me they meant 7 to 14 business days. I ask if I'm likely to get the phone by Dec 18 when I'm leaving town for the holidays. Their rep tells me it might be shipped by then. So there's a pretty good chance my phone will be sitting on my doorstep (or returned to sender) over my Christmas break.

    Fucking. Lovely.

  11. Dec 10 - got my replacement phone. Couldn't set it up manually, had to get Sprint support to approve it. Once again, they tell me to just wait on the billing shenanigans. They offer to open a ticket, which I take them up on.

  12. Dec 23 - get another email notice from Sprint that my now $1300 bill is due. Great.

  13. Dec 29 - Another notice that my service will be suspended if I don't pay my $1300 bill by tomorrow. I respond via email to the support ticket, but they do not email or call me back.

  14. Dec 30 - After getting no more info, I get back on chat support. I let them know that if I have to deal with one more two-week payment delay, I'm done and will never pay them a dime. My support rep has me talk to a supervisor again , and the left hand still can't find the right at Sprint. The right hand apparently still has its thumb up Sprint's ass, so they argue me into one more two-week payment delay. I promise them, I will not tolerate one more. Jan 13 is it.

    They offer to open a new ticket with executive support. Sure, whatever.

  15. Jan 2 - I get a call from someone at Sprint executive support. She tells me that she's tracked down the problem, and the warehouse department will look into it. Seriously? Now we're up to 4 deparments various people have assured me are involved. The support rep says she is going to close the ticket. I tell her NO, ABSOLUTELY NOT. The issue is not resolved, so you don't get to close the ticket yet.

  16. Jan 5 - I get another call from my executive rep with happy news - they've finally applied the returned phone credit. My bill is now $300, which breaks down in some way I can't fathom involving my previous plan, current plan, and three month's backup. I can live with that; at least we'll go back to normal payments after this.

This whole saga was extraordinarily stressful and cost me an arm and a leg. This is the worst customer service I've ever received. If I had had any idea how painful this would be, I would never have tried to upgrade. Thankfully for Sprint, I'm locked into another two-year contract, but the minute that's done I am out . I never want to deal with this company again.

Unicode CSS

Why? Because job security. See also: Coding in Emoji with Swift

Feminist Hacker Barbie

MattelĀ® released "Barbie: I Can Be A Computer Engineer" back in 2013. It was apparently the most sexist Barbie book ever. Barbie is totally incompetent - she infects her and a friend's computer with viruses, only makes the "designs" for a game and relies on male friends to code it, and then takes all the credit for the eventual game.

It made waves this week; somehow people only noticed it now. Mashable did a great writeup, and the book got hundreds of one-star reviews on Amazon before being de-listed. The internet continues to rag on it via the #FeministHackerBarbie hashtag, taking pages out of the book and re-captioning them.

I am seriously cracking up. Here's one of my favorites via Livelyivy:


There's also a tool for making your own version, and it's great. Here's mine:


WYSIWYG is a disaster

I've been trying to find a good WYSIWYG editor for simple CMS I'm building. My project just needs to make static pages - you know, /about, /faq, etc. The idea was that even if a developer had to write the HTML, anyone could go in and fix a typo or add a paragraph. My requirements for the html editor were pretty simple, I thought:

  • Produces mostly clean HTML (no <font>, <span style="ugly: yes;">, etc )
  • Forces Word, RTF, and HTML paste into plaintext, or at least something not horrible
  • Assigns classes for p, h1, hr, etc (or has hooks so I can add it in)
  • In-place editing mode
  • Minimal dependencies

Of course, you can't just use contentEditable directly. The Guardian has a great run-down of inconsistencies they found while building their back-end.

As has ever been the case, there are dozens of js libraries to do this sort of thing, and figuring out which ones are even worth investigating is a huge and draining process. Unfortunately my go-to for this sort of thing was out. Readactor is excellent, with a good API, good documentation, and readable code. But it's not free, and I want to release this as open-source.

  • TinyMCE - I got burned badly enough by this back in the PHP era
  • CKEditor - if anyone can show me a list of configuration options and their variations for this beast, I'll be impressed. A list of events I can hook into, and I'll be stunned. Some of the worst documentation I've ever dealt with. And look at the freakin' Rails plugin - better hope you use CanCan, Pundit, Mongoid, and want to slap in an extra controller.
  • WYMeditor - sounds interesting, but the mid-90's design isn't inspiring
  • Etch - backbone
  • Summernote - bootstrap
  • jQuery Text Editor - bare bones, and kinda crap docs
  • Hallo - links plugin isn't working. wut?
  • SmallEditor - angular
  • jQuery Notebook - can't even guess what requirements this will / won't need from reading the page and the docs - also needs font-awesome
  • Trumbowyg - wtf is with that name? "semantic" option is still in alpha
  • Morrigan - their demo page has scantly clad women! This must be a great editor! Yes, I played Dragon Age as well, but come on. Also v0.1-beta
  • Azexo Composer - drag and drop Bootstrap components, not quite what I wanted
  • Aloha Editor - beautiful page, but it really doesn't tell me a damn thing about how to use it, and their API docs are nil
  • Medium.js - no support for messing with classes or styles in the content
  • Scribe - not an editor, but a toolkit for building one. Built as AMD js modules, distributed via Bower, and everything is a plugin. Try building on this in a Rails engine, and you're gonna have a bad time.

The bottom line is that WYSIWYG editors for HTML are awful, and have been ever since Dreamweaver. I never thought about why it was an impossible concept until I read Nick Santos' article about Medium's editor.

Now I'm trying to figure out if I should accept an ugly, duct-taped-together interface for my CMS or just screw it and use Markdown.

Post-checkout hooks for rails

Other post-checkout hooks try to auto-run migrations or bundling for you, but I feel like those are pretty error-prone. On the other hand, just getting notified is pretty helpful.

Copy + paste into project/.git/hooks/post-checkout

How to Profile a Leaky Sidekiq Job in Heroku - Happy Bootstrapper

Very helpful. Difficulty not addressed: load testing in production.

Javascript - the style is the substance

Javascript is an interesting language. While Ruby has a style guide, and Python has a few (including Google's, they are not critical to how your code functions. They just help avoid those "strip whitespace" commits that touch every line in your repo and permanently ruin git blame.

With Javascript, the style is the substance. Take these two for example:

var object = {
    method: function(data){ ... },
    _variable: 3

object2 = {
    method: function(datae){ ... },
    _variable: 2

var Klass = function(){
    this.method = function(data){ ... };
    this.variable = 4;
    return this;

These seemingly small differences might not affect how a short script works, but they are critical to how your app works as a whole. The first declares a single object. The second declares a global variable. The third declares effectively a factory function.

Newlines can result in syntax errors for strings. Missing semicolons can ruin your JS after compression. Using reserved words as object keys can break your code in some browsers. Failing to use === can result in unexpected behavior.

It is essential to use a Javascript style guide. Frameworks like Express and Angular can help standardize things like object and module declarations, and CoffeeScript can provide syntax sugar to cover simple issues.

Otherwise, AirBnB's style guide is comprehensive and helps show best practices. Pick something, and stick with it, especially if you are working on a team.

Ruby Operators

This is funny XD

=>    hashrocket
<=>   spaceship
~>    twiddlewaka
->    stabby lambda

Time zone junk

Some random things I built to help deal with timezones in Ruby / JS

Update: Extracted this into a gem (in beta): HappyTime