06 August 2022

Quotations of the Day !!

"Distraction is like a parasite to the mind, if you don't kill distraction, distraction will kill your dreams" ~ monk


“From the poorest of countries to the richest of nations, education is the key to moving forward in any society.” — Nelson Mandela    

22 July 2020

How to watch tata sky on laptop?

If you have active Tata Sky account at home, you can watch all channels from anywhere using laptop or mobile:

For Laptop go to below link:

https://www.tatasky.com/dth/mobile-app-download

Click on Watch on Web link to see TV. Enter login / password as required.

For Mobile, from same link above download Tata Sky App.



Heartfullness Meditation Technique

Do cleansing of body and mind before sleep / after long work hours :
for 5mins imagine complexities or impurities are going out from back from the heart.
for next 5 mins imagine the vocuum left behind by first step is filled with sacred stuff.



Daily Meditation technique:

Focus on heart, start meditation for 30mins to 1hour. 2 times daily is good.

24 April 2020

Maven Fundamentals (Course on Plural Sight):

Maven

  • Works with Eclipse/ net beans.
  • Preferred choice for working with build tools like Cruise Control/Bamboo.
  • Ant is build on top of Java and XML in procedural way. Ant developed to be replacement for unix build tool Make. You need to define everything you want to do like clean/clear/cleanup etc. No inheritance, no reuse. Ant is scripting tool.
  • using Maven it is full fledged build tool.
  • transitive dependencies and capable to achieve inheritance in projects. In Maven we have pom.xml unlike build.xml in ant. Maven is interested in managing entire project life cycle.
  • Copy apach-maven-3.5.0 and add bin directory of maven to Path environment variable. run below command to know the version of maven
    mvn -version
  • Create a General project in STS and name it TestCalculator and add a file to the project with name pom.xml (project object model). and create a java file in that with some text printing on to the console.
    contents of pom.xml
<project>
<groupId>com.pluralsight</groupId>
<artifactId>TestCalculator</artifactId>
<version>1.0-SNAPSHOT</version>
<modelVersion>4.0.0</modelVersion>
<packaging>jar</packaging>

</project>
  • now navigate to the workspace folder from command prompt and run
mvn clean
mvn compile
then
go to
cd target/classes
and run below command to print output Madhu
java TestCalculator
  • run below command to create jar file as per pom.xml
    mvn package
all java code goes to src/main/java directory All test code is in src/test/java . All other language code is in src/main/groovy directory. All classes after compiling goes to target/classes/

some maven commands useful:

mvn clean package
mvn install
this will run package command and move the .jar to the C:\users\talakokm.m2\repository in that with group name set in pom.xml
even dependencies are copied here

Goals

clean
compile: compile src/main directory and move the classes to target/classes.
package: create jar/ear/war
install:Run package command and installs to local repository.
deploy: run install command and deploys to corporate repository.

pom.xml contents

Project is of 4 parts
groupId: is used in packaging of application like com.cdk
artifaceId: is application name.
version: version number of application.
packaging: is to mention how we want to package the application for example .war/.ear/.jar.
Dependencies
transitive dependencies will be pulled by Maven , it needs 3 things
groupId
artifactId
version
Example:
<dependencies>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang<artifactId>
<version>2.1</version>
</dependency>
</dependencies>
Add below build tag to pom.xml to set final name of our application while building application:
<build>
<finalName>foo</finalName>
</build>
now foo.jar is created in target directory with name foo.jar

Transitive dependencies:

Is the main reason why we use Maven.
Example: Add below dependency it will download all transitive dependencies.
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<versions>4.1.6.Final</version>
<scope>compile</scope>
</dependency>

Scope types in dependency:
There are six types of scopes available in dependencies.
compile - default scope. available everywhere
provide - like compile. available everywhere but not included in final artifact.
runtime - available only in runtime.
test - only available for test compilation/execution phase.
SNAPSHOT has special meaning. every compile or run picks up latest code.

Dependency Repository:

is where we store/download all our dependencies
specifying our own repository
<repositories>
<repository>
<id>spring-snapshot</id>
<name>Spring Maven SNAPSHOT Repository</name>
<url>http://repo.springsource.org/libs-snapshot</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
<releases>
<enabled>false</enabled>
</releases>
</repository>
</repositories>

Convert project to Maven Project via STS

in STS , select the project and right click and select configure --> convert to Maven project.

Adding dependencies:

using pom viewer we can edit pom.xml
also using dependencies tab we can update/add dependencies. dependency hierarchy automatically updated after save.

Effective POM

there is tab called Effective POM on pom.xml useful for debugging pom.xml to know what pom is doing.

Angular2 Training Notes

https://www.npmjs.com/package/typescript

search for typescript in find packages and install using 'npm install -g typescript'

create two directories src and dist in same directory

npm run compile

go to es6-features.org website

www.typescriptlang.org

Java script features:
default parameters

http://bit.ly/javascript-training-videos

Rest operator
Spread operator

typescript-lang.org

An Angular properties are:

module
component
directive
pipe
service

in angular 1.x everything is function and in angular 2.x everything is class.
A module is a collection of services, directives, controllers, filters, and configuration information.
Component is template.
Directive is dom manipulation.
pipe is used for transforming data for presentation.
service is non UI logic.

command to install a tool to help us create angular application.
npm install -g @angular/cli

run command to list all the commands
ng --help
How to create new project
ng new first-app
this will take more time, so exit using ctrl+c and go to directory
cd first-app

now run below command to install
npm install

now run below command to create application
npm run start
now you can view your application :
http://localhost:4200/
command to generate component directory and respective files using angular cli:
ng generate component [name] generates a component folder in the directory where it had run and creates html .ts and .spec.ts files.
example: ng generate component accountlist

it creates several direectory.
package.json is configuration file.
tslint.json check whether coding standards are followed by you in the project or not it is configuration file.
karma.conf.js is a tool to execute your tests in different browsers.
protractor.conf.js end user testing. useful to write end to end testing. this is configuration file.

@NgModule is annotatioin to specify a class as module.
app.component.js is a class and exporting the class which is coming from angular/core.
main.ts
by default anything defined in ts will not be shown to user unless you export it.


Day 5:
==========================
pure function:

method defined in component will gets triggered twice for every state change.
Redux is used to maintain data/store. Redux is available as ngRx for angular. so explore it in free time. It is state manager for angular.

underscore in java is alternate to for loop in java.
filter/maps also.

example in javascript for not using for loop:
numbers[] = {1,2,3,4,5,6};


numbers.filter(function(number){return number%2===0;})

using map
numbers.map() copy one list to another.

numbers.reduce is used to reduce the list or peforming aggregate functions.

window.localStorage for local storage.
======================
* key/value store
* key & value must be strings
* key can be incremental value starting 1
* use JSON.stringify /JSON.parse for serialization or deserialization
*local storage uses  Same origin policy meaning only one domain like a.com:444 can access it
* API's
=====
- setItem(key,value)
- getItem(key) returns value
- removeItem(key)
- key(index) return key of index
- clear()
- length

Type Script playground link:
from command prompt we can run "tsc app.ts" to generate app.js file.




References: