Pivotal Labs

Main menu

Skip to primary content
Skip to secondary content
  • About
  • Case Studies
  • Team
    • Executives
    • Locations
      • San Francisco (HQ)
      • Boston
      • Boulder
      • Denver
      • London
      • Los Angeles
      • New York
  • Community
    • Blogs
    • Tech Talks
    • Events
  • Careers
    • Lifestyle
    • Principles & Practices
    • Benefits
    • FAQ
    • Apply
  • Contact
    • Press Room
    • Press Releases
    • In The News
    • Press Kit
  • All
  • Labs
  • Standup
  • Tracker

Monthly Archives: July 2012

Brian Cunnie

Recovering OS X Open Directory from Backup

Brian Cunnie
Tuesday, July 24, 2012

Lost Open Directory Database

You’ve lost your Open Directory server database. You need to recover it, but you don’t have an Open Directory Archive, and you don’t have a replica that you can promote. And you don’t want to restore the entire server, either.

This blog post covers how to restore an Open Directory database from backup.

Audience

This blog post is directed towards system administrators

  • who have an Open Directory Server that is running OS X Snow Leopard 10.6.8 (this procedure would probably run under other versions of Snow Leopard, but we haven’t tested it)
  • who do not have a replica that they can promote
  • who do not have a conventional Open Directory backup (i.e. Server Admin → Open Directory → Archive)
  • who want to do a surgical restore of just the Open Directory; who do not want to touch the other parts of the system
  • who have backed up their files.

Disclaimer

This procedure worked for us; it may not work for you. YMMV. There is no warranty, express or implied. This is by no means an Apple-approved procedure.

Open Directory

Open Directory is a tightly integrated application that includes OpenLDAP, kerberos, and Apple’s password service. For a successful recovery, you need to restore the records for all 3 services.

Procedure

Your Open Directory Server needs to be configured as a server (not replica). If it’s configured as a replica, re-configure it as a standalone server before you begin.

First, shut down the relevant daemons (slapd/OpenLDAP, kerberos, Password Service).

sudo launchctl unload /System/Library/LaunchDaemons/org.openldap.slapd.plist sudo launchctl unload /System/Library/LaunchDaemons/edu.mit.Kerberos.kadmind.plist sudo launchctl unload /System/Library/LaunchDaemons/edu.mit.Kerberos.krb5kdc.plist sudo launchctl unload /System/Library/LaunchDaemons/com.apple.PasswordService.plist 

Check to make sure the processes aren’t running (we’re being very careful, maybe even paranoid):

ps auxwww | egrep "slapd|kadmin|krb5|Pass" 

Move the old files out of the way:

sudo mv -i /var/db/openldap{,-broke} sudo mv -i /var/db/krb5kdc{,-broke} sudo mv -i /var/db/authserver{,-broke} sudo mv -i /etc/krb5.keytab{,-broke} sudo mv -i /Library/Preferences/edu.mit.Kerberos{,-broke} 

Restore the files from backup (your backup directory, e.g. “/Volumes/Backup/yesterday”, may differ):

sudo rsync -avH /Volumes/Backup/yesterday/private/var/db/openldap /var/db/ sudo rsync -avH /Volumes/Backup/yesterday/private/var/db/krb5kdc /var/db/ sudo rsync -avH /Volumes/Backup/yesterday/private/var/db/authserver /var/db/ sudo rsync -avH /Volumes/Backup/yesterday/private/etc/krb5.keytab /etc/ sudo rsync -avH /Volumes/Backup/yesterday/Library/Preferences/edu.mit.Kerberos /Library/Preferences/ 

Double-check that they’re in place (yes, paranoia again):

sudo ls -l /var/db/{krb5kdc,openldap,authserver} /etc/krb5.keytab /Library/Preferences/edu.mit.Kerberos 

Reboot the machine:

 sudo shutdown -r now 

When the machine comes up, you should have recovered your Open Directory database to the same state as it was when you performed your backup.

Good luck.

  • 0 Shares
  • Share on Facebook
  • Share on Twitter
Travis Grathwell

[Standup][SF] 07/24/12: W doesn’t always mean Wednesday

Travis Grathwell
Tuesday, July 24, 2012

Helps

  • SVG to canvas with css

We need to convert an svg element to a canvas (to eventually be part of a larger png). This svg element has a lot of css on it. The current best option looks like canvg, but this library does not respect css from files. Has anyone found a workaround for this?

Solutions: wkhtmltopdf can take screenshots of your webpage programmatically.

Interestings

  • Mousetrap – JS keyboard shortcuts

This went around on twitter last week, but mousetrap looks quite nice for keyboard shortcuts.

  • Cocktail: DRY up your backbone with mixins

Cocktail adds a simple one-liner to Backbone’s extend method to help you break out reusable code into mixins. The repo also includes an example for testing mixins in Jasmine with shared behaviors.

More in the blog post and the repo

  • 0 Shares
  • Share on Facebook
  • Share on Twitter
Onsi Fakhouri

Cocktail: DRY up your backbone code with mixins

Onsi Fakhouri
Tuesday, July 24, 2012

I’ve continued to enjoy using Backbone.js to build single page apps. As I’ve seen more and more real world backbone I’ve started to develop opinions to augment the blissfully unopinionated little framework that could.

One of these opinions has turned into a mini-library: Cocktail adds functionality to Backbone’s extend to facilitate breaking up reusable code into mixins. It’s pretty straightforward:

  1. Define your mixin. Mixins are just plain vanilla JavaScript objects with methods and properties hanging off of them. Here’s a slightly contrived mixin that makes a view selectable:

    window.MyMixins = {};
    MyMixins.SelectMixin = {
      initialize: function() {
        this.model.on('change:selected', this.refreshSelect, this);
      },
    
    
      events: {
        click: 'toggleSelect'
      },
    
    
      render: function() {
        this.refreshSelect();
      },
    
    
      refreshSelect: function() {
        this.$el.toggleClass('selected', this.model.get('selected'));
      },
    
    
      toggleSelect: function() {
        this.model.set('selected', !this.model.get('selected'));
      }
    }
    
  2. Mix your mixin into your views. It’s a one-liner:

    var MyView = Backbone.View.extend({
      mixins: [MyMixins.SelectMixin, MyMixins.SomeOtherMixin],
    
    
      events: {
        'click .myChild': 'myCustomHandler'
      }
    
    
      initialize: function() { ... },
      render: function() { ... },
      etc...
    });
    
  3. That’s it! Instances of MyView will automatically inherit the behaviors and methods defined in SelectMixin.

Cocktail brings two simple things to the table:

  • it adds the special mixins:[...] notation to Backbone’s extend.
  • it automatically detects and handles method collisions. In the example above Cocktail will wrap MyView‘s and SelectMixin‘s implementations of initialize into one method and assign that method to the new, composite, class. The return value of this composite method is the last non-undefined value returned by the methods it wraps. All colliding methods are handled this way, as is the events hash (the events hashes all get merged together).

There are more details and examples at the repo. In particular, there’s an example for testing mixins with Jasmine — it goes over a pattern for writing shared behaviors in Jasmine.

  • 0 Shares
  • Share on Facebook
  • Share on Twitter
John Barker

NYC Standup 7/23/2012 – Goodbye, my Coney Island baby

John Barker
Monday, July 23, 2012

Events

  • Wednesday – Book club: “Kestrels, Quirky Birds, and Hopeless Egocentricity”

Discussing second half of “Kestrels, Quirky Birds, and Hopeless Egocentricity” by Reginald Braithwaite

  • Tuesday – Brownbag: “A culture of awesome brokenness”

Matt Parker will be showing the video “A culture of awesome brokenness”

  • 0 Shares
  • Share on Facebook
  • Share on Twitter
John Barker

Standup NY 7-23-2012

John Barker
Monday, July 23, 2012

Events

  • Wednesday – Book club: “Kestrels, Quirky Birds, and Hopeless Egocentricity”

Discussing second half of “Kestrels, Quirky Birds, and Hopeless Egocentricity” by Reginald Braithwaite

  • Tuesday – Brownbag: “A culture of awesome brokenness”

Matt Parker will be showing the video “A culture of awesome brokenness”

  • 0 Shares
  • Share on Facebook
  • Share on Twitter
Laurence Koret

Buzz: it sounds like a beehive in here

Laurence Koret
Friday, July 20, 2012

The Problem

Our New York office’s sound system was, frankly, awful. It had a persistent background buzz, a loud hum, which we could not get rid of until we re-engineered our audio cabling.

The Fix

We switched to shielded cabling and professional-grade connectors, and when we finished we no longer heard the buzz. And we are able to drive our sound system with an iPhone.

The 50 foot unshielded cables

In our original setup, we had pulled a 50 foot cable over an air-conditioning duct and lighting fixtures. Even though it was a thick gauge wire, it was not shielded.

[Unshielded wires are susceptible to ground loops and electrical interference. In audio cables, this usually results in a background hum or buzz.]

The cable had a 1/4″ phono plug on both ends. This is a 1950s connector which was used on large headphones and electric guitars. Numerous adapters were cobbled together to connect the sound source to the audio system. The results were uniformly dismal: no matter what we played, no matter how it was connected, it always sounded terrible.

The Final Setup

After some research, we settled on the following:

  • 2 x 50 foot shielded cables with XLR connectors (professional audio connectors). We used these cables to connect our DI box (see below) to our mixer in the front of the room.
  • A direct-in or (DI) box. In our setup, we used a Radial ProAV2 Passive Stereo DI with RCA 3.5mm XLR and 1/4in Inputs.

  • We also have a Sescom SES-IPOD-RCA03 3.5mm Mini Stereo Plug to Dual RCA Male Plugs. These are used when we need to connect an iPhone or another 3.5 mm jack device. This allows us to play an audio source from the back of the room.

  • 0 Shares
  • Share on Facebook
  • Share on Twitter
Mike Barinek

American Thrombosis and Hemostasis Network (ATHN) is looking for a Web Application Developer

Mike Barinek
Friday, July 20, 2012

At Pivotal Labs, one of the services we provide our clients is helping them interview and hire. Pivotal Labs and our clients place a strong emphasis on Agile development and its many aspects: Pair Programming, Test-Driven Development, rapid iterations, and frequent refactoring.

Rails and Mobile Developer

The American Thrombosis and Hemostasis Network (ATHN) is the coordinating body for a not for profit network of a 100+ blood disorder treatment centers. ATHN provides centralized technology solutions to support the research into and management of rare blood disorders. ATHN is building web and mobile management and research applications designed to improve the health and treatment of these rare blood disorders.

We are looking for a developer to create cutting edge mobile and web tools to collect, organize and analyze Big Data (ATHN has treatment data for hemophilia going back more than 30 years). Responsibilities include interpreting requirements to identify, evaluate and implement technical solutions.
ATHN’s technical team is close-knit unit, lead by ATHN’s Director of Operations. All team members work remotely from their homes. We rely heavily on Skype, Pivotal Tracker and other collaboration tools to stay in touch. If working with a dedicated group of technology professionals and helping improve the lives of tens of thousands of patients appeals to you, we urge to you apply.

Job Requirements

  • Self motivation and the capability to operate independently
  • Excellent oral and written communication skills
  • 1+ years experience building with the Ruby language and the Rails framework, be proficient with the entire Ruby on Rails stack
  • 1+ years experience building native iPhone applications, be proficient with Objective-C and Cocoa Touch
  • Published 1 or more apps to the App Store
  • 2+ years of hands-on web development experience demonstrating:
  • Proficiency with HTML/XHTML, JavaScript, CSS and JQuery
  • Sound object oriented design skills and knowledge of application architecture patterns
  • Competency in Cocoa design patterns and API design
  • Passionate about end-to-end and user experience design
  • Proficiency with relational databases, included design and development
  • Ability and desire to thrive in an Extreme Programming environment, including pair programming
    Desired Skills
    In addition to the required skills, the ideal candidate will have the following skills:
  • Working knowledge and comfort developing UI and UX using Photoshop
  • Working knowledge of test-driven development and related frameworks(preferably RSpec)
  • Working knowledge of Backbone.js
  • Experience developing mobile web applications using JavaScript, HTML 5 and CSS, JQuery Mobile
  • Experience with mobile development frameworks and environment ex. PhoneGap and Monotouch
  • Experience building native Android Applications
  • Qualifications B.A or B.S or relevant experience

Inquires can be submitted to cwatson@athn.org.

  • 0 Shares
  • Share on Facebook
  • Share on Twitter
Robbie Clutton

Testing within an ActiveRecord block

Robbie Clutton
Thursday, July 19, 2012

Following on from the article about ActiveRecord blocks and a similar topics at the office book club, I’ve been trying to put some of these concepts into my code. I did find it difficult to figure out how to test within the block. Below I’ll outline what we did to test the code within the block.

Say we’ve got a Foo class which inherits from ActiveRecord.

class Foo < ActiveRecord::Base end 

When create a new foo, we can use a block to mutate the object.

Foo.create(args) do |foo| foo.x = 1 end 

In the test, we want to return a stub, but we can’t assert that x was called on that stub as the block won’t be executed.

Foo.should_receive(:create) { foo_stub } foo_stub.should_receive(:x=) # assertion fails 

We can use a block after the ‘should_receive’ call to get the block as a Proc and call it with the stub we want to run assertions on.

Foo.should_receive(:create) do |args, &block| block.call(foo_stub) end 

Now we can successfully test inside the block.

  • 0 Shares
  • Share on Facebook
  • Share on Twitter
Georg Apitz

Jasmine Testing: Param(s) passed to a method.

Georg Apitz
Thursday, July 19, 2012

Recently, I’ve been using a nice way to test if the correct arguments have been passed to a method. This uses a neat property of jasmine where you set up the method you want to test as a mock and have an expectation inside the mock.

The only caveat is you have to set an expectation that your mock get’s called, otherwise if it never gets executed the test will also never fail.

Step by Step

1) Set up the spy on the method for which you want to test the params.
2) Set up the expectation to compare a param to an expected value.

spyOn(App.Views.MasterView.prototype, 'initialize').andCallFake(function() {
 expect(arguments[0].template).toEqual(JST['my_templates/simple_view']);
});

3) Call something that should call the method under test with the correct params.

var router = new App.Routers.ViewRouter;
router.simpleViewInit();

4) Set up an expecatation that makes sure the method under test get’s actually called.

expect(App.Views.MasterView.prototype.initialize).toHaveBeenCalled();

Here you go, now it is easy to test if a method is called with the expected param(s).

The complete test.

describe('App.Routers.ViewRouter', function() {
  beforeEach(function() {
    Backbone.history.start();
  });

  afterEach(function() {
    Backbone.history.stop();
  });

    describe('#simpleViewInit', function() {
        it('call initialize on the MasterView with the simple_view template', function() {
        spyOn(App.Views.MasterView.prototype, 'initialize').andCallFake(function() {
             expect(arguments[0].template).toEqual(JST['my_templates/simple_view']);
          });
          var router = new App.Routers.ViewRouter;
          router.simpleViewInit();

         expect(App.Views.MasterView.prototype.initialize).toHaveBeenCalled();
        });
    });
});

The code that is under test.

App.Routers.ViewRouter = App.Routers.BaseRouter.extend(
{
    routes: {
        'example1': 'example1'
    },

    initialize: function() {
        ...
    },

    simpleViewInit: function() {
        this.simpleViewRecord = new App.Models.SimpleViewRecord();
        this.simpleView = new App.Views.MasterView({
            el: '#view_element',
            model: this.simpleView,
            template: JST[''my_templates/simple_view''],
            state: 'expired'
        });

        this.simpleViewInit.fetch({
            success: function(model) {
              model.trigger('change');
            }, silent: true
        });
    }
});
  • 0 Shares
  • Share on Facebook
  • Share on Twitter
Jeff Saracco

Standup NY 7-19-2012

Jeff Saracco
Thursday, July 19, 2012

Interestings

  • automated deploys with jenkins

TL;DR:

exec ssh-agent ./path/to/your/build/script

We setup our ci server to deploy (via capistrano) our app to an “acceptance” environment after a successful build. However, the ssh configuration on the environment we deploy to confuses the ruby net-ssh library, rendering the “forward-agent” option in capistrano useless. Therefore, our build script needed to manually add keys to the ssh-agent.

To make an ssh-agent available to your build script in jenkins, wrap the shell command for your build script in “exec ssh-agent”:

exec ssh-agent ./path/to/your/build/script

Your build script will be executed as a subprocess of the agent. When the command finishes, the agent dies with it.

To help DRY up your stylesheets, SCSS allows for inheritance. Take the following example:

.btn-red {
height: 20px;
width: 20px;
border-radius: 5px 5px 5px 5px;
background-color: #FF0000;
}

.btn-white {
height: 20px;
width: 20px;
border-radius: 5px 5px 5px 5px;
background-color: #FFFFFF;
}

Notice the similarities between the three classes; copying & pasting style declarations should tickle the same spidey sense that copying & pasting Ruby code does. Fortunately, SCSS offers @extend, which can be used like so:

.btn {
height: 20px;
width: 20px;
border-radius: 5px 5px 5px 5px;
}

.btn-red {
@extend .btn;
background-color: #FF0000;
}

.btn-white {
@extend .btn;
background-color: #FFFFFF;
}

Events

  • Machine learning meetup tonight
  • 0 Shares
  • Share on Facebook
  • Share on Twitter

Topics

  • agile (778)
  • rails (113)
  • testing (87)
  • ruby (83)
  • ruby on rails (70)
  • jobs (62)
  • javascript (54)
  • techtalk (44)
  • rspec (38)
  • activerecord (29)
  • productivity (29)
  • gogaruco (29)
  • ironblogger (29)
  • git (28)
  • nyc (27)
  • rubymine (25)
  • bloggerdome (22)
  • mobile (22)
  • cucumber (20)
  • process (19)
  • pivotal tracker (19)
  • jasmine (19)
  • design (18)
  • ios (18)
  • webos (17)
  • objective-c (17)
  • android (16)
  • palm (16)
  • "soft" ware (16)
  • fun (15)
  • tracker ecosystem (15)
  • ci (15)
  • cedar (15)
  • rails3 (14)
  • performance (14)
  • bdd (14)
  • gem (13)
  • tdd (13)
  • selenium (12)
  • css (12)
  • goruco (12)
  • bundler (12)
  • meetup (11)
  • railsconf (11)
  • nyc-standup (11)
  • capybara (10)
  • mac (10)
  • mojo (10)
  • chef (10)
  • api (10)
Subscribe to Community Feed
  1. ←
  2. 1
  3. 2
  4. 3
  5. 4
  6. →
  • About
  • Case Studies
  • Team
  • Community
  • Careers
  • Contact
  • Labs
  • Events

Contact Us

contact@pivotallabs.com
+1 415-77-PIVOT
TwitterLinkedInFacebook

Pivotal Tracker

Tracker is the award-winning agile project management tool that enables real-time collaboration around a shared, prioritized backlog.
Visit pivotaltracker.com >