Thursday, May 18, 2023

Ruby Basics

Basics of Ruby

 

Start Ruby interpret

On terminal just type rib

ruby_docs $ irb
3.0.0 :001 > name = "This is the first string in Ruby"
 => "This is the first string in Ruby"
3.0.0 :002 > name.length
 => 32
3.0.0 :003 >

Introduction to Objects

Everything is an object

self


Talking to objects

3.even?

Method chains, it will give you 3 as output.

1.next.next

if you want to know the all applicable methods on any object just use the methods on the instance like below.

self.methods
self.methods.sort
"This is string".methods.sort


More Objects and Methods

Looking up methods

1.minutes
1.methods.sort

Invoking methods with arguments

['rock','paper','scissors'].index('paper')

use the between? method to determine if the number 2 lies between the numbers 1 and 3.
 
2.between?(1,3)


Syntactic Sugar for Special Methods

Special Methods

4.+(3)
1+2   # this is same as 1.+(2) 

words = ["foo", "bar", "baz"]
words[1]

above code can be written in below style.
words = ["foo", "bar", "baz"]
words.[](1)

page end here

Friday, May 5, 2023

compare two branches

 git diff <local branch> <remote>/<remote branch>

For example, git diff main origin/main, or git diff featureA origin/next


git diff origin/master  upstream/master


git diff master upstream/master

Monday, January 30, 2023

Git command Cherry-Pick

To get the commit changes in your branch, use the cherry-pick command of git as below.


    $ git cherry-pick commit-hash
  

changing the commit message of the last commit.

    $ git commit --amend -m "New commit message"

then do

    $ git push


Monday, September 5, 2022

version

 war {

    dependsOn('generateBuildVersion')

    archiveName 'lms.war'

    from('../frontend/dist')

}


task generateBuildVersion {

    doLast {

        def jsonFile = file('../frontend/src/app/version.json')

        def parsedJson = new groovy.json.JsonSlurper().parseText(jsonFile.text)

        parsedJson.versionNumber = parsedJson.versionNumber + 0.01

        parsedJson.releaseDate = Date.newInstance().format('MM/dd/yyyy')

        def jsonStr = JsonOutput.toJson(parsedJson)

        def jsonData = JsonOutput.prettyPrint(jsonStr)

        jsonFile.write(jsonData)

    }

}




{

    "versionNumber": 1.03,

    "releaseDate": "09/01/2022"

}



src/app/version.json


LoginComponent.ts


  versionNumber: number;

  releaseDate: string;

  

  

  constructor(

    private notification: NotificationService

  ) {

    this.versionNumber = this.sessionService.versionNumber;

    this.releaseDate = this.sessionService.releaseDate;

  }

  

  

  

SessionService.ts



  versionNumber: number;

  releaseDate: string;

  

    constructor() {

      this.versionNumber = +version.versionNumber;

    this.releaseDate = version.releaseDate;

  }


  LoginComponent.html

  

                <div>

                <p class="alignleft">{{ releaseDate }}</p>

                <p class="alignright">{{ versionNumber }}</p>

              </div>

  

  

package json

{

  "name": "lms-web",

  "version": "1.0.0",

  "scripts": {

    "ng": "ng",

    "start": "ng serve --proxy-config proxy.conf.json --live-reload false --port 4200",

    "build": "ng build --prod --aot --build-optimizer --common-chunk --vendor-chunk --optimization --progress --base-href /projname/",

    "test": "ng test --code-coverage --watch false",

    "lint": "ng lint",

    "lintcs": "ng lint --format checkstyle > checkstyle/frontend.xml",

    "e2e": "ng e2e --base-href /projname/ --aot --webdriver-update false --proxy-config proxy.conf.json"

  },

  "private": true,

  "dependencies": {

    "@angular/animations": "~11.2.4",

  },

  "devDependencies": {

    "@angular-devkit/build-angular": "~0.1102.3",

  }

}


 

intelli j short cut keys

 

Ctrl + Shift + F

Search a word in All files in a project

Ctrl + Shift + N

Search for a file by name

Ctrl + N

Open any class quickly

Ctrl + E

Open recent files

Ctrl + Alt + à

Navigate further to the files

Ctrl + Alt + ß

Navigate to the previous files

Ctrl + F3

Navigate to occurrence in forward direction

Shift + F3

Navigate to occurrence in the backward direction

Ctrl + H

Type hierarchy / Class Hierarchy

Ctrl + Alt + L

Format Code inside a file

Alt + Enter

To import the classed from jars

Ctrl + Alt + O

Optimize imports (never import package/class, Only optimize)

Ctrl + F12

Open methods in pop up with All methods and variables

 

 

 

 

 

F8

Run/execute      // This will jump to another breakpoint

F10

Step Over            // This can be used to step by step line debugging

F11

Step Into              // This will go inside method call

F12

Close DevTools/end debugging

Ctrl + p

Open source code file in DevTools

 

Thursday, September 1, 2022

primeng appendto

 <div class="container-fluid" #parentDiv>

  <div class="row">


    <mat-toolbar color="primary">


      <span (click)="openHomePage($event)">Student management System</span>

      <span class="example-spacer"></span>


      <p-dropdown [options]="listItems" [(ngModel)]="selectedItem" [appendTo]="parentDiv" placeholder="Select Year Period"

                  (onChange)="valueOnChange($event)" dataKey="value">

        <ng-template let-item pTemplate="selectedItem">

          <div class="option-wrapper">

            <span class="option-value">{{selectedItem}}</span>&nbsp;

          </div>

        </ng-template>


        <ng-template let-object pTemplate="item">

          <div class="option-wrapper">

            <span class="option-value">{{object.value}}</span>&nbsp;

            <mat-icon class="option-icon">{{object.label}}</mat-icon>

          </div>

        </ng-template>

      </p-dropdown>

      </mat-toolbar>


  </div>

</div>

Ruby Basics

Basics of Ruby   Start Ruby interpret On terminal just type rib ruby_docs $ irb 3 . 0 . 0 : 001 > name = "This is the first ...