Wednesday, December 01, 2021

Rails 7 Sample Project

1. gem install rails -v v7.0.0.alpha2

2. rails new blog --css tailwind

3. rails g scaffold post title

4. rails action_text:install
5. rails db:create db:migrate

        Monday, November 29, 2021

        Share Folder in Mac with Multipass Ubuntu Instance

         Share Folder


        multipass mount local/folder/path multipass-instance-name

        multipass mount /Users/bparanj/cloud gold


        multipass info gold

        Name:           gold

        State:          Running

        IPv4:           192.168.64.2

        Release:        Ubuntu 20.04.3 LTS

        Image hash:     91740d72ffff (Ubuntu 20.04 LTS)

        Load:           0.71 0.53 0.32

        Disk usage:     2.6G out of 4.7G

        Memory usage:   241.0M out of 981.3M

        Mounts:         /Users/bparanj/cloud => /Users/bparanj/cloud

                            UID map: 501:default

                            GID map: 20:default

        Saturday, November 27, 2021

        ssh into multipass instance

         Launch Ubuntu instance:

        multipass launch --name gold   

        Copy the IP address from:

        multipass list 

        Log in to multipass instance:

        sudo ssh -i /var/root/Library/Application\ Support/multipassd/ssh-keys/id_rsa ubuntu@192.168.64.2



        Friday, November 19, 2021

        Tuesday, November 09, 2021

        Postgresql Post Install Message

         To migrate existing data from a previous major version of PostgreSQL run:

          brew postgresql-upgrade-database


        This formula has created a default database cluster with:

          initdb --locale=C -E UTF-8 /opt/homebrew/var/postgres

        For more details, read:

          https://www.postgresql.org/docs/14/app-initdb.html


        To restart postgresql after an upgrade:

          brew services restart postgresql

        Or, if you don't want/need a background service you can just run:

          /opt/homebrew/opt/postgresql/bin/postgres -D /opt/homebrew/var/postgres


        Zoom Link:

        sqlite3 install

        After brew install, the output: 

        If you need to have sqlite first in your PATH, run:

          echo 'export PATH="/opt/homebrew/opt/sqlite/bin:$PATH"' >> ~/.zshrc


        For compilers to find sqlite you may need to set:

          export LDFLAGS="-L/opt/homebrew/opt/sqlite/lib"

          export CPPFLAGS="-I/opt/homebrew/opt/sqlite/include"


        For pkg-config to find sqlite you may need to set:

          export PKG_CONFIG_PATH="/opt/homebrew/opt/sqlite/lib/pkgconfig"

        Monday, November 08, 2021

        Warning! PATH is not properly set up

        Warning! PATH is not properly set up, /Users/n1576925/.rvm/gems/ruby-3.0.2/bin is not at first place.

                 Usually this is caused by shell initialization files. Search for PATH=... entries.

                 You can also re-add RVM to your profile by running: rvm get stable --auto-dotfiles

                 To fix it temporarily in this shell session run: rvm use ruby-3.0.2

                 To ignore this error add rvm_silence_path_mismatch_check_flag=1 to your ~/.rvmrc file.


        In MacOS Monterey, add the following to .bash_profile:


        # RVM can encounter errors if it's not the last thing in .bash_profile

        export PATH="$PATH:$HOME/.rvm/bin" # Add RVM to path for scripting (to manage Ruby versions)

        export PATH="$GEM_HOME/bin:$PATH"


        [[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*


        The .zshrc has only one line:

        source ~/.bash_profile


        Tuesday, September 07, 2021

        Rails on Docker Tips

        1. Reduce size of the image

        RUN apt-get clean && rm -f /var/lib/apt/lists/*_*

        2. Combine update, install and clean:

        RUN apt-get update -y \

        && apt-get install -y -q package-name \

        && apt-get clean \

        && rm -f /var/lib/apt/lists/*_*

        3. Use a separate build stage

        FROM base-image AS builder

        COPY . /app

        RUN apt-get install build-essential \

        && bundle install --deployment


        FROM base-image

        COPY --from=builder /app /app

        4. Set the system locale

        RUN echo "en_US.UTF-8 UTF-8" > /etc/locale.gen \

        && locale-gen en_US.UTF-8

        ENV LANG en_US.UTF-8

        ENV LANGUAGE en_US:en

        5. Create an unprivileged user

        # After build

        RUN adduser -s /bin/sh -u 1001 -G root \

        -h /app -S -D rails \

        && chown -R rails /app

        USER rails

        6. Prefer exec form for CMD

        CMD ["bundle", "exec", "rails", "s"]

        7. Specify resource constraints in production

        requests:

          memory: "100Mi"

          cpu: 0.5

         limits:

          memory: "200Mi"

          cpu: 1.0

        8. Log to STDOUT or an external agent

        ENV RAILS_LOG_STDOUT=true



        Friday, August 27, 2021

        Dockerfile with caching for Rails 6.1

         FROM ruby:2.7


        LABEL maintainer="Brianna"


        RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -

        RUN echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list


        RUN apt-get update -yqq && apt-get install -yqq \

            nodejs \

            npm \

            yarn


        RUN node -v


        COPY Gemfile* /usr/src/app/

        WORKDIR /usr/src/app


        RUN gem install bundler:'~> 2.1.4'

        RUN gem install rails

        RUN bundle install


        RUN echo $PWD

        COPY . /usr/src/app

        RUN rails webpacker:install


        CMD ["bin/rails", "s", "-b", "0.0.0.0"]


        https://drive.google.com/file/d/1nuZE88MOmMqiM2DMbur1RWPJvjUQ0rSf/view?usp=sharing

        Dockerfile for Rails 6.1

         FROM ruby:2.7


        RUN apt-get update -yqq

        RUN apt-get install -yqq nodejs npm

        RUN node -v


        RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -

        RUN echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list

        RUN apt-get update -y

        RUN apt-get install yarn -y


        RUN gem install bundler:'~> 2.1.4'


        COPY . /usr/src/app

        WORKDIR /usr/src/app

        RUN bundle install

        RUN bin/rails webpacker:install


        Saturday, August 21, 2021

        speedtest from terminal in Ubuntu 20.04

          sudo apt update

         sudo apt install speedtest

         sudo apt update

         sudo apt-get install python3-pip

         sudo pip3 install speedtest-cli

         speedtest-cli

         speedtest-cli --share

        go: go.mod file not found in current directory or any parent directory; see 'go help modules'"

         Run from the terminal:

        go mod init example.com/m/v2


        Copy the generated file before you build the go program in the Dockerfile:

         

        FROM golang:alpine

        WORKDIR /myapp

        COPY welcome.go .

        COPY go.mod .


        RUN go build -o welcome .

        ENTRYPOINT ["./welcome"]


        Make the generation of go.mod as part of the docker container:


        FROM golang:latest AS builder

        WORKDIR /myapp

        COPY welcome.go .


        RUN go mod init example.com/m/v2

        RUN go build -o welcome .


        FROM scratch

        WORKDIR /myapp

        COPY --from=builder /myapp/welcome .

        ENTRYPOINT ["./welcome"]

        Finding the number of cores in Ubuntu 20.04

         $ lscpu | egrep 'CPU\(s\)'

        CPU(s):                          4

        On-line CPU(s) list:             0-3

        NUMA node0 CPU(s):               0-3


        $ cat /proc/cpuinfo | grep processor | wc -l

        4


        $ nproc

        4

        Monday, August 16, 2021

        React and Libraries Book Notes

        1. yarn create react-app starter-project --template TypeScript
        2. yarn add -D typescript @types/node @types/react @types/react-dom @types/jest @typescript-eslint/scope-manager
        3. yarn add -D node-sass
        4. yarn add -D scss-loader typings-for-scss-modules-loader
        5. yarn add -D redux @reduxjs/toolkit react-redux @types/react-redux
        6. yarn add -D @material-ui/core @material-ui/icons
        7. Edit tsconfig.json:
        // tsconfig.json
        {
          "compilerOptions": {
            "target": "es5",
            "lib": [
              "es6", "dom",
          ...
              ...
            ],
            "noImplicitAny": true,
            "noImplicitThis": true,
            "strictNullChecks": true,

        8. yarn add -D styled-components @types/styled-components
        9. yarn add -D react-router-dom @types/react-router-dom
        10. yarn add -D enzyme enzyme-adapter-react-16 react-test-renderer
        11. yarn add -D enzyme-to-json
        12. yarn add sinon @types/sinon
        13. yarn add puppeteer jest-puppeteer ts-jest
        14. yarn add yarn add @types/puppeteer @types/expect-puppeteer @types/jest-environment-puppeteer
        15. Create these folders:

        src/components
        src/features
        src/layout
        src/pages
        src/redux
        src/recoil/atoms

        16. mkdir src/components src/features src/layout src/pages src/redux src/recoil/atoms
        17. npx generate-react-cli component Header
        18. Change generate-react-cli.json to 

        {
          "usesTypeScript": true,
          "usesCssModule": false,
          "cssPreprocessor": "scss",
          "testLibrary": "Enzyme",
          "component": {
            "default": {
              "path": "src/components",
              "withStyle": true,
              "withTest": true,
              "withStory": false,
              "withLazy": false
            },
            "page": {
              "customTemplates": {
                "component": "templates/page/component.tsx",
                "style": "templates/page/style.scss",
                "test": "templates/page/test.tsx"
              },
              "path": "src/pages",
              "withLazy": false,
              "withStory": false,
              "withStyle": true,
              "withTest": true
            },
            "layout": {
              "customTemplates": {
                "component": "templates/component/component.tsx",
                "style": "templates/component/style.scss",
                "test": "templates/component/test.tsx"
              },
              "path": "src/layout",
              "withLazy": false,
              "withStory": false,
              "withStyle": true,
              "withTest": true
            }
          }
        }

        https://drive.google.com/file/d/1nlgGdZLfsfmElS1xVGW6BoB_1jTtRT7x/view?usp=sharing


        Tuesday, August 10, 2021

        Bala Paranj

         Bala Paranj is focused on tackling the technical challenges to software development. He enjoys working on complex problems and applying design techniques to accelerate development and build elegant systems.

        Monday, August 09, 2021

        Brackets, Braces and Parentheses in Javascript

        Brackets [] hold arrays.

        Braces {} is used to create objects and group statements.

        Parenthesis () is used to supply parameters, group expressions and execute functions.

        Thursday, August 05, 2021

        Ruby times and and upto in Javascript

         Number.prototype.upto = function(t, cb) {

          var i = this;


          if(t < this) return +this;


          while (i <= t) {

            cb(i++);

          }


          return +this;

        };


        (1).upto(5, function(i){console.log(i);})



        // Ruby = 5.times { |i| puts i }

        // JS   = (1).times(function(i){console.log(i);})

        Number.prototype.times = function(cb) {

          var i = -1;


          while (++i < this) {

            cb(i);

          }


          return +this;

        }



        (5).times(function(i){console.log(i);})


        Tools


        Thursday, July 29, 2021

        Design Notes

        Write tests that confirm what the code does without any knowledge of how the code does it. Test WHAT, not the HOW. Tests should not be tightly coupled to implementation details. Program to the interface not to the implementation.

        Theme of Design Patterns book: The focus here is encapsulating the concept that varies, a theme of many design patterns.


        Wednesday, March 24, 2021

        linkedlist notes

         CreateList(),createsandreturnsanew,emptylist.

        • InsertListNode(L,p,n),addsnodenafternodepinlistL.Ifpisnull,then we insert n as the new head of the list. The function returns a pointer to n. We assume that the node n has already been created with some data that we want to add in the list. We will not get into the details on how nodes are actually created. Briefly, some memory must be allocated and initialized, so that the node contains the data we want and a pointer. InsertListNode then needs only change pointers. It must make the pointer of n point to the next node, or to null, if p was the last node of the list. It must also change the pointer of p to point to n, if p is not null.

        • InsertInList(L, p, d), adds a node containing d after node p in list L. If p is null, then we insert the new node as the new head of the list. The function returns a pointer to the newly inserted node. The difference with InsertListNode is that InsertInList creates the node that will contain d, whereas InsertListNode takes an already created node and inserts it in the list. InsertListNode inserts nodes, whereas InsertInList inserts data contained in nodes it creates. That means that InsertInList can use InsertListNode to insert in the list the node it creates.

        RemoveListNode(L, p, r), removes node r from the list and returns that node; p points to the node preceding r in the list, or null if r is the head. We will see that we need to know p in order to remove the item pointed by r efficiently. If r is not in the list, it returns null.

        • RemoveFromList(L, d), removes the first node containing d from the list and returns the node. The difference with RemoveListNode is that it will search the list for the node containing d, find it, and remove it; d does not point to the node itself; it is the data contained inside the node. If there is no node containing d in the list, RemoveFromList returns null.

        • GetNextListNode(L, p), returns the node following p in list L. If p is the last node in the list, then it returns null. If p is null, then it returns the first node of L, the head. The returned node is not removed from the list.

        • SearchInList(L, d), searches the list L for the first node containing d. It returns the node, or null if no such node exists; the node is not removed from the list.

        Difference between training, seminar, workshop, coaching, conference, symposium, webinar, course, lesson, class

        training -the process of learning the skills you need to do a particular job or activity

        workshop - training class or seminar in which the participants work individually and/or in groups to solve actual work related tasks to gain hands-on experience

        webinar  - an occasion when a group of people go on the internet at the same time to study and discuss something

        seminar - formal presentation by one or more experts in which the attendees are encouraged to discuss the subject matter

        coaching - extending traditional training methods to include focus on (1) an individual's needs and accomplishments, (2) close observation, and (3) impartial and non-judgmental feedback on performance

        symposium  - a meeting where experts discuss a particular subject

        conference  - a large meeting, often lasting a few days, where people who are interested in a particular subject come together to discuss ideas

        course  -a series of lessons about a particular subject

        lesson  - a period of time when a teacher teaches people

        class - a period of time in which students are taught something

        Monday, March 15, 2021

        Icons

         Process:

        https://thenounproject.com/search/?q=process&i=363475


        Constraint: 

        https://www.vectorstock.com/royalty-free-vector/constraint-icon-simple-element-vector-27077967


        Invariant:

        https://thenounproject.com/term/constant/239044/


        Patterns of Reasoning:

        https://thenounproject.com/term/pattern-lock/993151/


        Insight:

        https://www.pngitem.com/middle/wiwTw_data-insight-icon-png-transparent-png/


        Crawl:

        https://thumbs.dreamstime.com/z/crawling-man-icon-flat-design-gray-color-symbol-modern-ui-web-navigation-sign-illustration-element-crawling-man-icon-flat-design-114966254.jpg


        Walk:

        https://thenounproject.com/term/walk/709031



        Run:

        https://upload.wikimedia.org/wikipedia/commons/b/b0/Running_icon_-_Noun_Project_17825.svg


        Analytical Reasoning:

        https://s3.amazonaws.com/wj-cdn/uploads/aba2a20d6675bb1f8333eff5027c9760


        Use the top image on the D section


        Visual Model:

        https://icons8.com/icon/55808/3d-model



        Pricing Section:

        book:


        https://stock.adobe.com/search?k=%22book+icon%22&asset_id=190506160


        course:

        https://www.freeiconspng.com/img/15341


        coaching:

        https://www.123rf.com/photo_111338969_stock-vector-coaching-icon-coaching-symbol-design-from-human-resources-collection-.html



        community:

        https://thenounproject.com/search/?q=community&i=2522271


        Problem Classification

        https://thenounproject.com/search/?q=classification&i=1705417


        Never Get Stuck

        https://thenounproject.com/term/wall/1171258/

        https://thenounproject.com/search/?q=maze&i=369013


        Over 200 Problems

        https://thenounproject.com/term/quantity/2463381/


        No Memorization Required

        https://thenounproject.com/search/?q=memorization&i=544757

        https://thenounproject.com/term/wrong/539385/


        Stand Out from the Crowd

        https://thenounproject.com/search/?q=community&i=199749


        Inductive and Deductive Reasoning

        https://thenounproject.com/search/?q=reasoning&i=3239961



        Practice:

        https://s3-eu-central-1.amazonaws.com/glossika-blog/2019/05/use-deliberate-practice-to-learn-foreign-languages.png


        Use the rightmost diagram. Remove all the texts in this diagram.


        Theory

        https://thumbs.dreamstime.com/z/atomic-theory-icon-filled-thin-line-outline-stroke-style-vector-illustration-two-colored-black-atomic-theory-atomic-180544804.jpg


        Use the rightmost image.


        Drills

        https://thenounproject.com/search/?q=exercise&i=3507234


        Analytical:

        https://thenounproject.com/search/?q=deductive&i=79239




        The Feynman Learning Technique

        Learning occurs when you can explain the concepts and use it in a wide variety of situations. The more you know, the fewer blocks you will encounter, because most new things will connect to something you already understand.

        The Feynman Technique turns information into knowledge that you can access easily without any memorization. There are four steps to this method. They are as follows:

        1. Pretend to teach a concept you want to learn about to a sixth grade student.
        2. Identify gaps in your explanation. Go back to the source material to better understand it.
        3. Organize and simplify.
        4. Share it.

        Step 1: Pretend to Teach it to a Child

        Take out a blank sheet of paper. At the top, write the topic you want to learn. Now write out everything you know about the subject as if you were teaching it to a child. They have just enough vocabulary to understand basic concepts and relationships. Force yourself to be as simple as possible.

        We hide our lack of understanding by using complicated vocabulary and jargon. If you can’t define the words and terms you are using, you don’t really know the meaning of those words. Explanation must be at a sixth-grade reading level by using simple words and phrases.

        When you write out an idea from start to finish in simple language that a child can understand, you force yourself to understand the concept at a deeper level and simplify relationships and connections between ideas. You can better explain the why behind your description of the what.

        Some of the writing to teach will be easy. These are the areas where you have a clear understanding of the topic. But you will find many places where things are confusing to you.

        Step 2: Identify Gaps in your Explanation

        In the previous step you will identify areas where you struggle, you have gaps in your understanding in these areas. Gaps in your knowledge means you forget something important, aren’t able to explain it or simply have trouble thinking of how variables interact. Identifying gaps is a critical part of the learning process. Filling those gaps makes the learning stick.

        Now that you know your gaps in understanding, go back to the source material. Supplement it with other sources. Look up definitions. Keep going until you can explain everything in basic terms.

        Only when you can explain without jargon and in simple terms you demonstrate your understanding. If you need complicated terminology to explain, when someone asks you a question, you can only repeat what you’ve already said.

        Simple terms can be rearranged and easily combined with other words to communicate your idea. When you can say something in multiple ways using different words, you understand it really well. Skipping the work needed to explain in a simple way leads to getting stuck when challenged.

        Identifying the boundaries of your understanding is also a way of defining your circle of competence. When you know the topic and are honest about what you don’t know, you limit the mistakes you’re liable to make and increase your chance of success when applying knowledge.

        Step 3. Organize and Simplify

        Now you have a set of hand-crafted notes containing a simple explanation. Organize them into a story that you can tell from beginning to end. Read it out loud. If the explanation sounds confusing at any point, go back to the previous step of identifying the gaps in your explanation. Keep iterating until you have a clear story that you can tell others. You can use the Cornell notes taking template to organize your story. Download the template from: https://www.codingskill.net/assets/files/CornellNotesTemplate.pdf

        If you follow this approach, over time you will end up with a lot of notes on different topics. When you revise your notes periodically, you will see just how much you retain.


        Step 4: Share It


        Share your understanding of the material with someone who knows little about the topic. A good test of your understanding is your ability to convey it to another person. You can read out directly what you’ve written. You can present it like a presentation. Make an attempt to share the material with at least one person who isn’t that familiar with it.

        The questions you get and the feedback you receive are invaluable for further developing your understanding. Hearing the curiosity of your audience will likely stimulate your own curiosity and set you on a path for further learning. 

        The Feynman Technique is also a different way of thinking that makes you tear ideas apart and reconstruct them from the ground up. Feynman understood the difference between knowing something and knowing the name of something, when you truly know something, you can use that knowledge broadly. When you only know the name of something, you don’t know its meaning and lack understanding. You can’t take it apart and play with it or use it to make new connections and generate new insights. When you know something, the labels are not important, because it’s not necessary to keep it in the box it came in.

        Feynman’s explanations on why questions are simple and powerful. We talk in fact-deficient, confusing generalities to hide our lack of understanding. Take things apart. Staying at the abstract level does not promote understanding. Take apart the final solution; see how it works. See the cleverness of the different pieces; see the interactions between them. Learn something about the working code, the way the algorithm is put together, the ingenuity of people devising the algorithms and data structures.

        Learning doesn’t happen in isolation. We learn from books, people, ideas and getting exposed to different ideas. Improving requires questioning your knowledge and the knowledge of others.

        You can see how I applied this technique to learn about Topological Sort in my PDF notes: https://www.codingskill.net/assets/files/toposort.pdf. 

        Read about interleaving as a study strategy: https://www.codingskill.net/assets/files/Interleaving.pdf. 

        Download Feynman learning technique template: 

        Book Content Outline

        1. Problem solving approaches/strategies (how to think)
        2. Learning/Study tips so material don't get forget that easily
        3. Problem patterns/tricks (not only problem categories)
        4. A curated list with decent amount of problems to get exposed to all categories and useful patterns/tricks (hopefully sequential, like building blocks)

        Sunday, March 07, 2021

        Learning to Solve the Coding Problem

         Learn the reasoning behind a solution and how they derived that solution. After a few days, go back and solve the same problem again from scratch without any reference. Even if you remember the gist of the solution, you would still have to implement it again, which can be a challenge. You can also look at the solution in a different language and code it in a language more familiar to you. Understand the thought process behind a solution and how to derive it. Ideally use only the hints so you don’t look at the complete solution and have the chance to solve the problems on your own. But the goal is to reach a state where you can come up with optimal solutions without looking at the answer. This just takes practice and time.


        Build a solution from scratch. Get into the habit of getting your implementation to work. If you have difficulty to get it to work, you can then rule it out and move on to another approach. Speed should not be the focus. Developing a method of working through the problem in a methodical way with a set number of steps is the goal. Speed will be a byproduct of refining your method of approaching a problem you've never seen before.


        Part of the process is working through frustration, finding a starting point and building confidence in your solution. You must expect to work through those uncomfortable moments. Do not look at the solution until you have your own working implementation. Do not write a single line of code until you have written what you think is an entire working solution on paper.


        If you are passing some of the test cases and can't think of any other solution after spending a significant amount of time on it then look up the solution. Read the algorithm and then implement it. Do not look at the solution and copy and paste the solution in to add a +1 to your record.


        There's no short cuts. It's hard work, discipline and spending time working through it. The point isn't solving the problem. The point is improving your problem solving skills and communicating how you're going to approach the problem before writing code.


         The hard part isn’t solving the problems themselves, but rather overcoming the mental barriers and having the discipline to solve the problems consistently.

         

        Study Links

         https://medium.com/basecs

        https://www.youtube.com/playlist?list=PLDV1Zeh2NRsB6SWUrDFW2RmDotAfPbeHu

        http://www.youtube.com/mycodeschool

        https://www.udemy.com/course/introduction-to-data-structures-algorithms-in-java/#/)

        http://cp-algorithms.com/

        https://www.reddit.com/r/cscareerquestions/comments/bc85gv/i_have_to_literally_lookup_up_every_leetcode/

        https://medium.com/@sourabreddy

        https://www.reddit.com/r/cscareerquestions/comments/6luszf/a_leetcode_grinding_guide/

        https://teachyourselfcs.com/

        https://bottomupcs.com/intro.xhtml#d0e93

        https://techdevguide.withgoogle.com/resources?no-filter=true


        Thursday, March 04, 2021

        Long Term Goal

         1. Solving 1500 problems is NOT practical

        2. Two types of problem on LC.

            1. Problems Skills

            2. Mundane coding exercise

        3. Copying code from their notes.

        4. Just show the finished product. 

            Thinking process is more important.

        5. Why does this work?

        6. Very abstract explanations.

        7. Stanford: Code for demos.

        8. What to emphasize? Graph topics.

        9. algo + data structures

           Software Engineer - 2021

           Chips - Go ALL IN.

        10. Slack access

        11. Kills Two Birds in One Stone

              - Russel Brunson

              - Competitive Research

              - Nomad life

        12. Build a product that delivers the most value for the customers

             - $50

             - $500

             - $2000


        50% - Problem Solving

        50% - Coding Drills


        1. Wyzant

        2. Course Hero 

        3. codementor.io   


           Luck + Personality 


        Tuesday, February 23, 2021

        Coding Interview Preparation Phases

        Crawl Phase

        Step 1 : Basic Concepts

        Learn the basic data structures and algorithms. Learn the basic concepts and terminology to build your vocabulary of programming.

        Step 2 : Code

        Code the representation and operations for the data structures in your list.

        Step 3 : Coding Drills

        Design coding drills and practice the algorithms in your list.

        Step 4 : Analyze

        Analyze the time and space complexity of your code.

        Step 5 : Test

        Test your code using test cases. Debug and fix any bugs.

        Step 6 : Take Notes

        Take notes to help you review later. Learn from your mistakes.

        Step 7 : Pros and Cons

        After you have learned about the data structures in your list, compare the pros and cons of using similar data structures.

        Walk Phase

        Step 1 : Understand the Problem

        Understand the problem statement before you design the algorithm.

        Step 2 : Identify the Approach

        Identify the data structure, algorithm and strategy to solve the problem.

        Step 3 : Outline the Solution

        Outline the solution at a high level.

        Step 4 : Identify the Obstacles

        Identify the obstacles to solving the problem. Revisit your study materials to gain a deeper understanding of the concepts. This is a top down approach to assimilation process.

        Step 5 : Work Backwards

        Work backwards from the solution. Design and practice coding drills. Practice coding the solution and understand the solution. This is a bottom up approach to assimilation process.

        Step 6 : Test

        Test your code with test cases.

        Step 7 : Analyze

        Analyze the time and space complexity of your solution.

        Step 8 : Take Notes

        Review your solution and reflect. Take notes on where you made mistakes and review your solution.

        Run Phase

        Step 1 : Form Links

        Connect the dots between problems you solved in walk phase.

        Step 2 : Problem Types

        Solve problems by category.

        Step 3 : Recognize Patterns

        Summarize common patterns used for solving problems within the same category.

        Step 4 : Take Notes

        Take notes on where you made mistakes to help you review later.

        Step 5 : Practice

        Practice articulating your solution.

        Step 6 : Evaluate Progress

        Form a study group. Take mock interviews.

        Customized Action Plan

        I can guide you in creating a customized action plan for your situation. Sign up here https://go.oncehub.com/BalaParanj for your FREE session and we will figure it all out. Why is this free? Because I believe in Zig Ziglar's quote:

        You can get everything in life you want if you will just help enough other people get what they want.

        Thursday, February 11, 2021

        Coding Interview Question

                # 0 1 2 3 4 5 6

        input = [1,2,4,2,5,3,5]


        def duplicates(input)

          hash = Hash.new(0)

          output = Hash.new([])

          

          input.each do |n|

            hash[n] += 1

          end

          

          hash.each do |k,v|

            if v > 1

              output[k] = []

              input.each_with_index do |e, i|

                if e == k

                  output[k] << i

                end

              end

            end

          end

          

          output

        end


        p duplicates(input)


        Wednesday, January 27, 2021

        Saturday, January 23, 2021

        Desirable Difficulty

        UCLA professor Robert Bjork has argued that desirable difficulty is actually required for us to upskill and move to another level.

        Consider two kinds of batting practice. In one, the pitches are chunked into categories—twenty-five fastballs, twenty-five curve balls—in a predictable rhythm. At the end of this practice, hitters reported feeling a sense of confidence and flow.

        The alternative involves mixing up the pitches randomly. Here, the batters reported frustration and less satisfaction. But teacher Torre’ Mills points out that the random method, where desirable difficulty is at work, actually improves players’ skills more than the chunked approach.

        Desirable difficulty is the hard work of doing hard work. Setting ourselves up for things that cause a struggle, because we know that after the struggle, we’ll be at a new level.

        Learning almost always involves incompetence. Shortly before we get to the next level, we realize that we’re not yet at that level and we feel insufficient. The difficulty is real, and it’s desirable if our goal is to move forward.

        When we intentionally avoid desirable difficulty, our practice suffers, because we’re only coasting.

        The commitment, then, is to sign up for days, weeks, or years of serial incompetence and occasional frustration. To seek out desirable difficulty on our way to a place where our flow is actually productive in service of the change we seek to make.

        Seth Godin. “The Practice.” 

        Monday, January 18, 2021

        Learning Environment

         Learn in a relaxed environment. The best recall occurs when brainwave patterns show a relaxed state.

        Learn in a multi-sensory environment by involving visual, auditory and kinesthetic activities.

        Use color! This stimulates the right brain and helps recall.

        Make sure you take breaks every hour.

        Try to relate what you are learning to a bigger picture.

        Reinforce what you have learned through practice and review.


        Saturday, January 16, 2021

        Remove whitespace from file names in Unix/Mac

         Go to the folder where the files are located and run:

        for f in *; do mv "$f" `echo $f | tr ' ' '_'`; done

        Thursday, January 14, 2021

        Upload File to S3

         require 'aws-sdk-s3'  # v2: require 'aws-sdk'


        ACCESS_KEY_ID = ""

        SECRET_ACCESS_KEY = ""

        REGION_ID = "us-east-1"

        BUCKET_NAME = "bucket-name"


        def uploadS3

          credentials = Aws::Credentials.new(

                                             ACCESS_KEY_ID,

                                             SECRET_ACCESS_KEY

                                             )

          s3 = Aws::S3::Client.new(

                                  region: REGION_ID,

                                  credentials: credentials

                                  )

                                  

          #Upload export/file1.zip, export/file2.zip

          for file_name in ['file1.zip', 'file2.zip']

            name = File.join('export', file_name)


            # Upload

            File.open(name, 'rb') do |file|

              puts "start uploading #{file_name} to s3"

              resp = s3.put_object(bucket: BUCKET_NAME, acl: "public-read", key: file_name, body: file)

              puts resp

            end

            puts "File should be available at https://#{BUCKET_NAME}.s3.amazonaws.com/#{file_name}"

          end

        end

        Thursday, January 07, 2021

        Law of Success

        1. Fall in love with the process.
        2. Do it every single day.
        3. Celebrate your commitment.
        4. Track your metrics and data.
        5. Master your craft.

        Tommy Baker. “The 1% Rule: How to Fall in Love with the Process and Achieve Your Wildest Dreams.” 

        Wednesday, January 06, 2021

        Live Coding 175 Session Recordings Now Available

        We have now over 175+ live coding recordings for Leetcode live coding sessions. That is over 200 hours of discussions on coding problems. We are a group of developers preparing for FANG interviews. We meet everyday and work collaboratively on solving one medium Leetcode problem via Zoom.

        This is NOT a study group. We flip the classroom. You study whatever resources you find useful before the meeting. We only focus on PRACTICE and FEEDBACK during the Zoom calls. We share tips and the peer to peer learning has worked really well so far.

        I started the daily live coding sessions on July 25th, 2020. I have learned in just two months as much as I have learned in one year when I was studying and practicing by myself. Members requested me to record the sessions so they can watch any sessions that they miss.

        We don't rush into coding. We analyze the problem, create a model of the problem and use the model to answer questions. We then brainstorm alternate approaches to solve the problem starting with brute-force and eventually code the optimal solution by the end of the session.

        This is not passive learning like watching videos. The paid courses ask you to pause the video and think. But no one teaches how to think and ask questions to solve problem from scratch. We code the solution to problems from scratch.

        Our group hates memorizing and we focus on gaining deep understanding of the concepts. Join Leetcode Live Coding Telegram group: https://t.me/joinchat/VOy5LhxpFvgV4aJKeMBIRg

        You will also get access to the Zoom cloud recordings. You will develop insights on how to approach coding problems and you don't have to memorize anything. You will learn how visualizing the key aspects of well known algorithms can make it easier to understand the algorithms at a deeper level. 

        Tuesday, January 05, 2021

        Topic Wise or Random Practice ?

         Topic wise practice if fine when you are learning the basics of data structures and algorithms. You basically can be operating in either Learning Mode or Practice Mode. When you are in learning mode, it's ok to practice by topic otherwise you should not be practicing by topic. Because, you have to develop the ability to recognize what data structure and algorithm to use just like a real interview.

        Leetcode Live Coding Thread Discussion Link

         https://leetcode.com/discuss/general-discussion/1002477/Leetcode-Live-Coding