How to quickly find a PR on github or ghe

Leave a comment

Go to your repos


Click Pull Requests

Screen Shot 2016-12-07 at 12.07.28 PM.png

Click the type of PR you are looking for

Screen Shot 2016-12-07 at 12.07.42 PM.png

Then search

Screen Shot 2016-12-07 at 12.07.51 PM.png

How to add a flash message to your Rails Twitter Bootstrap application

Leave a comment

To get these nice Twitter Bootstrap alerts to show up in your Rails application


Emit them from your Rails app like this.


 class SomeController < ApplicationController

  before_action :last_page

  def what_is_automated_testing
    flash[:success] = 'Success'
    flash[:info] = 'Info'
    flash[:warning] = 'Warning'
    flash[:danger] = 'Danger'
    render layout: "static_page_with_sidebar"

Now, if you have Twitter bootstrap correctly configured, you should see this.


If you are wondering why you don’t see this styling with the rest of your application, it’s because Rails by default doesn’t use this hashes (success, info, warning, etc) for it’s messages. It uses ‘notice’ and others instead (though some may overlap) which is defined in the defaul scaffold.scss so beware of that.

Happy styling!

Links that help


How to Rails nested layouts

Leave a comment

Say you have several static but similarly designed web pages, but you don’t want to copy and paste all the same HTML again and again.

Here is an example of two views, both static pages, the use nested Rails views to do slightly different rendered from one another.

One page is called bar. It has a sidebar. The other is called baz – it does not.

Give you application.html.erb a fancy content_for yield.


<!DOCTYPE html>

<%= render 'layouts/header' %>


<%= render 'layouts/navbar' %>
<div class='container-fluid'>

  <%= render 'layouts/alerts' %>
<div class="row-fluid">
<div class="col-md-9">
<div id="content"><%= content_for?(:content) ? yield(:content) : yield %></div>
<div class="col-md-3">
      <%= render 'shared/site_sidebar' %></div>

This is how rails let’s you dynamically define content that can be later filled in.

Setup your routes


  get '/bar',   to: 'static_pages#bar'
  get '/baz',   to: 'static_pages#baz'

Setup your controller to use your custom static page layout


class StaticPagesController < ApplicationController

  def bar
    render layout: "static_page"

  def baz
    render layout: "static_page"


Define your custom static page layout


<% content_for :content do %>
    <%= content_for?(:static_page) ? yield(:static_page) : yield %>
<% end %>
<%= render template: "layouts/application" %>

There is some magic here. This is using Rails content_for as a means us letting you define content for this layout sometime later. We are going to set two different kinds of content here shortly – one for bar, one for baz.

But basically this magical line

    <%= content_for?(:static_page) ? yield(:static_page) : yield %>

Says: If there is content for an area defined for static_page, yield it. Else do a regular yield.

Define your two slightly different static pages

Now comes the fun part. Here we define two pages. Bar has a side bar, and baz hides it. But they both share the same layout.


<% provide(:title, 'Bar Page') %>

<% content_for :static_page do %>
<h1>What is Bar?</h1>
<% end %>


<% provide(:title, 'Baz Page') %>

<% content_for :stylesheets do %>
    #sidebar {display: none}
<% end %>

<% content_for :static_page do %>
<h1>What is Baz?</h1>
<% end %>

This reason this works is that in my header layout, I defined a yield on the style sheet.

<style><%= yield :stylesheets %></style>

Here is the full source for that


  <title><%= yield(:title) %></title>
<style><%= yield :stylesheets %></style>

  <%= csrf_meta_tags %>

  <%= stylesheet_link_tag    'application', media: 'all', 'data-turbolinks-track': 'reload' %>
  <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>

In baz, where we don’t want to show the sidebar, we can hide it by yielding some CSS into the style sheet like this.


<% content_for :stylesheets do %>
    #sidebar {display: none}
<% end %>

So now when baz renders, no side bar.


But when bar renders, we get the full sidebar.

Screen Shot 2016-12-04 at 9.55.57 AM.png

I found this whole process of setting this up very confusing. So don’t feel bad if you don’t get it. There aren’t many examples out there.

But if you are determined not to repeat code over and over again like I felt, hopefully this will help.

Cheers – Jonathan

Links that kind of help

How is IF LET in swift evaluate

Leave a comment

if let name = optionalName {

Essentially the line is saying, “if you can let the new variable name equal the non-optional version of optionalName, do the following with it”. As Martin pointed out, this is called Optional Binding.

The sole purpose of it is to test if an optional variable contains an actual value and bind the non-optional form to a temporary variable. This is the safe way to “unwrap” an optional or in other words, access the value contained in the optional. It is in no way testing for equality of any kind. It is only testing for the existence of a value within an optional.

How to clip image with Illustrator mask

Leave a comment

Setup your image, surround the area with a pen.

Screen Shot 2016-12-02 at 11.42.05 AM.png

Select both the mask and the image you want to clip.

Then go Cmd – 7 to make a mask.

Screen Shot 2016-12-02 at 11.36.18 AM.png

Screen Shot 2016-12-02 at 11.42.05 AM.png

Voila! Clipped image. Thank you Mirya for this tip. And yes I know ideally I would do this in photoshop.

Metrics Hygiene

Leave a comment

Thanks again to Jonathan Yeo for sharing this great article on how to think about metrics.

Call it a mission or a raison d’être or a value statement or whatever. It should be summable in a single sentence. There should be one not just for the entire company, but also for every team and every project within that company. When people hear this, they should feel inspired. Like it’s something they’d be excited to get and make happen every morning.

If your team, org, or company doesn’t have this, and instead has a bunch of metrics, it might be time to take a step back and think about how to better articulate the “why do we do what we do?” more clearly.

Then, you can start executing on the mission by breaking it down into its requisite milestones, each with its own set of metrics or measurements to help serve as guideposts for how well things are going.

Some rules of thumb for good metrics hygiene:

These are some of my learnings in my quest to become more and more disciplined about the tactics of good goal setting and measurement.

  • To assess for product-market fit, look at retention. Do not look at the sheer number of people using your product or feature (which can be skewed by things like how aggressively you promote it.) Retention best correlates with whether your product is valuable because it tells you whether people who tried it liked it enough to return and use it again.
  • To optimize for growth, understand your funnel. In order for people to become regular users of your product, they have to pass through a bunch of hurdles. First, they have to be aware of your product. Second, they have to be interested enough to check it out. Third, they have to convert (download an app, fill out a form, confirm e-mail, etc.) Fourth, they have to do enough within your product to understand why it might be valuable in their lives. Fifth, they have to remember to come back. At each of these steps, you will lose people. If you can track and measure what that rate of loss is, you can then start to figure out where to focus your efforts to make your funnel less leaky.
  • Figure out which metrics are truly important, and focus on those. It’s tempting to get into the state where you track everything (because you can), and you have a dashboard filled with numbers that all feel like they should be green. Recognize that most things don’t matter, and that only a small handful actually do. Don’t waste time talking about the unimportant stuff, and don’t sweat letting some of the less important metrics go up or down.
  • To figure out the best metric to track, use the magic-wand technique. Ask yourself: “If I could wave a magic wand and know anything about my users in the world, what would I most want to know to tell me whether my app will be successful?” Even if your answer is not something you can actually measure (“Is my app suggesting recommendations that my users find valuable?”), it is a helpful starting point to work from. (“Okay… so I can’t ask every user if the recs were valuable… but if it were valuable, I’d probably see them saving or sharing recs more, and they’d probably spend more time reading recs, and…etc, etc.”)
  • Don’t just accept a metrics goal without understanding it. I can’t emphasize this enough: the goals you and your team agree to will be hugely impactful to your work, so make sure you buy into them. Do not accept metric goals at face value. Ask why. Ponder whether or not they make sense, and what behaviors they will incentivize. Are there situations where something will feel like a good decision but the metric doesn’t move? Conversely, are there situations where you could imagine the metric going up a lot but not be convinced that the product is actually better? If so, would another metric (or set of metrics) do a better job of tracking what actually matters?
  • View data skeptically by suggesting countermetrics. If the data is showing you what look like good results, ask yourself: “What else can I look at to convince me that these results aren’t as good as they seem?” These are called countermetrics, and every success metric should have some. (For example, don’t look at click-through rate without looking at the number of fast bounces back, don’t look at the sales numbers of a product without looking at how many returns or cancellations there are, etc.) It’s much better to be paranoid about interpreting data so you can quickly catch your mistakes and adjust your strategy. Don’t fall into the trap of confirmation bias where you’re just looking for signals that prove your intuitions are right.
  • Use qualitative research to get at the why. Quantitative data that tells you what people did is best paired with qualitative research that give you insight into how people felt. Conduct usability testing, utilize focus groups, and run surveys to get at the why behind the behavior you’re seeing.

Taken from below:

Metrics Versus Experience

The Year of the Looking Glass

How we put Facebook on the path to 1 Billion people – Chamath Palihapitiya

Leave a comment


This is a great talk on how FB got to where they are, and some of the underlying principles that got them there.

Slides can be found here.

Some highlights for me were relentlessly focussing on these three things:

  1. How do you get people in the front door.
  2. How do you get them quickly to that ah ha moment as quickly as possible.
  3. How do you deliver core product value as often as possible.

A very powerful metric for them was also focusing on getting new users to 7 friends in 10 days. That was all they focused on in early days.

They also worked hard on removing ego from the product. And their recipe for success was basically this.

Screen Shot 2016-11-28 at 8.36.25 AM.png

No magic. It was as simple as that. Not some overly complex thing.

Screen Shot 2016-11-28 at 8.36.36 AM.png

Chamath is not a fan of trusting your gutt. Spent a lot of time debunking and invalidating lore, to disprove all the product decisions people were making based on gutt.

Screen Shot 2016-11-28 at 8.36.47 AM.png

Most people aren’t very good. That was his experience after working at AOL.

Screen Shot 2016-11-28 at 8.36.56 AM.png

Most products miss their core value, or focus on the wrong things.

Screen Shot 2016-11-28 at 8.37.17 AM.png

Story here was that FB didn’t get excited when they passed MySpace at 45M users. They knew they were winning, and they know they were going to get much larger. Because they new their business. They knew they had won.

Screen Shot 2016-11-28 at 8.37.22 AM.png

They didn’t talk about monetization or anything for 3 years. All they focused on at every townhall and Q&A was :

How to do we get people 7 friends in 10 days as quickly as possible.

Special thank you Jonathan Yeo for sharing this video with the team.








Older Entries

%d bloggers like this: