Saturday, October 31, 2015

rr mocking framework

How to mock something and raise exception? In your model if you need to test something that's raises ActiveRecordNotFound, you can do :

stub(some_object).walk { raise }

Wednesday, October 28, 2015

30-inch Apple Cinema HD Display vs 34" Class 21:9 UltraWide™ WQHD IPS Curved LED Monitor Dimensions

30-inch Apple Cinema HD Display
  • Height: 21.3 inches (54.3 cm)
  • Width: 27.2 inches (68.8 cm)

34-inch Class 21:9 UltraWide™ WQHD IPS Curved LED Monitor (34.0" Diagonal

Height: 33.7' inches
Width: 14.6 inches


Doing exact text search using ack

ack -w bugs

The -w flag will search only bugs and not bugs-bunny or anything other than exact match.

raise in Ruby

raise in Ruby will raise whatever exception you rescue in your code. So instead of doing :

raise MyException

you can just do:

raise

Here is a demo:

class MyException < Exception
end

class Foo
  def hi
    raise MyException.new('hello')
  end
end

def tester
  begin
    f = Foo.new
    f.hi
  rescue
    raise
  end
end

tester

Saturday, October 24, 2015

FactoryGirl::DuplicateDefinitionError: Factory already registered: author

I was getting this error in the rails console, when I did:

> FactoryGirl.find_definitions

Fix:

FactoryGirl.factories.clear
FactoryGirl.find_definitions

Thursday, October 22, 2015

Using Textmate to Browse Source Code using Bundler

Run:

export BUNDLER_EDITOR=mate

in the terminal. Now you can do:

bundle open gem-name

to view the source. You can also add the BUNDLER_EDITOR variable to the bash_profile.

Tuesday, October 13, 2015

Notes from the book Team Geek

  • Software development is a team sport.
  • You need to work with other people. 
  • Share you vision.
  • Divide the labor.
  • Learn from others.
  • Create a brilliant team.

Humility


  •  You are not the center of the universe.
  •  You don't know everything
  •  You are not incapable of making mistakes or being wrong
  •  It does not mean never failing

Respect


  • Genuinely care about others you work with.
  • You treat them as human beings
  • You appreciate their abilities and accomplishments

Trust


  • You believe others are competent and will do the right thing
  • You're ok with letting them drive when appropriate


Almost every social conflict can be traced back to a lack of humility, respect or trust.

Lose the Ego


  • Don't come off like a know-it-all
  • Build a sense of team accomplishment and group pride

Learn to both deal out and handle criticism

  •  Learn to respect your peers and give constructive criticism politely
  •  Your self-worth shouldn't be connected to the code you write

Fail Fast, learn, iterate


  •   Failure is viewed as a golden opportunity to learn and improve
  •   Don't hide in the cave until it's perfect
  •   It's ok to show imperfect software to users and some trust that your users really do appreciate     your efforts and are eager to see rapid improvements.
  •   Document your failures  

What was learned and what is going to change as a result of the learning experience. Follow through on the proposed changes. Don't erase your tracks - light them up like a runway for those who follow you.

Postmortem should include:

• A brief summary
• A timeline of the event, from discovery through investigation to resolution
• The primary cause of the event
• Impact and damage assessment
• A set of action items to fix the problem immediately
• A set of action items to prevent the event from happening again
• Lessons learned

Leave Time for Learning

It's about increasing humility and being willing to learn as much as teach. Put yourself outside your comfort zone now and then.

Learn patience

Be open to influence

  •   It's ok for someone else to change your mind.
  •   Choose your battles carefully
  •   In order to be heard properly, you first need to listen to others
  •   Listening should take place before you've decided on something

Team Culture

Code reviews, TDD and the value you place on having good design docs before starting to crank out reams of code.

Mission Statement is a way to describe the product goals and non goals.
Comments should be focused on why the code is doing what it's doing, not what the code is doing.
Require code reviews for every commit. Check for style, quality and mistakes.
Have real test and release processes. Testing should be part of the coding and review process.
Communication and process reduces the barrier to entry for newcomers.
Code is ultimately about communications with people.
An engineer needs nurturing, time and space to think and create.

Bad Manager


  •  Micromanagement
  •  Ignoring low performers
  •  Hiring pushovers : Your team won't be able to make a move without you. You can't take a vacation. You may feel secure in job. 

Strive to hire people who are smarter than you and can replace you.
See failure as an opportunity to learn and not to point fingers or assign blame.

Do a postmortem of production failures. Document the events that led to the actual failure and develop a series of steps that will prevent it from happening in the future. Focus on the code of the problem and fix it once and for all.

Be a teacher and a mentor


  •  Experience with your team's processes and systems
  •  The ability to explain things to someone else 
  •  The ability to gauge how much help your mentee needs
  •  Don't overexplain things 

Set Clear Goals

  Is there anything you need?
  You can increase intrinsic motivation by giving people three things: autonomy, mastery and purpose
  Autonomy means no micromanagement. Mastery means giving the opportunity to learn new skills and improve existing skills
Code culture should include : Consensus based development, high-quality code, code reviews and an environment where people feel comfortable to try new things and to fail fast.

Protect your team's attention and focus. Don't let someone waste team's time.
Beware of those who are incapable of accepting a consensus decision, incapable of listening to or respecting other points of view and incapable of reaching compromises.
 
Redirect the energy of perfectionists
Keep track of your accomplishments and use them in your self-assessment

Three bullets and a call to action

Don't be all things. Define the problem narrowly and solve it well. Solve common problems for most users and do it really well. Focus on the user, not what's convenient for you to code. Complex things should feel seamless and easy.

Ruby 2.2.3 Complex Basics


Ruby 2.2.3 Complex methods such as to_c, rationalize, rectangular, polar, +, -, /, *, real, imaginary and more. Click on the image below to watch the video.



Friday, October 09, 2015

Ruby 2.2.3 Bignum Basics

Ruby 2.2.3 Bignum methods such as remainder, fdiv, conversion to differnt base using to_s and bit_length. Click on the image below to watch the video.

Ruby 2.2.3 Comparable Basics

Ruby 2.2.3 Comparable methods such as <=> and between is covered in this video. Click on the image below to watch it.

Wednesday, October 07, 2015

Ruby 2.2.3 Binding Basics

Ruby 2.2.3 Binding basics such as binding, using binding with eval, local_variables, local_variable_set and local_variable_get. Click on the image below to watch the video.

Ruby 2.2.3 Lazy Enumerator Basics

Ruby 2.2.3 Lazy Enumerator basics. Click the image below to watch the video.

Monday, October 05, 2015

Ruby 2.2.3 Enumerator Basics : Part 4

Ruby 2.2.3 Enumerator methods such as yield, feed, next_values, peek and peek_values. Click on the image below to watch the video.

Ruby 2.2.3 Enumerator Basics : Part 3

Ruby 2.2.3 Enumerator methods such as with_object and feed. Click on the image below to watch the video.

Sunday, October 04, 2015

Ruby 2.2.3 Enumerator Basics : Part 2

Ruby 2.2.3 Enumerator methods such as enum_for, to_enum and implementing Fibonacci sequence using Enumerator. Click on the image below to watch the video.

Ruby 2.2.3 Enumerator Basics : Part 1

Ruby 2.2.3 Enumerator methods such as each_with_object, next, next_values and feed. Click on the image below to watch the video.

Ruby 2.2.3 Module Basics : Part 9

Ruby 2.2.3 Module methods such as module_function, prepended, private_instance_methods, remove_method and undef_method. Click on the image below to watch the video.

Saturday, October 03, 2015

Ruby 2.2.3 Module Basics : Part 8

Ruby 2.2.3 Module methods such as extend_object, extended, included, method_added, remove_method and method_removed. Click on the image below to watch the video.

Ruby 2.2.3 Module Basics : Part 7

Ruby 2.2.3 Module methods such as remove_class_variable, singleton_class, alias_method and using instance_method in combination with define_method. Click on the image below to watch the video.

Ruby 2.2.3 Module Basics : Part 6

Ruby 2.2.3 Module methods such as private_class_method, private_instance_methods, private_method_defined?, protected_method_defined? and public_method_defined?. Click on the image below to watch the video.

Ruby 2.2.3 Module Basics : Part 5

Ruby 2.2.3 Module methods such as instance_methods, method_defined?, class_exec and module_eval. Click on the image below to watch the video.

Ruby 2.2.3 Module Basics : Part 4

Ruby 2.2.3 Module methods such as const_set, constants, include?, included_modules, instance_method. Click on the image below to watch the video.

Ruby 2.2.3 Module Basics : Part 3

Ruby 2.2.3 Module basics such as autoload, const_defined? and const_get. Click on the image below to view the video.

Ruby 2.2.3 Module Basics : Part 2

Ruby 2.2.3 Module methods such as autoload, autoload?, module_eval, class_exec, class_variable_defined?, class_variable_get, class_variable_set, class_variables and const_defined?

Friday, October 02, 2015

Ruby 2.2.3 Module Basics : Part 1

Ruby 2.2.3 Module methods such as constants, nesting, dynamically adding methods to a module, prepend and ancestors. Click the image below to watch the video.

Thursday, October 01, 2015

Revenue Scaling Problems with iPhone App Business

My first 10 iPhone apps made $30 / day consistently. If I project this, it will take 100 apps to make $300 / day ($9000 / month).

Problems

1. One app per week must be published (unrealistic for one-man company)
2. Cannot throw an app and expect sales without marketing effort.
3. I did not know the 'Equitable Revenue Share' rule during the start of the iPhone app business.

Only 2% of the iPhone apps make significant sales. The 98% of the apps do not make that much money.

How to Increase iOS App Store Downloads

 Free version with in-app purchases.
- Universal app for all devices.
- prweb.com : Press releases works (just breaks even for $5 product)
- Target Mac related sites for press releases.

Google Adwords

 Wasted money on junk keywords. Use Double Click site to check traffic stats before spending on advertising on sites.

Be wary of people contacting you (harvesting email on your sales page) for ad placement on their site. These are lousy sites with no traffic.

British Accent iPhone and iPad App

1. Content : High quality and unique, useful.
2. Price : Cheaper than alternatives.
3. Value : Better than alternatives.

Target Market

 Call center employees. Foreign language speakers. Job seekers. Marketing to a new niche every time is more work.

Millions of users reading article on DailyMail website resulted in $1000 / day sales. This is not sustainable. Temporary spike is not useful in building business for long-term. Facebook, Twitter, News coverage etc.



Equitable revenue share : Refer Million Dollar Consulting.

Seduction Flash Cards iPhone App

 Quality content

- Existing brand. People search for 'Ross Jeffries'

Time Spent : 2 Hours
Money Spent : $50
Graphic Design : $50 (Elance)
Marketing : $0

ROI : Very High
Solves problem : Study cards anywhere

Animal Hand Shadows iPhone App

Cost of Video Production : $1000
Sales = $0

YouTube Views = 0 (18 months after upload)

Analysis


Solves a problem

 No

Market 

 Unknown target market

Reach

 None

Partnership

 Unknown

Japanese Gestures iPhone App

Money Spent

Video production cost : $500
Noise reduction : $500

Solves a problem

 I don't know

Target Market

 Unknown

Competitors

 None

Partners

 Language companies?

Google search

Japanese gestures to check if any ads come up.
This is a big flop. 18 months after uploading to You-Tube, no one watched it.

Lessons Learned


  • Set clear expectations of how the work will be reviewed. Crappy videos could have been rejected and there would be no need to spend on noise reduction.


  • Market first approach would have made this idea non-viable.


  • Do not be carried away by the excitement of creating a product.



  • Top 500 Movies iPhone App

    Development Time : 2 - 4 days
    Graphic Design : $50
    Marketing Effort : $0

    Slowly moved up in sales. Solves problem : Track movies watched with fast lookup. High ROI, just below Seduction Flash Cards.

    Science of Getting Rich iPhone App

    Development Time : 2 to 4 hours
    Content : Public Domain
    Test : Will customers pay for convenience?

    The answer is NO. This failed.

    Content is not unique. Alternatives : Download from sites, iTune podcasts etc.

    American Accent Made Easy iPhone App

    Poor sales for Indian and Chinese versions. Ideally must be part of the generic product and optional in-app purchase. This increases download and it moves up on the chart.

    Made the mistake of getting content from an accent reduction specialist who does not have the proper software / hardware to record quality audio. I wasted money on reducing the noise for a product that does not sell.

    iOxalate iPhone App

    This was my first product on Appstore. No competitors. Solves a problem. Optimized for mobile context. Fast lookup of oxalate content on the go. Can be used for grocery shopping, eating out.

    Reach : Difficult to reach target market. Very small market (intersection of iPhone owners and those who have suffered from kidney stones)

    Partnership : Find kidney stones ebook seller and split revenues. Sales is almost 0 so there is no need to track and the partner can get a cut for every sale. Developing partnership with established medical companies is very difficult. Takes too much time and effort.

    Development effort : 4 weeks. I was new to XCode tools. I had to go through the learning curve.

    The aim was to go fast from code to cash. But it's easy to go fast from code to trash while time and money is wasted. Focus on reducing the waste when going from idea to code stage.

    How to Write Application Statement for SaaS App

    Identify the things about your application that you know with certainty, as well as things you don't yet know. Write a rough story - two paragraphs or less. Be quick and to the point.
    • What is notable about your application?
    • What is it supposed to do?
    • How will it support its users?
    • Is it connected to a real-world example that you can study?
    • Have you done something similar?
    • What will make your design a success?
    • What are the most challenging  things to work out?
    • What seems clear?
    • What seems ill defined?
    You need not answer all these questions. Simply write about the critical aspects of your application. If it helps you make your point, draw a rough sketch or two. Focus on the main ideas.

    Design Story for Click Plan

    This sales boosting application helps digital product sellers to promote and sell their products. One of the concerns is identifying all the actors and how the system is customized for each actor.
    • Can a seller be an affiliate or vice-versa?
    • Do seller and affiliate have the same signup process?
    • Do they have just one account?
    We will design our software for one digital product, ebook and one payment processor Paypal. Email stamping of ebook will be provided to minimize copyright violations. The biggest challenge is modeling the interactions between the application and external systems.

    Seller is interested in selling ebooks. Each ebook can be uploaded to the site so that email stamping can be done after purchase. After purchase, fulfillment involves: email stamping the product and sending email with links to the downloadable ebook and any bonus ebooks. The links to the ebooks are limited by number of downloads and expires after a given time. Bounty window or cookie duration is 6 months and is not configurable. Publisher can provide multiple landing pages for a given product.

    Affiliate marketer can login and view their bounties. Sellers can view their sales. The application provides transparency to publishers and marketers. Payment processing is out of scope of the product.

    Ruby 2.2.3 Class Basics : Part 2

    Ruby 2.2.3 Class method inherited hook that allows to find out who subclassed a given class. Click the image below to watch the video.

    Ruby 2.2.3 Class Basics : Part 1

    Ruby 2.2.3 methods such as alias, creating class dynamically, superclass, allocate and new methods. Click the image below to view the video.

    Bubble Sort Visual Demo

    Click the image below to watch the video.