Thursday, 20 April 2023

Kotlin - Observer

 Rxjava - 

Observer - Based on data view willl render (react) karega.

trotling -> making stream for execution (Means clicks event fire krege ek particular duration m taki same event again & again call n ho) 

3 Major Component are there -

    1) Observable

    2) Observer

    3) Operator 


class MainActivity : AppCompatActivity() {

private var TAG:String = "MainActivity"

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)

var btn_throttleFirst : Button = findViewById(R.id.btn_throttleFirst)

btn_throttleFirst.clicks()
.throttleFirst(15000,TimeUnit.MILLISECONDS)
.subscribe {
Log.d(TAG,"throttleFirst duration : 15000 MLS")
}

simpleObserver()
}

private fun simpleObserver(){
var list = listOf<String>("member 1","member 2","member 3")
val observable = io.reactivex.rxjava3.core.Observable.fromIterable(list)

observable.subscribe(object : io.reactivex.rxjava3.core.Observer<String>{
override fun onSubscribe(d: Disposable) {
Log.d(TAG,"onSubscribe")
}

override fun onError(e: Throwable) {
Log.d(TAG,"onError")
}

override fun onComplete() {
Log.d(TAG,"onComplete")
}

override fun onNext(t: String) {
Log.d(TAG,"onNext")
}

})

}
}


output -

 throttleFirst duration : 15000 MLS


Wednesday, 8 February 2023

Node-Js (REPL)

 1) Using For Debug JavaScript code & Experiment Code.

    R- READ 

    E- EVAL 

    P- PRINT 

    L- LOOP 


2) Make New File

    type nul > index.js <-|

3) Delete File

    del nul > Filename

4) Express Js - 

        It Will Provide Simple Rest Api's.

5) node install express --save

6) npm init


Friday, 5 August 2022

SwiftUi - Login Page Example

 //

//  ContentView.swift

//  Chapter1

//

//  Created by Kamal Nishad.

//


import SwiftUI


struct ContentView: View {


    @State private var username: String = ""

    @State private var password:String = ""


    

    var body: some View {

        

        VStack{

            

            WelcomeText()

            UserImage()

            

            TextField("Enter Username",text: $username)

                .padding()

                .background(.regularMaterial)

                .cornerRadius(5.0)

                .padding(.bottom, 0)

        

            SecureField("Enter Password",text: $password)

                .padding()

                .background(.regularMaterial)

                .cornerRadius(5.0)

                .padding(.bottom,5)

            

            Text("Login")

                .font(.headline)

                .foregroundColor(.white)

                .padding()

                .frame(width: 150, height: 50)

                .background(Color.green)

                .cornerRadius(15.0)

 

        }

    }

}



struct WelcomeText:View{

    var body: some View{

       return Text("Welcome")

            .font(.largeTitle)

            .fontWeight(.semibold)

            .padding(.bottom,20)

    }

}


struct UserImage : View{

    var body: some View{

        return Image("profile")

            .resizable()

            .aspectRatio(UIImage(named:"profile")!.size,contentMode: .fill)

            .frame(width: 120, height: 120)

            .clipped()

            .cornerRadius(180)

            .padding(.bottom,20)

    }

}


struct ContentView_Previews: PreviewProvider {

    static var previews: some View {

        ContentView()

    }

}


Tuesday, 17 May 2022

ReactiNative ListView

import { StatusBar } from 'expo-status-bar';
import { useState } from 'react';
import { Button, StyleSheet, Text, View,TextInput,ScrollView, } from 'react-native';

export default function App() {
  const [enteredGoalText, setEnteredGoalText] = useState('');
  const [courseGoals,setCourseGoals] = useState([]);

  function goalInputHandler(enterdText){
    setEnteredGoalText(enterdText);
  };

  function goalAddHandler(){
    setCourseGoals(currentCourseGoal => [
              ...currentCourseGoal,
              enteredGoalText,
            ]);
  };


  return (
    <View style={styles.appContainer}>
        <View style={styles.inputContainer}>
          <TextInput style={styles.textInput}
                     placeholder="Your course is here"
                     onChangeText={goalInputHandler} />
         
          <Button title='Sumbit' onPress={goalAddHandler}/>

        </View>
        <View style={styles.goalsContainer}>
          <ScrollView alwaysBounceVertical={false}>
                  {courseGoals.map((goal)=>
                      <View  key={goal} style={styles.goalItem}>
                        <Text style={styles.goleText}>{goal}</Text>
                      </View>
                    )}
          </ScrollView>
        </View>
    </View>
  );
}

const styles = StyleSheet.create({
    appContainer:{
      flex:1,
      paddingTop:20,
      paddingHorizontal:16,
    },
    inputContainer:{
      flex:1,
      flexDirection:'row',
      justifyContent:'space',
      alignItems:'center',
      padding:24,
      borderBottomWidth:1,
      borderBottomColor:'#cccccc',
      borderPaddingLef:24
    },
    textInput:{
      borderWidth:2,
      borderColor:'#cccccc',
      width:'70%',
      marginRight:8,
      padding:8,
    },
    goalsContainer:{
        flex:4
    },
    goalItem:{
      margin:8,
      padding:8,
      borderRadius:6,
      backgroundColor:'#5e0acc',
      color:'white',
    },
    goleText:{
        color:'white',
    },
    listTxt:{
      paddingLeft:24,
      paddingTop:10
    }
});

Thursday, 10 February 2022

Nodejs - Prototype

 prototype = provide ability for adding new methods or class (Example- Inherit)


1) Home.js

var cal = require("./addition");
cal.addition();
console.log(cal.aval)

2) addition.js

module.exports={
    addition:function(){
        console.log("this is addition module");
    },
    aval:20
}


