Sunday, August 20, 2017

Rspec doubles - normal double, instance double, class doublea

Test doubles are any object that are suppose to stand in and represent real objects during testing. Rspec offers three types of doubles - ordinary doubles(just double), instance doubles, and class doubles.

All doubles are strict by default. What that means is that if any un-allowed or unexpected methods are invoked, the test will fail. For example:

x = double()
a.bar // error because `bar` was not allowed.

However, you can make any double loose by appending `as_null_object`.

Now lets look at differences.

Ordinary doubles

x = double()

These doubles are super barebones. You can allow any messages on these methods.

Instance doubles

x = instance_double('ClassName')

These doubles are aware of the instance methods of class 'ClassName' - you can only allow messages that are defined.

Class doubles

x = class_double('ClassName')

These doubles are aware of the class / module methods of any class or module named 'ClassName'. Just like instance doubles, only defined messages are allowable.

In short, instance and class doubles go a step farther than verifying the state of an object (was 'X' called?). They also verify behavior (is 'X' a thing that this object does?).

When do you use one over the other?

I see ordinary doubles as good for creating dummy objects during a test. For example, if you need to fulfill a parameter requirement for a method where you know the object isn't being used. However, you generally want to use instance and class doubles for the stricter check.

Saturday, August 12, 2017

New Smoothie I'm trying this week

So the avocado coconut smoothie I mentioned last week is more complicated to make than I prefer.

This week I'm going to give this a shot: https://iquitsugar.com/recipe/liver-detox-smoothie/

Ingredients

 small green apple, diced and frozen.
1 zucchini, diced and frozen.
1/4 avocado, diced and frozen.
1 cup mixed greens like broccoli florets, watercress, beetroot greens, silverbeet, kale or spinach.
1/4 cup coriander or parsley (or both!).
1 teaspoon chia seeds.
1/4 teaspoon turmeric, ground.
1/2 lemon, juiced.
2 cups coconut water.

My Grocery List

  • 1 - 2 green apples
  • Zucchini
  • Avocados
  • broccoli florets 
  • Almond Milk

Reflections on Sublime so far - quotes and projects

I switched over to using Sublime from Vim this past year and it's been an absolute joy to use. In fact, I liked it so much I even made a cheatsheet for others to get the most out of this editor. However, there's were still a couple of actions that have been a source of frustration: changing quote types and navigation across multiple projects. In this post I'll discuss what they are, the solution I've adopted to address them, and how I still felt about the solutions after a week of use.

Problem 1: Quotes


Replacing single quotes with double quotes or double quotes with single quotes using multiple selection. If you select both quotes, typing in a single quote will simple quote the double quotes themselves. 

For example:

"hello world" becomes '"'hello world'"' when what I really want is 'hello world'. This isn't a problem if I'm trying to actually quote selections, but very rarely do I (or anyone) want to be quoting the quotation marks. 

Solution

The most promising solution I found to this problem is the ToggleQuotes sublime plugin. I just installed it and it works pretty well. I'm considering adding tests to this and adding support for quotes around multi-line strings. 

Problem 2: Project navigation


When I have sublime opened for > 1 projects, it's difficult to go from one to another. Right now I just use the basic mac application switcher and it works fine for two projects but once I have > 3 applications open it becomes a nightmare.

Solution

Turns out Sublime has a built in projects feature to deal with this issue. I just learned that every window you open is either a named project or anonymous project (if you open sublime in any directory not associated with a project). You can define project specific sublime settings and switch between them quickly using sublimes Project feature. You can also add folders from other projects into the current project.

Update after a week of using ToggleQuotes and sublime projects features

  • The project feature for sublime is absolutely indispensable. I've been able to switch from one project to another seamlessly and this has been a tremendous boost for my workflow. I will also say that I continue to advocate for keeping the project files in the same place - no need to pollute your repos if you don't have to. 
  • Toggle quotes is awesome. Thank you @spadgos.






Saturday, July 29, 2017

Smoothie breakfast diet

I'm currently experimenting with a low-sugar, nutrient-dense breakfast smoothie diet that's easy to make. This is a list of three smoothies that I will be having throughout the week along with a grocery list of ingredients you'll need to buy to make them. 


Banana Peanut butter 

