Updates from June, 2014 Toggle Comment Threads | Keyboard Shortcuts

  • ThomasPowell 9:10 pm on June 27, 2014 Permalink
    Tags: , ,   

    Toggling the mute button in Microsoft Lync for Mac via Applescript 

    Through liberal use of the dictionary for Microsoft Lync, the Accessibility Inspector, and a few web links, I’ve come up with this script which toggles the mute button in Lync for Mac.

    tell application "Microsoft Lync"
    end tell
    tell application "System Events"
      tell process "Microsoft Lync"
        repeat with aWindow in (get every window)
          set aName to get the name of aWindow
          set initialName to ((characters 1 through 12 of aName) as string)
          if (initialName = "Conversation") then
            activate aWindow
            click checkbox 5 of splitter group 1 of aWindow
          end if
        end repeat
      end tell
    end tell

    I still want to hook it up to a hotkey, and ideally, have a different hotkey for mute and unmute, but that will have to be left for another session. I will hopefully update this post with more details as I figure out how to explain them.

  • ThomasPowell 8:29 pm on June 19, 2014 Permalink
    Tags: deprecation, , rspec3, sed   

    rspec-rails 3 deprecation warnings scripts and fixes 

    Upon upgrading to rspec 2.99.0, I began to receive deprecation warnings for several things that had issues, and to do a few updates:

    Because the project was using its syntax and stub_model I needed to add that functionality back into rspec in the :test group of my Gemfile:

      # Support for its syntax
      gem 'rspec-its', '~> 1.0.1’
      # Support for stubbing model in view specs:
      gem 'rspec-activemodel-mocks', '~> 1.0.1'

    On top of that I had to do substitutions for be_true, be_false, and_return with block syntax, and change pending to skip for a few pending tests.

    I was able to run the following find + sed commands for each of these (note that the .original part is Mac-specific):

    find . -name '*.rb' -exec sed -i .original 's/be_true/be_truthy/g' {} +
    find . -name '*.rb' -exec sed -i .original 's/be_false/be_falsey/g' {} +
    find . -name '*.rb' -exec sed -i .original 's/and_return[ ]*{[ ]*\([^} ]*\)[ ]*}/and_return(\1)/g' {} +
    find . -name '*.rb' -exec sed -i .original 's/^\([ ]*\)pending /skip /g' {} +

    I haven’t completely foolproofed the last two regexes, so I’d make sure to have your work committed for each set of substitutions (and to make sure rspec still passes your tests, of course.)

    And the cleanup:

    find . -name '*original' -exec rm {} +

    Lastly, to quiet the remaining deprecation warnings that I had, I added this to my spec_helper.rb:

    Rspec.configure do |config|
    # other config code
      config.mock_with :rspec do |mocks|
        mocks.yield_receiver_to_any_instance_implementation_blocks = true
    # other config code

    This configuration, as I understand it, will be standard with 3.0:

      mocks.yield_receiver_to_any_instance_implementation_blocks = true

    This setting is required for 2.99 because you will unconditionally get a deprecation warning even if you set the type…


    And I wanted to raise an error for any other deprecation warnings:


    After all the dust had settled from 2.99, I upgraded rspec-rails to 3.0.0 and did a bundle update:

      gem 'rspec-rails', '~> 3.0.0' # Test framework

    I’ve unearthed a few deprecation warnings about :should syntax, which I expect to update later.

    One misleading deprecation warning:

    Requiring `rspec/autorun` when running RSpec via the `rspec` command is deprecated. Called from /Users/tpowell/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:247:in `require'.

    …was actually due to having require 'rspec/autorun' in my spec_helper.rb

  • ThomasPowell 1:05 am on June 19, 2014 Permalink
    Tags: ,   

    mkdir with intermediate directories and rails generate view spec 

    I’ve been running into a lot of cases where I need to build intermediate directories for a path. Apparently, the correct option is -p

    mkdir -p dir/tree/to/make

    From the mkdir man page:

         -p      Create intermediate directories as required.  If this option is not specified, the full path prefix of each operand must already exist.  On the
                 other hand, with this option specified, no error will be reported if a directory given as an operand already exists.  Intermediate directories
                 are created with permission bits of rwxrwxrwx (0777) as modified by the current umask, plus write and search permission for the owner.

    I’ve assigned it an alias in my .zlogin:

    alias mkdirtree='mkdir -p'

    Of course, this all came about because I needed to an generate rspec file for a view, which can be done with:

    rails g rspec:view name/of/controller action another_action

    Results in the following files in the spec/name/of/controller directory:

Compose new post
Next post/Next comment
Previous post/Previous comment
Show/Hide comments
Go to top
Go to login
Show/Hide help
shift + esc
%d bloggers like this: