JT Archie's blog



JT ArchieJT Archie
[Standup][NY] 03/08/2012
edit Posted by JT Archie on Thursday March 08, 2012 at 04:02PM

Interesting

  • Ruby MRI seems to have taken a step back in time, a dangerous, but useful feature (to some) is the goto statement.
  • It appears that DateTime object has some issues with doing math.

    DateTime.now - 1.hour #raises TypeError
    DateTime.now - 3600   #works as expected
    1.hour.class          #Fixnum
    
  • Reading the CSS property background-position in Chrome returns an invalid value. Don't rely on it.

  • Github was hacked! They had a security issue that was a result of attr_accessible being uses incorrectly. Remember to authorize your SSH keys.
  • Need help with cron? Use http://cronwtf.github.com to convert cron into friendly English.
  • &&, ||, and ! vs. and, or, and not. It is highly recommended to always use the strict logical operators (&&, ||, and !) because the keywords (and, or, and not) don't have the same operator precedence.
  • When evaluating variables in strings with bash, its better to use ${var} than $var. The curly-brace allows you to evaluate a variable with copy behind it. For example, ${var}asdf and $varasdf evaluate differently because of the expected variable name.

Help

  • Rails <3.1 has some gotchyas when using :inverse_of option.

    class Note < ActiveRecord::Base
      has_many :contacts, inverse_of: :note
    end
    
    
    class Contact < ActiveRecord::Base
      belongs_to :note, touch: true #for triggering the note observer when the contact is updated
    end
    
    
    class NotObserver
      def after_touch(note)
        note.contacts # does not have the new attributes updated unless you specify the :inverse_of
      end
    end
    
    
    # Somewhere in the code...
    contact.update_attributes....
    
  • When table names are not namespaced on a class. What is the best way to work with this if we want table names to be namespaced?

    class Foo::Bar < ActiveRecord::Base
    end
    
    
    > Foo::Bar.table_name == "bars"
    true
    

Interesting

  • When using validates on an association, remember for uniqueness validations to use the associated attribute.

    validates :foo, :uniqueness => true
    

    Should be

    validates :foo_id, :uniqueness => true
    
  • You can get a quick an easy git blame with a string, rather than a line number.

    git log --pretty=oneline -S'some string'

Help

  • What is the advantage of using scope over a class method?

    scope :new, order(:id)
    

    or

    def self.new
      order(:id)
    end
    

    Some Pivots seem to think that scope doesn't add the default scope in some cases (a bug?). It appears that class methods are the preferred way moving forward in Rails.

Events

  • Tuesday brown bag was a series of Youtube videos of Alan Key speaking about programming.
  • Thursday UX Book Club is meeting to discuss Steve Jobs book.

JT ArchieJT Archie
[Standup][NYC] 1/17/2011
edit Posted by JT Archie on Tuesday January 17, 2012 at 01:44PM

Interesting

  • Trying to load Ruby 1.9.3 with RVM on OSX Lion and having problems? Adam has found a solution here.

Events

  • Simple made easy was the tech talk (video) today. The implications being what is easy might not be the best for your code maintenance.

Interesting

  • Git 1.7.8 is out!
  • We have a new gong in the office!
  • When using Timecop.timetravel in your tests, make sure that you use before setting up your test data. Otherwise the data could potentially be created before that time existed!
  • git whatchanged gives you a normal git log with a list of changed files.

Help

  • Rails console history is crazy! On opening a new session, and pressing up for history, random data appears from history, many eons ago. Two files are written to with each rails command -> irb_history and irb-history. Any idea what's going? Some people think that it might the interaction with wirble.

JT ArchieJT Archie
[Standup][NYC] 2011-11-16 - Lion is not Enterprise ready
edit Posted by JT Archie on Thursday November 17, 2011 at 05:18AM

Interesting

  • If you are trying to get REE on Lion make sure that you have GCC 4.2 or higher. Learn more.
  • If you are still using a mouse with scroll wheel in Lion, disable the middle click annoyance with Mission Control.

Help

  • Donate for Movember we are team 'Pivots NY'. We grow facial hair for Man Cancer Awareness Month.

JT ArchieJT Archie
[Standup][NYC] 2011-11-14 - 3, 2, 1 Launch!
edit Posted by JT Archie on Monday November 14, 2011 at 10:48AM

Interesting

  • Heroku has released Scheduler. Their replacement functionally for cron, which allows you to schedule processes to be run (limited to a 10 minute interval).

Events

  • Monday - Raise Cache @ 7pm
  • Wednesday - node.js meetup @ 6:30pm
  • Wednesday - Machine Learning study group @ 7pm

Interesting

  • Cucumber has better support for within selectors. You can actually chain withins together for more precise selection. The selectors for within are looked up in the selector.rb file. Then I should see "Hello" within the header within the page
  • Over the weekend Heroku Cedar was having trouble with deployments. Every deployment got the "gray" screen of death. It appears that they were having issues.

JT ArchieJT Archie
Standup 3.17.2011 -- will_paginate render and devise testing
edit Posted by JT Archie on Thursday March 17, 2011 at 02:34PM

Help

How do I test a custom will_paginate renderer?

If using RSpec, test the custom render in a helper spec by using helper.will_paginate and the options you need to test your rendering settings.

When testing with Devise, my custom Devise views are not loading in the specs, instead Devise's default views are. Why?

Interesting Things

  • When using Devise in integration test, users were logged in when they shouldn't have been. The culprit was that in the integration test there was before block that logged a user in and in the same scope a pending test. The logged in user was never officially logged in, so later in the test suite a view that did not require login had a logged in user. Be careful how you log in users and clean your session!

JT ArchieJT Archie
Standup 08/26/2010 - Rails controls too much of cache
edit Posted by JT Archie on Thursday August 26, 2010 at 09:17AM

Help

"Does Postgres have an equivalent MySql Myisam high write performance?"

A Pivot was wondering what settings in Postgres can be enabled for high performance INSERTs (willing to sacrafice SELECT performance on said table).

"Why is Paperclip giving a Stream close error when in development?"

When using Paperclip in development, any file upload results in a Stream IOError. Trying to replicate the problem with Paperclip on its own causes no problems, so it appears to be a conflicting library.

Interesting Things

  • An update to yesterday's Rubymine font size issue. The file drawer can not be specifically updated, but the overall system font can be under Preferences > Appearance > Fontsize. Make sure to restart Rubymine.
  • Google Voice has been added as a service on to GMail. Make phone calls for free to anywhere in the US from your browser.
  • An update to yesterday's Safari 'Back' button issue. Safari caches the previous ajax call (dubbed ajax zombie) when going back to a previous page. The fix had to do with changing Rails default "Cache-control" header to be "no-store".

JT ArchieJT Archie
Standup 08/25/2010 - Rails RC2
edit Posted by JT Archie on Wednesday August 25, 2010 at 09:23AM

Help

"How does Mobile Safari handle the back button?"

When pressing the back button in Mobile Safari can cause the access to the DOM to be lost. It appears to happen because of resources of "forward" facing pages taking over the cache.

"How to set the font size on RubyMine project (file) drawer?"

With the increasing size of resolution on monitors, some of are experiencing the small font issue. Is there a setting to control the RubyMine project browser?

Interesting Things

  • Updating ImageMagick from 6.6.1 to 6.6.3 fixes a bug with color palette when trying to resize images using Paperclip.
  • Rails 3 RC2 has dropped fixing many bugs and this much closer to the final release. The Rails team would like to find any blockers specifically in Bundler and ARel.

Other articles: