Thursday, October 11, 2018
Diff same file between two different commitson the same branch
git diff HEAD~1 HEAD -- app/views/layouts/application.html.erb
This will diff the current commit with the previous commit.
This will diff the current commit with the previous commit.
Wednesday, October 10, 2018
Find all the Replace by Chaining ack output to sed
From the command line, I was able to replace Bootstrap 3 classes with Bootstrap 4 class using
ack, sed and xargs.
ack "search text" -l --print0 | xargs -0 -n 1 sed -i "s/search text/replacement text/"
Reference:
Sed recursively with the help of ack and xargs
Sunday, October 07, 2018
Top 3 Lessons from Successful Open Source Projects
Linux was not written from scratch. Linus Torvalds took the Minix as the starting point. It is easier to start from a good partial solution. Minix provided the scaffold and eventually the Minix code was either rewritten or deleted. Read more at Cathedral Bazaar
- Every good work of software starts by scratching a developer's personal itch.
- Good programmers know what to write. Great ones know what to rewrite (and reuse).
- Smart data structures and dumb code works a lot better than the other way around.
Sunday, September 30, 2018
Organized Topics for Coding Skills
Big O Notation
Construction of Loops
Establishing Initial Conditions for Loops
Finding the Iterative Construct
Termination of Loops
Iteration Trace Table
Iterative Program Structure
While Loop Structure
For Loop Structure
For Loop Examples
Comparison: Loops vs Recursive Functions
Divide-and-Conquer
Recursion : Algorithmically, Semantically
How to Code Recursively
Stack Overflow Example
Compute a to the power b
Induction and Recursion
Summation Algorithm
Add a sequence of numbers
Recursion
Iteration
Recursive Sum
Multiplication
Iterative Solution
Recursive Solution
Division without divide operator
Trace : Desk Check a solution
Non-Linear Recursion
Factorial
Recursive Solution
Optimized Solution
Factorial Call Stack
Factorial Algorithm
Factorial Implementation
Compute a to the power b
Recursion Solution
Iterative Solution
Compute a % b
Iterative Solution
Efficient Solution
Fibonacci : Multiple Bases Cases - Recursion
Efficient Fibonacci
Fibonacci Runtime
Fibonacci Number Efficiency
Fibonacci Iterative Solution
Dynamic Programming
Square Root Desk Check Table
Binary Recursion
Even Number
Square Root
Linear Recursion
Exponentiation Function
Factorial C
Array C
Binary Search C
Reverse String C
Sum the Digits
Find Repeating Elements
Identical
Unique Characters
Unique Characters with Constraints
Duplicate Elements in Array
Recognize Non-Linear Recursion
Add Adjacent Elements
Runtimes + , *
Powers of 2 from 1 through n
Remove White Spaces
Remove Duplicates in a String
String Segmentation
Palindrome
Palindrome Substrings Diagrams
Palindrome
Construction of Loops
Establishing Initial Conditions for Loops
Finding the Iterative Construct
Termination of Loops
Iteration Trace Table
Iterative Program Structure
While Loop Structure
For Loop Structure
For Loop Examples
Comparison: Loops vs Recursive Functions
Divide-and-Conquer
Recursion : Algorithmically, Semantically
How to Code Recursively
Stack Overflow Example
Compute a to the power b
Induction and Recursion
Summation Algorithm
Add a sequence of numbers
Recursion
Iteration
Recursive Sum
Multiplication
Iterative Solution
Recursive Solution
Division without divide operator
Trace : Desk Check a solution
Non-Linear Recursion
Factorial
Recursive Solution
Optimized Solution
Factorial Call Stack
Factorial Algorithm
Factorial Implementation
Compute a to the power b
Recursion Solution
Iterative Solution
Compute a % b
Iterative Solution
Efficient Solution
Fibonacci : Multiple Bases Cases - Recursion
Efficient Fibonacci
Fibonacci Runtime
Fibonacci Number Efficiency
Fibonacci Iterative Solution
Dynamic Programming
Square Root Desk Check Table
Binary Recursion
Even Number
Square Root
Linear Recursion
Exponentiation Function
Factorial C
Array C
Binary Search C
Reverse String C
Sum the Digits
Find Repeating Elements
Identical
Unique Characters
Unique Characters with Constraints
Duplicate Elements in Array
Recognize Non-Linear Recursion
Add Adjacent Elements
Runtimes + , *
Powers of 2 from 1 through n
Remove White Spaces
Remove Duplicates in a String
String Segmentation
Palindrome
Palindrome Substrings Diagrams
Palindrome
Friday, September 28, 2018
Tuesday, September 25, 2018
How to override merge conflict
To use the latest git version of the file. We can replace file that has conflict with the latest from repo by running these commands:
git reset -- path/to/file.ext
git checkout path/to/file.ext
Monday, September 24, 2018
Find and Replace a Term in All Files in All Directories from a Given Directory
find ./ -type f -exec sed -i -e 's/apple/orange/g' {} \;
Sunday, September 23, 2018
Unable to download data from https://rubygems.org/ - SSL_connect returned=1
gem install rails -v 4.1
ruby -ropen-uri -e 'eval open("https://git.io/vQhWq").read'
-e:1:in `eval': uninitialized constant OpenSSL::OPENSSL_LIBRARY_VERSION (NameError)
ruby -v -e 'require "openssl"; p OpenSSL'
ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-darwin13.0]
OpenSSL
brew rm openssl brew cleanup openssl brew install openssl
Thursday, September 20, 2018
Monday, September 17, 2018
Copy / Paste terminal utility for Ubuntu
1. sudo apt-get update
2. sudo apt-get install xclip
Add an alias to the .bashrc file:
alias pbcopy='xclip -sel clip'
I am using the same command that is used on a Mac as the alias. I also have open alias to open a directory from a terminal:
alias open='xdg-open'
2. sudo apt-get install xclip
Add an alias to the .bashrc file:
alias pbcopy='xclip -sel clip'
I am using the same command that is used on a Mac as the alias. I also have open alias to open a directory from a terminal:
alias open='xdg-open'
Wednesday, July 25, 2018
no implicit conversion of nil into String
This can happen when you have not defined the required configuration in secrets.yml. For instance, you are using http basic auth and the credentials are not defined in the config file.
Tuesday, July 24, 2018
Wednesday, July 18, 2018
Tuesday, July 17, 2018
Thursday, July 12, 2018
Sprockets::FileNotFound: couldn't find file 'fingerprintjs2' with type 'application/javascript'
jquery_ujs Uncaught TypeError: $.ajaxPrefilter is not a function
This happened when I copied the started template from Bootstrap 4.1 version. It gives you the slim version of jQuery by default. Use the regular jQuery. https://code.jquery.com/jquery-3.3.1.min.js
In style.scss, include
@import bootstrap
Copy the bootstrap.js to vendor/assets/javascripts directory. Copy bootstrap.css to vendor/assets/css directory.
This happened when I copied the started template from Bootstrap 4.1 version. It gives you the slim version of jQuery by default. Use the regular jQuery. https://code.jquery.com/jquery-3.3.1.min.js
In style.scss, include
@import bootstrap
Copy the bootstrap.js to vendor/assets/javascripts directory. Copy bootstrap.css to vendor/assets/css directory.
Sunday, July 08, 2018
Overcoming Mental Hurdles to Software Development
Facing Too Many Unknowns
Gaining Momentum
I was able to gain momentum by tackling simple tasks related to that feature. Refined the requirements and the user's flow over a few days to come up with more followup questions to finalize the requirements. Once the requirements became clear, I was not coding based on some phantom requirements and designing the complicated database structure that was not even required. The time spent on solving problems that did not exist was very energy draining. I had already spent time on analyzing the flow that could vary due to three variables. This made the solution very complex due to the amount of variations. The code was becoming a big mess.
Focusing on the Core
I drew simple diagrams with boxes and arrows to show the user's flow for different use cases. Discussion with the stakeholder had a structure because we focused only on one use case at a time. There was no discussion of technology during this conversation. Only golden path scenario was discussed to clarify the requirements. We can add the alternate scenarios later. We can ask questions based on the existing diagrams, reason about what should happen and draw the alternate scenarios separately.
Gaining Business Context
I made the mistake of copying the similar features of other existing products. I realized it was a mistake later because the business context was different. During the conversation based on simple diagrams I was able to understand the business context. I had narrowed the scope of the problem to be solved. I also pushed back on some requirements and asked the stakeholder to justify why it should be included in version 1. Some of the things might happen once every 3 months does not justify automation and was removed from the stated requirements.
Building a Prototype First
I did not build a prototype because it was a lot easy to use Bootstrap 4.1 with Rails to build the screens with hard coded data. I saved the time to learn a prototyping tool. I was able to focus on learning new AWS APIs that was required to build the product.
Being Agile and Lean
The client was remote and was able to chat via What's app and email few times a week. The requirements were in the emails and were not well thought out to write the test first. Clarify First, Test Later. I did not automate the infrastructure management because at this point I am not sure if I can get 99 clients who will find this product useful without any customization. It has been custom built for this particular client. Reading the lean startup articles, I was confident that I was targeting the right segment in the adoption curve.
Lessons Learned
- Do not write production level code before understanding the business.
- Draw simple diagrams with technical details to gain business context first.
- Narrow down the scope of the problem before starting to code.
- It's ok to start the first few versions of the screen with existing products from similar domains.
- Remember, these screens need to refined once the business context knowledge is acquired.
- If the complexity of the solution is getting out of control, go back and see if you can push back on the requirements.
Saturday, July 07, 2018
Subscribe to:
Posts (Atom)




