o/p ->

this is addition module

20


Nodejs- Templete String

 var name ="kamal"

var age = "26"


console.log("value of %s and %s",name,age)

//or

console.log("value one: "+name+"value two: "+age)

//now templete string example is...
console.log(`name ${name} age ${age}`)

Nodejs - Class Example

  Class Example

class users{                         ///creteing class

        constructor(name,age){              //declare constructor
            this.name =name;
            this.age=age;
        }
   
        getName(){
            this.email ="dev@gmail.com";
            return this.name;
        }

        getAge(){
            return this.age;
        }

        getEmail(){
            return this.email;
        }
}

///now crete object of class
var user = new users("kamal","26");
console.log(user.getName())
console.log(user.getAge())
console.log(user.getEmail()) ///agar getName() function define ne rhege pahle to undefine k error ayega



OUTPUT
kamal 26 dev@gmail.com




Wednesday, 9 February 2022

Nodejs - ECMA Concept

ECMA Concept

-> 'let ' is an scope varible it can't be use as globle varible

-> if we'r using 'var' in place of let it will re-assign last defined value (means

    var a = 30

    var a = 30

    console.log("value of a is:"+a)

OUTPUT-

        value of a is = 30

)

if we are using 'let' inplace of var then it look like

let a=40;

let a=30;

OUTPUT

SyntaxError: Identifier 'a' has already been declared

    at wrapSafe (internal/modules/cjs/loader.js:1001:16)

    at Module._compile (internal/modules/cjs/loader.js:1049:27)

    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)

    at Module.load (internal/modules/cjs/loader.js:950:32)

    at Function.Module._load (internal/modules/cjs/loader.js:790:12)

    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:76:12)

    at internal/main/run_main_module.js:17:47 


if we using scope varible

let a=30;


function esma_example(){
    let a = 40;
    console.log("value of a under function :"+a);
}

esma_example()
console.log("value of a:"+a);


output-

value of a under function :40

value of a:30


Nodejs- module exports

module exports

->it will help to get/fetch one module data into another module

main.js 

var name = "Kamal"
var person = function(a,b){
    var c = a+b
    console.log("sum of "+ a +" and "+ b +" is "+ c)
}

person(5,5);

module.exports.exp_example = name;


global_object.js

var main = require("./main")
console.log(__dirname)
console.log(__filename)
console.log(main.exp_example)


OUTPUT-

K:\NodeJs\Node Basics\chapter-1

K:\NodeJs\Node Basics\chapter-1\globalObject.js

Kamal

Nodejs - Global Objects

 Global Objects

-> We have two js files for accessing main.js objects we are using this functions in object.js

1)main.js

var person = function(a,b){
    var c = a+b
    console.log("sum of "+ a +" and "+ b +" is "+ c)
}

person(5,5);

2)global_objects.js

var main = require("./mian")
console.log(__dirname)
console.log(__filename)


output
sum of 5 and 5 is 10 K:\NodeJs\Node Basics\chapter-1 K:\NodeJs\Node Basics\chapter-1\globalObject.js




Nodejs - Arrow Functions

Arrorw Functions :
    
        -> Its a shortest way to define functions.

             EXAMPLE:    
            
            Without Parameter

                    var kamal =()=>{console.log("Its a arrow functions")}
                   
                     kamal()            ///call function

            With Parameter

                    var kamal =(a)=>{console.log("value of a is :"+a)}
                    
                    kamal(5)          ///call function

            With Multiple Parameter

                    var kamal =(a,b)=>{
                                
                    var  c=a+b
                    console.log("value of c is :"+c)}
                    
                    kamal(5,5)          ///call function

OUTPUT- value of c is :10

Nodejs - Anonymous Functions

 Anonymous Functions

    -> define variable then function

    Ex.-        !) Without parameter.... 

                     ver kamal = function(){

                        console.log("Its a anontmous function");

                    }

                    kamal()              ///call functions


                !!) With parameter...

                    var kamal = funtion(a,b){

                     var c = a+b

                    console.log("The value of  c is : "+c)

                     }


                    kamal(5,5)          //call functions


OUTPUT -  The value of  c is :10

NOTE: There is no name infront of function thats why its a anonymous function.



Thursday, 2 December 2021

NodeJs - Node Http & Query String

Basic Conecpts For Creating server and response code

Its a inbuilt modul with help of this module we can perform meny operationsIt Handle - Request & Response beacause it is a Hypertext Text Transfer Protocol(get request from user and give response to server)

1) For creating server we need Http module..

2) Url Handling : For Handlng Url we can use

var http = require('http');  --> inbuild module it access via direct requre method can access

var server = http.createServer(function(req , res){       ///create server

//Request Status , Content Type

server.writeHead(200,{"content-type":"text/plain"})

var url = req.url;                 //Url Handling

res.write(url)

res.end('Response End')     //print message

}) .listen(3000);


Note : Query String = Send Variable in browser with url

Url Handling

var http = require('http');  --> inbuild module it access via dirct method

var url = require('url');             //Handling Querystring

var server = http.createServer(function(req , res){       ///create server

server.writeHead(200,{"content-type":"text/plain"})

var result = url.parse(www.google.com?id=10, true).query;

res.write(res.name);   //things whinch want to get like name


}) .listen(3000);



Run-> localhost://300

Monday, 22 November 2021

Kotlin - Functions

 function with two Int parameters and Int return type.

sum of 3 and 5 is 8

A function body can be an expression. Its return type is inferred.

sum of 19 and 23 is 42

Kotlin - Observer

 Rxjava -  Observer - Based on data view willl render (react) karega. trotling -> making stream for execution (Means clicks event fire kr...