Glad You're Ready. Let's Get Started!

Let us know how we can contact you.

Thank you!

We'll respond shortly.

Standup 6/10/2011: scp's magical tab completion

Ask for help

  • Some pivots on an Android project were trying to remember if there was any way to turn of overscroll glow in lists.

Interesting Things

  • DevOps Days is coming up on June 17 & 18. They appeared to be sold out before, but are now inviting people off the waiting list, so if you want to go sign up.

  • When using scp to get files from a remote machine, it actually uses ssh to get into the machine to do tab completion of the remote filesystem.

  • When running specs through rake, FactoryGirl factories are evaluated before fixture data is loaded, which is the opposite of what happens when running directly with spec. This manifests itself with really broken factories if they need to load fixture data but do it too early.

All this means is, don’t write your factories like this:

Factory.define :foo do |f| Bar.find_by_number(100)

Write them using the lambda syntax like this:

Factory.define :foo do |f| { Bar.find_by_number(100) }
  • Some pivots were noticing what seemed to be strange behavior when using the ‘and’ keyword in ruby, because it has the lowest precedence in the language.

Some demonstrations:

> def foo1
>   puts 'foo' and false
> end

> a = foo1
 => nil
> a
 => nil

If you try to wrap the 'foo' and false in parentheses, be careful of your spacing:

> def foo2
>   puts ('foo' and false)
> end

> b = foo2
 => nil
> b
 => nil

> puts('foo' and false)
SyntaxError: compile error
(irb) syntax error, unexpected kAND, expecting ')'
puts('foo' and false)

Using && is a little more predictable

> puts 'foo' && false
 => nil

Or the difference when assigning not just printing:

> x = 'foo' and false
 => false
> x
 => 'foo'
> y = 'foo' && false
 => false
> y
 => false

Post a Comment

Your Information (Name required. Email address will not be displayed with comment.)

* Copy This Password *

* Type Or Paste Password Here *