http://www.youmustlovefood.com/banana-peanut-butter-cinnamon-smoothie/
http://allrecipes.com/recipe/221261/peanut-butter-banana-smoothie/A
  • Peanut butter 
    • has protein as well as potassium — which lowers the risk of high blood pressure, stroke and heart disease. It also contains fiber for your bowel health, healthy fats, magnesium to fortify your bones and muscles, Vitamin E and antioxidants.
  • Bananas
    • They contain several essential nutrients, and have benefits for digestion, heart health and weight loss.
    • Bananas are among the most popular fruits on earth.
    • Bananas contain a fair amount of fiber, as well as several antioxidants.
Grocery List 
  • banana 2x
  • milk (2 cups)
  • peanutbutter (1/2 cup)
  • Cinnamon powder
  • Cacao powder 
    • https://iquitsugar.com/raw-cacao-vs-cocoa-whats-the-difference/
Apple Strawberry

http://gimmedelicious.com/2015/07/16/apple-strawberry-smoothie/
  • Apples are 
    • extremely rich in important antioxidants, flavanoids, and dietary fiber. The phytonutrients and antioxidants in apples may help reduce the risk of developing cancer, hypertension, diabetes, and heart disease. This article provides a nutritional profile of the fruit and its possible health benefits.
  • Strawberries are no exception to this rule; 
    • in addition to antioxidants, they have many other nutrients, vitamins, and minerals that contribute to overall health. These include folate, potassium, manganese, dietary fiber, and magnesium. It is also extremely high in vitamin C!
Groceries
  • Apple (1x)
  • Frozen strawberries (1 cup)
  • Milk (1/2 cup)
  • Strawberries / banana (1 cup)


Avocado Coconut

https://iquitsugar.com/recipe/avocado-coconut-dreamboat-smoothie/
  • Avocados are 
    • Health benefits and nutritional information. Also known as an alligator pear or butter fruit, the versatile avocado is the only fruit that provides a substantial amount of healthy monounsaturated fatty acids (MUFA). Avocados are a naturally nutrient-dense food and contain nearly 20 vitamins and minerals.
  • Coconut oil
    •  is high in natural saturated fats. Saturated fats not only increase the healthy cholesterol (known as HDL cholesterol) in your body, but also help convert the LDL “bad” cholesterol into good cholesterols. By Increasing the HDL in the body, it helps promote heart health and lower the risk of heart disease.
Groceries
  • Coconut oil (2 tablespoons)
  • Blueberries (1 / 2 cup)
  • Banana (frozen) ( 1) 
  • Avocado (1)
  • Coconut cream (500 ml)
Toppings
  • Gogi berries
    • https://www.downtoearth.org/health/vitamins-supplements/ways-to-use-goji-berries
  • Chia seeds
  • Cacao nibs 
  • Mulberries 
Final grocery list
  • 2 Apples
  • 4-5 Bananas 
  • Cacao powder
  • Coconut oil 
  • Coconut cream (2 cups)
  • 1 Avocado 
  • 1 container Blueberries
  • Strawberries 
  • Frozen strawberries
  • Almond milk 

Tuesday, May 16, 2017

How to run Cinemania 96 on Windows 10


  1. Install Virtualbox 
  2. Create a windows 7 VM using free IE8 windows 7 virtual machine from microsoft. Create it with at least 1GB of RAM so it's no super slow.
  3. Download virtualbox guest addition and extension pack
  4. Add the extension pack to VB
  5. Start windows 7 VM and install guest additions. Reboot.
  6. Connect CD to USB port
  7. Add a USB device in the VM
  8. Copy files over to the hardisk 
  9. Run cinemania.exe

Sunday, April 30, 2017

Career Development Plan

In our last post, we established the key skills that make up the value of an engineer working in an organization. However, knowing the generalities is not very actionable. 

In this post, we'll delve into the key sub-skills that make up the top level skills as well as accompanying specific actionable tasks that you can start implementing immediately increase your skillfulness in that area and thereby increase your overall value as an engineer. 

Technical Expertise (clean and efficient code, language mastery, editor mastery, etc)
  • Core CS Fundamentals
    • Algorithms and Data structures
  • System Design
    • Learn Programming Paradigms 
      • Object Oriented 
      • Functional 
  • Programming Language
    • Learn Ruby
  • Text editor
    • Learn Sublime Editor (for host machine development tasks)
    • Learn Vi / Vim / Emacs (for general editing tasks)
  • Shell
  • Testing
  • Debugging
  • Source Control
    • Learn GIT
Qualities (leadership ability, general problem solving ability, communication ability, maturity level, etc)
  • Communication
    • Writing and Speaking
  • Analytical / Problem Solving Ability
  • Maturity 
    • Growth Mindset
    • Honors commitments
    • Seeks and Integrates Feedback
    • Treats others with respect
    • Actively Identifies problems
    • Self awareness
    • Proactive about future / career
Execution (planning ability, ability to get shit done, hitting goals)
  • Estimation
  • Project Planning / XP
  • Time Management
  • Getting Unblocked
  • Simplest thing that could possibly work

Scope (area of impact, sub-component, component level, sub-system, system, business unit value)

As your skill sets grows (technical, quality, and execution), so will your scope. If it doesn't, then you need to seek out more responsibility yourself. 

Dedicate entire branches of improvement for each area and track your progress overtime. Identify sticking points (tasks that are on B) and master them (move them to C). 

Saturday, April 29, 2017

Framework for Assessing value of Software Engineers

How does the industry differentiate between a junior software engineer from a senior software engineer? What are the set of attributes we use to assess the value of an engineer so that they're compensated appropriately? 

These are important questions with answers that seem to vary wildly, but having some method of approaching these questions are crucial for arriving at a mutual agreement between the hiring manager and the engineering employee on the value that the engineer brings to the organization. That shared understanding is really important for initial salary negotiations and for maintaining a amicable business relationship overtime. 

As an engineer, even if the companies you're applying for jobs for or are currently working at have no structure for compensation, it's still in your best interest to know what your metrics are for measuring your value so you can improve more effectively. For example, if "leadership quality" is a valuable attribute in your system, then you can very intentionally seek out ways to acquire that trait. 

But what does this value structure for engineers look like? What are the metrics? 

It's easy to come up with a list of things that you think are most important, but they're not helpful if they don't align with what a company or the industry as a whole deems most important. You can't approach companies asking to be paid a million dollars a year just because you can recite methods in the C++ standard library. Impressive? Maybe. Valuable? Not necessarily. 

One way to approach this question is to simply ask hiring managers at top companies. Luckily, many great engineering teams have shared their views on this publicly. After looking at the engineering ladders / compensation structures for these companies and identifying commonalities, I arrived at this general structure for engineers:
  • Technical Expertise (clean and efficient code, language mastery, editor mastery, etc)
  • Qualities (leadership ability, communication ability, maturity level, etc)
  • Execution (planning ability, ability to get shit done, hitting goals)
  • Scope (area of impact, sub-component, component level, sub-system, system, business unit value)
Some companies also mentioned "experience" and "public artifacts" such as Github projects. However, I left those out because those only serve as signals for the traits we're looking for. When you look at someones experience, you're trying to get a sense of where they're at in terms of things like leadership ability or technical expertise. 

The specifics of each and how they're prioritized will vary by company and by industry. You don't have the time to evaluate every attribute that could fall under technical expertise, so as a hiring manager you need to identify which ones you value and come up with strategies to measure how different candidates stack up on that metric.

I highlighted scope in a different color because it's not so much a skill as it is an area of responsibility. Skillfulness in other areas does lead to expansion in the scope of responsibility for an individual within an organization through promotions, but they're still quite distinct from one another since it's not inherently a skill. Nonetheless, it's a key metric because increasing scope does have a significant and direct effect on your value. You can have flying marks in all three areas of technical expertise, qualities, and execution but work on relatively small system compared to other members of the organization with very little business value. 

How this generic structure helps engineers

You can use this list as a framework for thinking about your skill set in the context of your domain / industry. How do you think you rank on technical expertise? On your personal qualities like communication ability? Do you want to become knowledgeable about other critical parts of the system to expand your area of responsibility? If you find a weak area, start working on it. 

Admittedly, this structure isn't very actionable if you can't fill in the specifics. One particular area where finding the set of important skill seems daunting is in the area of technical expertise. A million things can qualify as technical expertise. For example, if you work in embedded systems, having knowledge of Angular.JS isn't as valuable even though it certainly qualifies as a technical expertise. The solution here is to focus on durable skills. 

Durability is a trait that exists for each skill and across skills. First, we'll look at an example of two different skills that differ in durability.

1. Knowledge of classic computer algorithms
2. Knowledge of the API of a brand new AWS web service

#1 is not likely to change. #2 is more likely to change. Whether or not #1 is directly useful to you is a different story. But it is knowledge that is more durable because the most efficient sorting algorithms don't change in a matter of weeks or even years. 

Lets take one skill: editor mastery. 

Durable skill: Mastery over a popular, mature, productive editor that is available across systems. 
Non-durable skill: Mastery over an editor that is buggy and works on a single platform.

Every time you decide to learn something, keep durability in mind. You're making an investment and you want to make sure you're investing in something that will pay dividends for years to come. 

Resources