iMessage Not Delivered

Leave a comment

If you get this error message on your childs iPad try the following:

Goto Settings -> General -> Date & Time

And turn on ‘Set Automatically’. If it’s already on turn it off and on again.
If you are still stuck go

Settings -> Messages and logout and log back in again.

For some reason this has fixed my kids iPad problems multiple times.

Links that help

http://support.apple.com/kb/ts4268

Leadership and Choice – Carly Fiorina (former CEO HP)

Leave a comment

There have been two excellent podcasts from the Stanford Entrepreneurial Thought Leader series that bear recording. One from Carly Fiorina. And another from Carol Bartz of Autodesk.

What resonated most with me about these two podcasts was:
1. Don’t try to overplan your career.
2. That old cliche about change being hard.

Carol (a straight talker) came right out and said: ‘No body cares about your career except you and your mother.’ And that you shouldn’t create fixed narrow straight up the ladder career paths because:
a) your focus will be too narrow
b) you won’t have a good foundation

If you want to be CEO, VP, or some high-level executive a broad range of experiences is better than shooting straight up the ladder – because eventually you will fall over.

I also like the fact she never knew exactly where she was going next. Her whole attitude was is you saw something that was interesting, run with it, do it well, and chances are someone will notice and reward you with another opportunity. Just do it!

This is empowering. It means if there is a job or position you want, just show the initiative, get involved, and go for it. Chances are it will work out.

Carly gave what has probably been one of the best leadership talks I have ever heard. She describes leadership as facing two huge obstacles:
1. Fear
2. Status quo

Everyone fears something. And people in positions of power want to preserve the status quo. Not because they are evil people. But because it’s comfortable, and it’s good for them! It’s natural and many of us would do it to in similar circumstances.

But leadership isn’t status quo. It’s about creating that vision for change.

Carly has one of the best stories of leadership I have heard. She describes how after studying medival history at Stanford as an undergrad, and dropping out of law school after a year much to the disappointment of her parents, he talk a job as a secretary at a local business and worked there for a couple months.

A few months in, two gentlemen approached her and told her they thought she had potential to do more than answer the phone and asked if she would be interested in learning more about what they did around there.

That’s leadership. It’s seeing the potential and possibilities in others and then helping them seize them.

Income statements and balances sheets are lagging indicators

An income statement of a balance sheet is an indication of decisions already made. Somebody has bought a product, that’s revenue. A manager has made a decision about expenses, that’s an expense you post. Lagging indicator. Important but you are looking in the rear view mirror.

THere are things that tell you where a business is going. Asking the right questions of customers is really important. Customer satisfaction is the leading indicator of how a company is doing.

Single greatest indicator of a company’s health

Carly’s single greatest factor as to whether a company is doing well or a company is doing poorly is customer satisfaction. This is why Carly boldly announced in 2002 that in a few years time HP would be the world leader in technology surpassing both IBM and Dell in sales. She knew this because she knew HP could replicate Dells cost structure, they could replicate their distribution and Dell had stopped innovating, and there customer satisfaction ratings were falling while HPs were going up.

Dell had quit innovating. They had stopped taking risks. They had stayed with the same competitive model for too long and their customer satisfaction was straight down.

A companies ability to take risks is also an indicator of a leading business.

Customers always know what’s wrong. And every time they do, it’s an opportunity.

Leadership

Carly then goes on to describe leadership further as:
1. Capability.
2. Collaboration.
3. Character.

Capability

Every company eventually hits a point where the old answers don’t work anymore. And when that happens it’s only creativity, risk taking that can save the company (innovators dilemma).

Learn something every day. Those most adaptive to change survive. True of species, organizations, and people.

You can’t ever settle in. Don’t get old before your time.

Collaboration

Good decisions are a result of diverse people coming together and examining every point of view in a deliberate, rigorous, process, and then making a decision.

Groupthink is the enemy. People all alight and get together and agree. It’s human nature because we all want to surround ourselves with people like us. It’s comfortable. It’s easier. You finish each others sentences. You can relate. But one day you are going to miss something.

The goal is to always build a diverse group of people. Because you make better decisions. It’s harder. But it’s better because you get better answers.

Anybody can play today. But not if we can’t leverage. So learning how to collaborate with people with different POV than you is a very important leadership skill.

Character

Character is about judgement, perspective, and ethics.

Judgement – being able to take loads of information, and distill it down to it’s core. Should I act? Or should I pause. Do I have all the information? How do I filter the good information from the bad. The necessary from the irrelevant. That’s judgement.

Perspective – understand the difference between the interesting vs the important. Not everyone is like you. Need to understand those differences. Carly encourage people to read history, art, travel the world. All that gives you perspective about what’s out there.

Ethics – in most organizations and in most endeavors if you do things that are on the line, or one the edge, you can get better results in the short term. That’s why a lot of businesses tolerate businesses that are on the edge.

Values are what guides your behavior when no one is looking and don’t think anyone is going to find out. Leaders most important job is making people understand that values actually matter. Ethics count.

And that we are not going to do things on the edge, because eventually we are going to cross the line. Devastating things then happen. You can’t hide anything anymore. So you can’t get close to the edge.

Summary

This was an awesome talk about an awesome leader and I encourage anyone interested to listen to the full podcast on the link(s) below.

Note this is also available on iTune as a podcast (great for commutes).

http://ecorner.stanford.edu/authorMaterialInfo.html?mid=1557

http://ecorner.stanford.edu/authorMaterialInfo.html?mid=1679

How to Create Rails SignUp Page

Leave a comment

Some notes from http://www.railstutorial.org/book/_single-page#cha-sign_up

sign-up

config/routes.rb

  match '/signup',  to: 'users#new',            via: 'get'
end

Gemfile

group :test do
  gem 'selenium-webdriver', '2.35.1'
  gem 'capybara', '2.1.0'
  gem 'factory_girl_rails', '4.2.0'
end

> bundle install

spec/factories.rb

 FactoryGirl.define do
  factory :user do
    name     "Michael Hartl"
    email    "michael@example.com"
    password "foobar"
    password_confirmation "foobar"
  end
end

config/environments/test.rb

 SampleApp::Application.configure do
  # Speed up tests by lowering bcrypt's cost function.
  ActiveModel::SecurePassword.min_cost = true
end

app/views/users/show.html.erb

 <% provide(:title, @user.name) %>
<h1>
  <%= gravatar_for @user %>
  <%= @user.name %>
</h1>

app/helpers/users_helper.rb

 module UsersHelper

  # Returns the Gravatar (http://gravatar.com/) for the given user.
  def gravatar_for(user)
    gravatar_id = Digest::MD5::hexdigest(user.email.downcase)
    gravatar_url = "https://secure.gravatar.com/avatar/#{gravatar_id}"
    image_tag(gravatar_url, alt: user.name, class: "gravatar")
  end
end

app/views/users/new.html.erb

<%= provide(:title, 'Sign Up') %>

<div class="container">

  <%= form_for(@user, :html => {:class => 'form-signin'}) do |f| %>
      <h2 class="form-signin-heading">Sign Up</h2>
      <%= render 'shared/error_messages' %>

      <%= f.label :name %>
      <%= f.text_field :name %>

      <%= f.label :email %>
      <%= f.text_field :email %>

      <%= f.label :password %>
      <%= f.password_field :password %>

      <%= f.label :password_confirmation, "Confirmation" %>
      <%= f.password_field :password_confirmation %>

      <div class="text-centered">
        <%= f.submit "Create my account", class: "btn btn-large btn-primary" %>
      </div>
  <% end %>

</div>

app/views/shared/_error_messages.html.erb

 <% if @user.errors.any? %>
  <div id="error_explanation">
    <div class="alert alert-error">
      The form contains <%= pluralize(@user.errors.count, "error") %>.
    </div>
    <ul>
    <% @user.errors.full_messages.each do |msg| %>
      <li>* <%= msg %></li>
    <% end %>
    </ul>
  </div>
<% end %>

app/assets/stylesheets/custom.css.scss

/* forms */
#error_explanation {
  color: #f00;
  ul {
    list-style: none;
    margin: 0 0 18px 0;
  }
}

.field_with_errors {
  @extend .control-group;
  @extend .error;
}

app/assets/stylesheets/signin.css.scss

/* sign in */
.form-signin {
    max-width: 300px;
    padding: 19px 29px 29px;
    margin: 0 auto 20px;
    background-color: #fff;
    border: 1px solid #e5e5e5;
    -webkit-border-radius: 5px;
    -moz-border-radius: 5px;
    border-radius: 5px;
    -webkit-box-shadow: 0 1px 2px rgba(0,0,0,.05);
    -moz-box-shadow: 0 1px 2px rgba(0,0,0,.05);
    box-shadow: 0 1px 2px rgba(0,0,0,.05);
}

