Sunday, July 31, 2016

Saturday, July 30, 2016

Bloom's Taxonomy for Software Development

You can read the basics of Blooms Taxonomy. Bloom’s revised taxonomy of cognitive processes for our purpose of software development education is as follows:

  1. Remember
  2. Understand 
  3. Apply 
  4. Analyze 
  5. Evaluate and
  6. Create

For self-learning, we can use this revised Bloom's taxonomy of learning outcomes. Note that we don't use the knowledge dimension and cognitive process dimension. We stay at the highest level.

References

Project-centric Evolutionary Teaching in Software Development Education
Bloom’s Taxonomy wrt Software Development Education

Friday, July 29, 2016

RubyPlus Screencast Feed

Learn practical tips and techniques on how to develop web applications using Ruby on Rails web framework. The episodes are short to minimize the amount of content to avoid overwhelming learners. The episodes are designed to give developers a quick way to get their feet wet and learn by building web apps.

Wednesday, July 27, 2016

How to find out where ruby executable is installed

$ irb --simple-prompt -rrbconfig
> RbConfig::CONFIG['bindir']
 => "/Users/bparanj/.rvm/rubies/ruby-2.2.3/bin"
> exit
~ bparanj$ ruby -v
ruby 2.2.3p173 (2015-08-18 revision 51636) [x86_64-darwin14]
~ bparanj$ which ruby
/Users/bparanj/.rvm/rubies/ruby-2.2.3/bin/ruby
~ bparanj$

Key Ruby Directories and their RbConfig Terms

~ bparanj$ irb --simple-prompt -rrbconfig
> RbConfig::CONFIG['vendordir']
 => "/Users/bparanj/.rvm/rubies/ruby-2.2.3/lib/ruby/vendor_ruby"
> RbConfig::CONFIG['sitedir']
 => "/Users/bparanj/.rvm/rubies/ruby-2.2.3/lib/ruby/site_ruby"
> RbConfig::CONFIG['archdir']
 => "/Users/bparanj/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/x86_64-darwin14"
> RbConfig::CONFIG['rubylibdir']
 => "/Users/bparanj/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0"

Beautiful Markup Rails Conf Presentation Notes

Learn the html elements. Download HTML 5 and CSS 3 smashingmagazine cheatsheets.
Don't use div_for?.
Use content_tag only if necessary.
Avoid markup in helpers.
Web accesibility: Use alt tags in link_to and image_tag.
Use CSS Sprites with Rails helper methods. SVN 37signals blog article.
image_sprite :email, class: 'email', title: 'Email'
Checkout deadweight and startups gems.
Dust Me Selectors Firefox add on.
Checkout rack-tidy gem

RubyPlus Podcast Episode 10


Sunday, July 24, 2016

Unit Test and Number of Assertions

Good unit tests should fail for exactly one reason, that's why you should be using one assert per unit test. 
Test one logical concept per test. You can have multiple asserts on the same object. They will usually be the same concept being tested. Roy Osherove.

Tuesday, July 19, 2016

Movie Review Rails 5 App Screencasts

The first 6 episodes of RubyPlus screencasts is based on the following articles.

1. Integrating Twitter Bootstrap 4 with Rails 5
2. Twitter Bootstrap 4 Forms and Navigation in Rails 5

- Tab highlighting
- Border and Box Shadow Effect

3. Implementing Search Feature using Searchkick, Twitter Bootstrap 4 and Rails 5

- ElasticSearch
- Searchkick

4. Using Star Rating jQuery Plugin Raty with Twitter Bootstrap 4 in Rails 5 Apps

- JQuery Raty Plugin for Star Rating

ReferenceError: Stripe is not defined

1. Make sure you have:
<body data-no-turbolink>

2. <script src="https://js.stripe.com/v2/"></script>



Possible Problem:
<script src="https://js.stripe.com/v2/"></script>

Possible Fix: 



Remove the comma in the form:




<form action="create" method="POST" id="payment-form", class='form-horizontal'>

Friday, July 15, 2016

RailsConf 2016 - Get a Whiff of This by Sandi Metz

The Problem

If you have watched this video:  https://www.youtube.com/watch?v=PJjHfa5yxlU  you will see around 30 mins mark, the code that looks like this:





This test does not test anything. She has stubbed her test, so it is meaningless. The test proves that a double class you created returns 47 in the assertion. You should never stub yourself out in a test. State based testing in this case is not the right choice. You can also pass junk values for the starting and ending values, the test will still pass. You can even pass empty params, the test will still pass.

You want exactly one test to fail for any given bug. This test will fail if you change 47 to any other number, string, nil or anything else. The emphasis of the current test is not on whether the message to total was sent or not.

Tests that are not written with their role as specifications in mind can be very confusing to read. The difficulty in understranding what they are testing can greatly reduce the velocity at which a codebase can be changed. Nat Pryce and Steve Freeman "Are your tests really driving your development?"

The Solution

What is the fix? The total class method belongs to our application and not ActiveRecord, so we can safely mock this method and still keep our tests running fast without hitting the database. I am shocked by how some of the speakers get their talks approved for a Railsconf with technical errors like this in their presentation.


Thursday, July 14, 2016

acts-as-taggable-on and Rails 5

Bundler could not find compatible versions for gem "activerecord":
  In snapshot (Gemfile.lock):
    activerecord (= 5.0.0)

  In Gemfile:
    acts-as-taggable-on (~> 3.4) was resolved to 3.4.0, which depends on
      activerecord (< 5, >= 3.2)

    rails (~> 5.0.0) was resolved to 5.0.0, which depends on
      activerecord (= 5.0.0)

Running `bundle update` will rebuild your snapshot from scratch, using only
the gems in your Gemfile, which may resolve the conflict.

Resolution:

gem 'acts-as-taggable-on', :git => 'https://github.com/mbleigh/acts-as-taggable-on'

Wednesday, July 13, 2016

div_for deprecated

You don't need any gem replace div_for with html tags. For example:

div_for(comment) becomes


<div id="comment_1234" >
  <td>My Comment</td>
</div>

Ruby Plus Podcast Episode 9





Simple Example for Value Capture in a Business

Almost everyone knows that a business needs to create value, but they probably don't know about capturing value. The simplest example is the CoinStar. Do you have a piggy bank that’s ready to burst, or a bag of change that you’d like to deposit into your account? CoinStar® machines quickly count up your coins and provide you with cash. A fee of 10% will be deducted from your deposit. The business captures value by charging a percentage of fees. CoinStar considers it's service to be of value, some of the people would consider that it adds enough value to give 10% of their deposit.

Friday, July 08, 2016

How to write technical articles

More I wrote, easier it became to create content. Whenever I encounter problems during development, I document the steps I took to resolve them and package it as an article. It also helps me to think clearly because I create a rough draft of the article by documenting every step I try and the outcome of my experiment.  I know it will save readers ton of time because I had to spend a fair amount of time to research and try different suggestions from other developers. I enjoy it a lot. Learning from other blogs, the research process and the satisfaction of resolving tough problems is very fulfilling.

Thursday, July 07, 2016

How do you know if your compensation is fair?

 I am blogging, engaged in the Ruby community and publish OS libraries. How do you compare salary wise among your peers? Check out payscale. Payscale will show you the percentile to give you an idea of where you stand. You can then decide if you want to aim even higher or happy with your current salary. Do you want to see what you would make if you worked at Buffer? Check out Buffer Salary.

ngrok screenshot


YAML Configuration Gems

yettings 

Create settings/constants for your Rails 3 app using a YAML file

figaro

Simple Rails app configuration

settingslogic

A simple and straightforward settings solution that uses an ERB enabled YAML file and a singleton design pattern.

While Figaro is easier to set up, Settingslogic allows nested configurations which feels for cleaner code.

Magiconf

Magiconf is a light-weight alternative to figaro that is designed to work directly with Rails. Easily store and access all your application's configuration data using a single yaml file. A great solution for storing passwords, dealing with heroku, and working in a team with different development environments.

config

Easiest way to add multi-environment yaml settings to Rails, Sinatra, Pandrino and other ruby projects.

A Practical Guide to Information Architecture by Donna Spencer

5 Different Methods to Analyze

Exploring the Data

Immerse yourself in the data and explore it a little. This gives you a feel for the type of information you have and the very high-level patterns. You can create a spreadsheet with columns source, tag, comment and frequency. Each row is an independent idea that you want to look at individually. Look at how people describe similar needs and whether there is consistency between sources.

Term Analysis

Term analysis is a technique used to learn about terminology and understand how people describe ideas. Choose something you want to know about and use your research notes to see how they describe it. Look for:
  • Words used to describe a concept
  • Synonyms
  • Antonyms
  • Related concepts
  • Broader and narrower terms
  • Concepts frequently mentioned together
The outcomes from this analysis can help you understand how people describe their information needs. It is also use for labeling navigation.

Affinity Diagramming

  1. Why does this happen?
  2. What is the underlying idea of this group of notes?
  3. What is important about this group of notes?

How People Think About Categories

I want to know more about X. It's better to arrange content around topics than around tasks or audiences.

People think at different levels of a hierarchy depending on their experience and knowledge about the topic. Domain experts think at a more detailed level than people who use their information. Aim to bridge the gap between the two.

Content You Need

The content should meet the needs of the people using your site and also achieve your project goals. Figure out what you can maintain with your available resources.

Current Behavior

Use web analytics to identify the most popular content. Check statistics for a long period to include topics that might be popular at different times of the year. Check what happens when new content is added? Does it peak and then never get used again?

Make the most popular content easier to find. Think about why people like this particular content and whether you can create more like it. Think whether you can use it to help people find other things. You can provide links to related content. Poor title can be the reason why good content is not popular. Visit sites like digg.com or delicious.com to see what's popular in your field. Check competitors or similar sites for top articles.

User Research

User research can uncover needs for functional items such as calculators, templates and tools.

Content Brainstorm

User research and business goals can guide you to come up with content ideas.

Competitor Analysis

Check the competitors content and see how well they do it. This can trigger some ideas. It must meet both the needs of your audience and project goals.

Task Based Classification Scheme

Task based scheme works well for web apps when:
  • There are only a small set of tasks
  • The main tasks have clear boundaries
  • Your content is easy to allocate to the task groups
Tasks follow the format: I need to x. I do y.

You can use a range of classification schemes:
  • Time
  • Alphabetic
  • Geography
  • Format
  • Organisational Structure
  • Task
  • Audience
  • Subject or topic
You can also mix them up.

Tagged Pattern

Item is tagged with keywords. The keywords provide access to the content. Useful when people don't know what they are looking for. The tags help people to explore and find related information.

Labels and Language

The words you use must:
  • Call things by their correct name
  • Are consistent
  • Use terminology of the audience
  • Are clear

Wednesday, July 06, 2016

How People Look for Information

Finding Known Items

Know what you want
Have words to describe it
May have a fairly good idea where to start
Know that there is an answer
Know when you see the answer

Jump into a website to find out something, get the answer and then leave. The best design solutions for this behavior are search and A-Z indexes.

Exploring

Have some idea of what you need to know
May not know how to articulate it
May not know the best terminology to use
May not know where to start looking

As you discover information and learn, the gap between your current knowledge and your target knowledge narrows. Links between relevant pages will help people move between things and build up knowledge. Search is not an ideal solution in this case.

Refining and Narrowing

This happens when you have a large number of items to choose and you want to narrow down to those that are of interest. You will usually have some criteria in mind when you start and you should be able to recognize products that meet that criteria. You may do some exploring at the start to learn about what is important and to set your criteria, then find a set of products and narrow down. Sometimes, this is followed by a comparison task. The most appropriate design solutions are filters and faceted browse.

Comparing

Look at the similarities and differences to help you make a decision. The design interface for comparison must:

A very good understanding of what criteria and features are important to people
A very good understanding of how people make final decisions
Content with enough structure to display things side-by-side
A good filter, to let people narrow (if appropriate)

Getting a Broad Idea

This is about getting a basic information about a topic. A high-level overview of the main ideas, a summary or the big picture must be provided before detailed content. Summary of detailed content could be bullet points, diagrams or videos that communicate the main ideas easily. For example, wikipedia articles provide a good summary before diving into details.

Diving into Details

Create layers of information to balance not enough detailed information vs too much detailed information. Start with good overview information, add a layer for more detail and another for even more detail.

Discovering Unknown Things

You can help people discover interesting things they did not know existed. You business goal could encourage people to stick around - to sell them product they are interested in but did not know about. You need to understand the relationships between content items and show people related things. Provide links to them to capture their attention and make it easy to explore.

Keeping Up to Date

People often want to keep up to date with what's happening within an industry or topic but are not looking for a specific answer.

Re-Finding

This mode is looking for things you have already seen. Ways to implement re-finding:

1. Bookmark managers like delicious
2. Saving items to a wishlist
3. Saving items without signing in

JSON::ParserError: A JSON text must at least contain two octets!

How to reproduce the JSON::ParserError. Go to rails console:

$rails c
Loading development environment (Rails 4.2.6)
> JSON.parse(nil)
TypeError: no implicit conversion of nil into String
from /Users/bparanj/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/json/common.rb:156:in `initialize'
> JSON.parse({})
TypeError: no implicit conversion of Hash into String
from /Users/bparanj/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/json/common.rb:156:in `initialize'
> JSON.parse('')
JSON::ParserError: A JSON text must at least contain two octets!
from /Users/bparanj/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/json/common.rb:156:in `initialize'

ngrok and rails

Build webhook integrations with ease.
Run personal cloud services from your own private network.
Demo without deploying
Simplify mobile device testing

1. Download [ngrok](https://ngrok.com/ 'ngrok') and install it.
2. Run your Rails app : rails s -b 0.0.0.0
3. Go to the directory where you extracted the zip file and run it. ./grok http 3000
4. You can now access the Rails app from the URL displayed in the ngrok Forwarding section of the server output. It will be something like: http://81ce07d0.ngrok.io


Find missing indexes in the database in Rails app

Add gem 'lol_dba' to Gemfile. Run bundle. Run:

lol_dba db:find_indexes

from the project root to find the missing indexes.

Expose Local Rails App to the Public Internet

1. Install NodeJS if your machine does not have it installed.

2. Install Localtunnel.
    npm install -g localtunnel

3. Start your rails app on your machine
rails s

4. Request a tunnel to your local server:

lt --port 3000

5. Copy the URL in the output:
your url is: https://cgoyfetijd.localtunnel.me

to access it from any machine.

This gave : 504 Gateway Error (with nginx server version)

Due to security, since Rails 4.2 the local server is not exposed to the network. To fix this, start the server like this :

rails s -b 0.0.0.0

When this is accessed from another machine, the log file shows the error:

Cannot render console from 209.249.19.171! Allowed networks: 127.0.0.1, ::1, 127.0.0.0/127.255.255.255

In development.rb:

config.web_console.whiny_requests = false

does not work.

Add:

config.web_console.whitelisted_ips = '209.249.19.171'

to allow that particular IP to connect remotely to your local Rails app. To whitelist the whole private network:

config.web_console.whitelisted_ips = '209.249.0.0/16'

References

localtunnel
localtunnel gem

Evaluating Ruby Gems

Go to Ruby Toolbox and check:
  • Which gems are the most popular for a given category?
  • Does the gem meet our application requirements?
Go to github and check:
  • Is it regularly updated?
  • How responsive are the developers? Check how many issues are closed and how many are open.
  • Does it have good documentation in Wiki?
  • Download the source code and read the code to answer any questions.
  • Is the code readable? Can you fix bugs if things go wrong?
  • How readable are the tests?
  • Does the test help you with how to use it?
Look at the project on RubyGems and compare when the different versions were released. Take a look at the runtime dependencies of the gem. Depedencies can break compatibility in an update. Read the documentation for the gem at RubyDoc

Tuesday, July 05, 2016

Sunday, July 03, 2016

Capybara::ElementNotFound: Unable to find field "Credit Card Number"

You must provide a unique id for the field. For example:

Define a unique id for the text field that allows a user to enter a credit card.