.form-signin .form-signin-heading,
.form-signin .checkbox {
    margin-bottom: 10px;
}

.form-signin input[type="text"],
.form-signin input[type="password"] {
    font-size: 16px;
    height: auto;
    margin-bottom: 15px;
    padding: 7px 9px;
}

Adding flash

<strong>app/views/layouts/application.html.erb</strong>
 <!DOCTYPE html>
<html>
  .
  .
  .
  <body>
    <%= render 'layouts/header' %>
    <div class="container">
      <% flash.each do |key, value| %>
        <div class="alert alert-<%= key %>"><%= value %></div>
      <% end %>
      <%= yield %>
      <%= render 'layouts/footer' %>
      <%= debug(params) if Rails.env.development? %>
    </div>
    .
    .
    .
  </body>
</html>

app/controllers/users_controller.rb

 class UsersController < ApplicationController

  def create
    @user = User.new(user_params)
    if @user.save
      flash[:success] = "Welcome to the Sample App!"
      redirect_to @user
    else
      render 'new'
    end
  end

  private

    def user_params      	

params.require(:user).permit(:name, :email, :password_digest, :admin, :password, :password_confirmation)
    end
end

spec/requests/user_pages_spec.rb

require 'spec_helper'

describe 'User pages' do

  subject { page }

  describe 'signup page' do
    before { visit signup_path }

    it { should have_content('Sign Up') }
    it { should have_title('AC Sign Up') }
  end

  describe "signup" do

    before { visit signup_path }

    let(:submit) { "Create my account" }

    describe "with invalid information" do
      it "should not create a user" do
        expect { click_button submit }.not_to change(User, :count)
      end
    end

    describe "with valid information" do
      before do
        fill_in "Name",         with: "Example User"
        fill_in "Email",        with: "user@example.com"
        fill_in "Password",     with: "foobar"
        fill_in "Confirmation", with: "foobar"
      end

      it "should create a user" do
        expect { click_button submit }.to change(User, :count).by(1)
      end

      describe "after saving the user" do
        before { click_button submit }
        let(:user) { User.find_by(email: 'user@example.com') }

        # it { should have_link('Sign out') }
        it { should have_title(user.name) }
        it { should have_selector('div.alert.alert-success', text: 'Welcome') }
      end
    end
  end

end

How to convert an image into vector illustrator

Leave a comment

When copying or converting images, it’s very handy to create uneditable opaque layers to trace over. You do this by:

Creating a new layer

create-new-layer

Then make it transparent

transparency

Then you can start tracing

start-tracing

Links that help

How to create User Rails

Leave a comment

As summary of notes take from Michael Haretl’s excellent tutorial

http://www.railstutorial.org/book/_single-page#cha-modeling_users

Create User
> rails generate scaffold User name:string email:string password_digest:string remember_token:string admin:boolean
> rails generate controller Users new –no-test-framework
> rake db:migrate
> rake test:prepare

Setup Gemfile

source 'https://rubygems.org'

gem 'rails', '4.0.0'
gem 'sqlite3'
gem 'sass-rails', '~> 4.0.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.0.0'
gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 1.2'

gem 'rspec-rails', '2.13.1'

group :test do
  gem 'selenium-webdriver', '2.35.1'
  gem 'capybara', '2.1.0'
end

gem 'bcrypt-ruby', '~> 3.0.0'

> bundle install

Create test file

spec/models/user_spec.rb

require 'spec_helper'

describe User do

  before do
    @user = User.new(name: "Example User", email: "user@example.com",
                     password: "foobar", password_confirmation: "foobar")
  end

  subject { @user }

  it { should respond_to(:name) }
  it { should respond_to(:email) }
  it { should respond_to(:password_digest) }
  it { should respond_to(:password) }
  it { should respond_to(:password_confirmation) }
  it { should respond_to(:remember_token) }
  it { should respond_to(:authenticate) }
  it { should respond_to(:admin) }

  it { should be_valid }
  it { should_not be_admin }

  describe "with admin attribute set to 'true'" do
    before do
      @user.save!
      @user.toggle!(:admin)
    end

    it { should be_admin }
  end

  describe "when name is not present" do
    before { @user.name = " " }
    it { should_not be_valid }
  end

  describe "when email is not present" do
    before { @user.email = " " }
    it { should_not be_valid }
  end

  describe "when name is too long" do
    before { @user.name = "a" * 51 }
    it { should_not be_valid }
  end

  describe "when email format is invalid" do
    it "should be invalid" do
      addresses = %w[user@foo,com user_at_foo.org example.user@foo.
                     foo@bar_baz.com foo@bar+baz.com foo@bar..com]
      addresses.each do |invalid_address|
        @user.email = invalid_address
        expect(@user).not_to be_valid
      end
    end
  end

  describe "when email format is valid" do
    it "should be valid" do
      addresses = %w[user@foo.COM A_US-ER@f.b.org frst.lst@foo.jp a+b@baz.cn]
      addresses.each do |valid_address|
        @user.email = valid_address
        expect(@user).to be_valid
      end
    end
  end

  describe "when email address is already taken" do
    before do
      user_with_same_email = @user.dup
      user_with_same_email.email = @user.email.upcase
      user_with_same_email.save
    end

    it { should_not be_valid }
  end

  describe "when password is not present" do
    before do
      @user = User.new(name: "Example User", email: "user@example.com",
                       password: " ", password_confirmation: " ")
    end
    it { should_not be_valid }
  end

  describe "when password doesn't match confirmation" do
    before { @user.password_confirmation = "mismatch" }
    it { should_not be_valid }
  end

  describe "with a password that's too short" do
    before { @user.password = @user.password_confirmation = "a" * 5 }
    it { should be_invalid }
  end

  describe "return value of authenticate method" do
    before { @user.save }
    let(:found_user) { User.find_by(email: @user.email) }

    describe "with valid password" do
      it { should eq found_user.authenticate(@user.password) }
    end

    describe "with invalid password" do
      let(:user_for_invalid_password) { found_user.authenticate("invalid") }

      it { should_not eq user_for_invalid_password }
      specify { expect(user_for_invalid_password).to be_false }
    end
  end

  describe "remember token" do
    before { @user.save }
    its(:remember_token) { should_not be_blank }
  end

end

Setup Model

app/models/user.rb

class User < ActiveRecord::Base

  before_save { self.email = email.downcase }
  before_create :create_remember_token
  validates :name, presence: true, length: { maximum: 50 }
  VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-]+(\.[a-z]+)*\.[a-z]+\z/i
  validates :email, presence: true, format: { with: VALID_EMAIL_REGEX },
                    uniqueness: { case_sensitive: false }
  has_secure_password
  validates :password, length: { minimum: 6 }

  def User.new_remember_token
    SecureRandom.urlsafe_base64
  end

  def User.hash(token)
    Digest::SHA1.hexdigest(token.to_s)
  end

  private

    def create_remember_token
      self.remember_token = User.hash(User.new_remember_token)
    end
end

Deprecation warning

To get rid of [deprecated] I18n.enforce_available_locales will default to true in the future

config/application.rb

require File.expand_path('../boot', __FILE__)

module SampleApp
  class Application < Rails::Application
    I18n.enforce_available_locales = true
  end
end

To handle uniqueness
> rails generate migration add_index_to_users_email

db/migrate/[timestamp]_add_index_to_users_email.rb

 class AddIndexToUsersEmail < ActiveRecord::Migration
  def change
    add_index :users, :email, unique: true
  end
end

> rake db:migrate
> rake test:prepare

Configure capybara
spec/spec_helper.rb

 # This file is copied to spec/ when you run 'rails generate rspec:install'
RSpec.configure do |config|
  config.include Capybara::DSL
end

Comment out a couple PUT/POST tests in users_controller_spec.rb as these pages don’t
contain password and password confirmation fields. Will test those separate using capybara.

How to Install Capybara with RSpec Rails

Leave a comment

Gemfile

group :development, :test do
  gem 'sqlite3'
  gem 'rspec-rails', '2.13.1'
end

group :test do
  gem 'selenium-webdriver', '2.35.1'
  gem 'capybara', '2.1.0'
end

> bundle install
> rails generate rspec:install

spec/spec_helper.rb

RSpec.configure do |config|
  config.include Capybara::DSL
end

Note: this is different than plan rspec gem. It’s an rspec gem specially designed for rails that creates it’s own spec_helper.

How to create static pages Rails

Leave a comment

> rails g controller StaticPages home help --no-test-framework

config/routes.rb

root  'static_pages#home'

get "static_pages/home"
get "static_pages/help"

app/controllers/static_pages_controller.rb

class StaticPagesController < ApplicationController

  def home
  end

  def help
  end
end

Older Entries

Follow

Get every new post delivered to your Inbox.

Join 324 other followers

%d bloggers like this: