Showing posts with label uki. Show all posts
Showing posts with label uki. Show all posts

Tuesday, August 15, 2017

Express




    💥Express is a minimal and flexible Node.js web application framework that provides a robust set of features to develop web and mobile applications. It facilitates the rapid development of Node based Web applications.

     💥Following are some of the core features of Express framework −
  • Allows to set up middle wares to respond to HTTP Requests.
  • Defines a routing table which is used to perform different actions based on HTTP Method and URL.
  • Allows to dynamically render HTML Pages based on passing arguments to templates.

    💥Install the Express framework globally using NPM so that it can be used to create a web application using node terminal.
           npm install express --save 

    
    💥we should install the following important modules along with express 

  • body-parser − This is a node.js middleware for handling JSON, Raw, Text and URL encoded form data.
            npm install body-parser --save

  • cookie-parser − Parse Cookie header and populate req.cookies with an object keyed by the cookie names.
           npm install cookie-parser --save

  • multer − This is a node.js middleware for handling multipart/form-data.
           npm install multer --save

     💥Request & Response

              Express application uses a callback function whose parameters are request and response objects.

          app.get('/',function()
                 {

                  })

  •  Request Object − The request object represents the HTTP request and has properties for the request query string, parameters, body, HTTP headers.
  • Response Object − The response object represents the HTTP response that an Express app sends when it gets an HTTP request.

Scrum

     💥The ability to create and respond to change in order to succeed in an uncertain and turbulent environment. Agile is a time boxed, iterative approach to software delivery that builds software incrementally from the start of the project, instead of trying to deliver it all at once near the end.
               The Agile movement seeks alternatives to traditional project management. Agile approaches help teams respond to unpredictability through incremental, iterative work cadences and empirical feedback. Agilists propose alternatives to waterfall, or traditional sequential development.

 💥The Four Agile Manifesto Values are:
  • Individuals & Interactions over processes and tools
  • Working Software over Comprehensive Documentation
  • Customer collaboration over contract negotiation
  • Responding to Change over following a plan
 
 💥Agile Principles are:
  1. Satisfy the customer.
  2. Welcome changing requirements.
  3. Face-to-face meetings are the most effective way to convey information
  4. Working software is the primary measure of progress
  5. Continuous attention to technical excellence and good design enhances agility
  6. Simplicity is essential
  7. Let the team reflect on how to do better at regular intervals and adjust behavior accordingly

 
 


      

                💥Scrum is a framework for managing software development. Scrum is designed for teams of 3 to 9 developers who break their work into two-week cycles, called "sprints", check progress daily in 15-minute stand-up meetings, and deliver workable software at the end of every sprint.Approaches to coordinating the work of multiple scrum teams in larger organizations include Large-Scale Scrum and Scrum of Scrums.Scrum is part of the Agile movement.

   💥What is Daily Stand-up?

  • A daily stand-up is a daily status meeting among all team members and it is held roughly for 15 minutes.
  • Every member has to answer three important questions −
    • What I did yesterday?
    • What I'll do today?
    • Any impediment I am facing.../ I am blocked due to...
     
  • Daily stand-up is for status update, not for any discussion. For discussion, team members should schedule another meeting at a different time.
  • Participants usually stand instead of sitting so that the meeting gets over quickly.



  
  💥Scrum has three roles: Product Owner, Scrum Master, and Team.

      👸Scrum Master

A Scrum Master is a team leader and facilitator who helps the team members to follow agile practices so that they can meet their commitments. The responsibilities of a scrum master are as follows −
  • To enable close co-operation between all roles and functions.
  • To remove any blocks.
  • To shield the team from any disturbances.
  • To work with the organization to track the progress and processes of the company.
  • To ensure that Agile Inspect & Adapt processes are leveraged properly which includes
    • Daily stand-ups,
    • Planned meetings,
    • Demo,
    • Review,
    • Retrospective Meetings, and
    • To facilitate team meetings and decision-making process.
                
          👸Product owner
  •  The product owner is commonly a lead user of the system or someone from marketing, product management or anyone with a solid understanding of users, the market place, the competition and of future trends for the domain or type of system being developed.communication is a large part of the product owner responsibilities. The product owner role requires working closely with key stakeholders throughout the organization and beyond, so he or she must be able to communicate different messages to different people about the project at any given time.

      👸Team
 According to Scrum’s founder, “the team is utterly self managing.” The development team is responsible for self organizing to complete work. For software projects, a typical team includes a mix of software engineers, architects, programmers, analysts, QA experts, testers, and UI designers. Each sprint, the team is responsible for determining how it will accomplish the work to be completed. The team has autonomy and responsibility to meet the goals of the sprint.

Monday, August 14, 2017

Authentication in React Applications

    💥we have built the initial application with presentational and container components for the sign-up form, the login form, and the home component.

    💥we need to add new dependencies

   👸 bcrypt is a package with the bcrypt algorithm implementation for hashing passwords
  👸  jsonwebtoken is an implementation of JSON Web Token standard
  👸 mongoose is a MongoDB ORM library
  👸 passport is a flexible authentication library
  👸 passport-local is a Passport strategy for authenticating with an email and a password


    💥We can install these packages by typing:
 
npm install --save bcrypt jsonwebtoken mongoose passport-local

    💥The application will have the next directory structure



  💥 Index.js file

const express = require('express');
const bodyParser = require('body-parser');
const passport = require('passport');
const config = require('./config');

// connect to the database and load models
require('./server/models').connect(config.dbUri);

const app = express();
// tell the app to look for static files in these directories
app.use(express.static('./server/static/'));
app.use(express.static('./client/dist/'));
// tell the app to parse HTTP body messages
app.use(bodyParser.urlencoded({ extended: false }));
// pass the passport middleware
app.use(passport.initialize());

// load passport strategies
const localSignupStrategy = require('./server/passport/local-signup');
const localLoginStrategy = require('./server/passport/local-login');
passport.use('local-signup', localSignupStrategy);
passport.use('local-login', localLoginStrategy);

// pass the authenticaion checker middleware
const authCheckMiddleware = require('./server/middleware/auth-check');
app.use('/api', authCheckMiddleware);

// routes
const authRoutes = require('./server/routes/auth');
const apiRoutes = require('./server/routes/api');
app.use('/auth', authRoutes);
app.use('/api', apiRoutes);


// start the server
app.listen(3000, () => {
  console.log('Server is running on http://localhost:3000 or http://127.0.0.1:3000');
});

The property jwtSecret of the config object contains a secret phrase our application will use to sign tokens.

config/index.json
 {
"dbUrl": "mongodb://localhost/react_app",
"jwtSecret": "a secret phrase! !"
}

 
 
      💥The bcrypt module will generate a hash from a generated earlier salt string and a user’s password. This hash instead of a user’s password will be saved in the collection.

       user.password = hash;

 
     💥The basic logic here is to check if a user with a given email exists. If so, we will compare the given password’s hash value with a value saved in the database. If the user exists and the password is correct, we will create a JSON Web Token (JWT).

          The token looks similar to this:


eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.
eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiYWRtaW4iOnRydWV9.
TJVA95OrM7E2cBab30RMHrHDcEfxjoYZgeFONFh7HgQ
 

 

Sunday, August 13, 2017

Tic-tac-toe

If you want to do Tic-tac-toe, here are the steps to follow:

     😛Make sure you have a recent version of node js installed.
     😝Follow the installation instructions to create a new project.
         
             👉 npm install -g create-react-app
                 create-react-app my-app

                 cd my-app
                 npm start

         

  😝Delete all files in the src/ folder of the new project.
  😝 Add a file named index.css in the src/folder with css code.
      
     👉 body {
  font: 14px "Century Gothic", Futura, sans-serif;
  margin: 20px;
}

ol, ul {
  padding-left: 30px;
}

.board-row:after {
  clear: both;
  content: "";
  display: table;
}

.status {
  margin-bottom: 10px;
}

.square {
  background: #fff;
  border: 1px solid #999;
  float: left;
  font-size: 24px;
  font-weight: bold;
  line-height: 34px;
  height: 34px;
  margin-right: -1px;
  margin-top: -1px;
  padding: 0;
  text-align: center;
  width: 34px;
}

.square:focus {
  outline: none;
}

.kbd-navigation .square:focus {
  background: #ddd;
}

.game {
  display: flex;
  flex-direction: row;
}

.game-info {
  margin-left: 20px;
}







 😜Add a file named index.js in the src/ folder with Js code.

     👉import React from 'react';
      import ReactDOM from 'react-dom';
      import './index.css';

      class Square extends React.Component {
  render() {
    return (
      <button className="square">
        {/* TODO */}
      </button>
    );
  }
}

class Board extends React.Component {
  renderSquare(i) {
    return <Square />;
  }

  render() {
    const status = 'Next player: X';

    return (
      <div>
        <div className="status">{status}</div>
        <div className="board-row">
          {this.renderSquare(0)}
          {this.renderSquare(1)}
          {this.renderSquare(2)}
        </div>
        <div className="board-row">
          {this.renderSquare(3)}
          {this.renderSquare(4)}
          {this.renderSquare(5)}
        </div>
        <div className="board-row">
          {this.renderSquare(6)}
          {this.renderSquare(7)}
          {this.renderSquare(8)}
        </div>
      </div>
    );
  }
}

class Game extends React.Component {
  render() {
    return (
      <div className="game">
        <div className="game-board">
          <Board />
        </div>
        <div className="game-info">
          <div>{/* status */}</div>
          <ol>{/* TODO */}</ol>
        </div>
      </div>
    );
  }
}



ReactDOM.render(
  <Game />,
  document.getElementById('root')
);



😝In particular, we have three components:

  • Square
  • Board
  • Game
The Square component renders a single <button>, the Board renders 9 squares, and the Game component renders a board with some placeholders that we'll fill in later. None of the components are interactive at this point.

     
😝passing some data from the Board component to the Square component.

   👉class Square extends React.Component {
  render() {
    return (
      <button className="square">
        {this.props.value}
      </button>
    );
  }
}

class Board extends React.Component {
  renderSquare(i) {
    return <Square value={i} />;
  }

  render() {
    const status = 'Next player: X';

    return (
      <div>
        <div className="status">{status}</div>
        <div className="board-row">
          {this.renderSquare(0)}
          {this.renderSquare(1)}
          {this.renderSquare(2)}
        </div>
        <div className="board-row">
          {this.renderSquare(3)}
          {this.renderSquare(4)}
          {this.renderSquare(5)}
        </div>
        <div className="board-row">
          {this.renderSquare(6)}
          {this.renderSquare(7)}
          {this.renderSquare(8)}
        </div>
      </div>
    );
  }
}

class Game extends React.Component {
  render() {
    return (
      <div className="game">
        <div className="game-board">
          <Board />
        </div>
        <div className="game-info">
          <div>{/* status */}</div>
          <ol>{/* TODO */}</ol>
        </div>
      </div>
    );
  }
}


ReactDOM.render(
  <Game />,
  document.getElementById('root')
);
    

                 


😝Declaring a Winner

 when a game is won. Add this helper function

👉function calculateWinner(squares) {
  const lines = [
    [0, 1, 2],
    [3, 4, 5],
    [6, 7, 8],
    [0, 3, 6],
    [1, 4, 7],
    [2, 5, 8],
    [0, 4, 8],
    [2, 4, 6],
  ];
  for (let i = 0; i < lines.length; i++) {
    const [a, b, c] = lines[i]; 
if (squares[a] && squares[a] === squares[b] && squares[a] === 
squares[c]) {
      return squares[a];
    }
  }
  return null;
}

  😝If you want any changes in this game. you only change in index.js file.

final index.js code.

   👉 import React from 'react';
    import ReactDOM from 'react-dom';
    import './index.css';



function Square(props) {
  return (
    <button className="square" onClick={props.onClick}>
      {props.value}
    </button>
  );
}

class Board extends React.Component {
  renderSquare(i) {
    return (
      <Square
        value={this.props.squares[i]}
        onClick={() => this.props.onClick(i)}
      />
    );
  }

  render() {
    return (
      <div>
        <div className="board-row">
          {this.renderSquare(0)}
          {this.renderSquare(1)}
          {this.renderSquare(2)}

        </div>
        <div className="board-row">
          {this.renderSquare(3)}
          {this.renderSquare(4)}
          {this.renderSquare(5)}

        </div>
        <div className="board-row">
          {this.renderSquare(6)}
          {this.renderSquare(7)}
          {this.renderSquare(8)}

        </div>
      </div>
    );
  }
}

class Game extends React.Component {
  constructor() {
    super();
    this.state = {
      history: [{
        squares: Array(9).fill(null)
      }],
      xIsNext: true
    };
  }

  handleClick(i) {
    const history = this.state.history;
    const current = history[history.length - 1];
    const squares = current.squares.slice();
    if (calculateWinner(squares) || squares[i]) {
      return;
    }
    squares[i] = this.state.xIsNext ? 'X' : 'O';
    this.setState({
      history: history.concat([{
        squares: squares
      }]),
      xIsNext: !this.state.xIsNext,
    });
  }

  render() {
    const history = this.state.history;
    const current = history[history.length - 1];
    const winner = calculateWinner(current.squares);

    const moves = history.map((step, move) => {
      const desc = move ?
        'Move #' + move :
        'Game start';
      return (
        <li>
          <a href="#" onClick={() => this.jumpTo(move)}>{desc}</a>
        </li>
      );
    });

    let status;
    if (winner) {
      status = 'Winner: ' + winner;
    } else {
      status = 'Next player: ' + (this.state.xIsNext ? 'X' : 'O');
    }

    return (
      <div className="game">
        <div className="game-board">
          <Board
            squares={current.squares}
            onClick={(i) => this.handleClick(i)}
          />
        </div>
        <div className="game-info">
          <div>{status}</div>
          <ol>{moves}</ol>
        </div>
      </div>
    );
  }
}



ReactDOM.render(
  <Game />,
  document.getElementById('root')
);

function calculateWinner(squares) {
  const lines = [
    [0, 1, 2],
    [3, 4, 5],
    [6, 7, 8],
    [0, 3, 6],
    [1, 4, 7],
    [2, 5, 8],
    [0, 4, 8],
    [2, 4, 6],
  ];
  for (let i = 0; i < lines.length; i++) {
    const [a, b, c] = lines[i];
    if (squares[a] && squares[a] === squares[b] && squares[a] === squares[c]) {
      return squares[a];
    }
  }
  return null;
}

If you intrested play this tic-tac-toe game,you will  go to this URL 

 https://ukifunwork3byabi.herokuapp.com/ 

Sunday, July 30, 2017

Heroku


Heroku is a cloud platform as a service supporting several programming languages that is used as a web application deployment model.


💥How to use Heroku 

  1. Download the Heroku Toolbelt.
  2. Login: heroku login.
  3. Add your public key: heroku keys:add.
  4. Pull down your current application heroku git:clone -a app-name.
  5. Make your improvements.
  6. Git add and commit your changes.
  7. Push back to heroku: git push heroku master.


 💥Advantage in Heroku

  • Heroku is easy to get started.
  • Heroku is the cheapest option for a low traffic site
  • we don't have to add our credit card for payment at early stage.
  • They offer no of Dyno for upgrade and downgrade app instance
  • Database integration is pretty simple with PostgreSQL

 💥Disadvantage in Heroku
  • we have to pay very high, once we decide to handle more traffic.
  • we have to manually scale our application on hight traffic.
  • we can't login to your server via SSH(Secure Remote Login & File Transfer)

💥What Is SSH Protocol Used for?

The protocol is used in corporate networks for:
  • providing secure access for users and automated processes
  • interactive and automated file transfers
  • issuing remote commands
  • managing network infrastructure and other mission-critical system components.

Friday, July 28, 2017

Postman

A powerful GUI platform to make your API development faster & easier, from building API requests through testing, documentation and sharing. We recommend the free Postman App for Mac, Windows, Linux or Chrome. Developer Teams.

💥 How to work postman
  1. Launch the Postman app.
  2. Go to the Authorization section: Postman Authorization Section.
  3. For the Type, select OAuth 2.0: Authorization Type.
  4. Click Get New Access Token.
  5. Click Request Token.
  6. Click on the name of the token to see you now have access to the new token: Access Token.

 💥What are the benefits to use postman

  • Easily create test suites

    Postman allows we create collections of integration tests to ensure our API is working as expected. Tests are run in a specific order with each test being executed after the last is finished 

    ☺store information for running tests in different environments 


      Postman allows we to store specific information about different environments and automatically insert the correct environment configuration into our test. This could be a base URL, query parameters, request headers, and even body data for an HTTP post.




    ☺ Store data for use in other tests
          Postman also allows we to store data from previous tests into global variables. These variables can be used exactly like environment variables.we can store the response  and use that as part of a request header, post body, or URL for the subsequent API calls.

     ☺Easily move tests and environments to code repositories

            


UI & UX


      💥 While User Experience is a conglomeration of tasks focused on optimization of a product for effective and enjoyable use; User Interface Design is its compliment, the look and feel, the presentation and interactivity of a product. But like UX, it is easily and often confused by the industries that employ UI Designers.

   💥Unlike UX designers who are concerned with the overall feel of the product, user interface designers are particular about how the product is laid out. They are in charge of designing each screen or page with which a user interacts and ensuring that the UI visually communicates the path that a UX designer has laid out.

Free code Camp and Codecadamy & hackerrank



HackerRank is a technology company that focuses on competitive programming challenges for both consumers and businesses, where developers compete by trying to program according to provided specifications.HackerRank's programming challenges can be solved in a variety of programming languages (including Java, C++, PHP,Python,SQL) and span multiple computer science domains.
On the consumer side, when a programmer submits a solution to a programming challenge, their submission is scored on the accuracy of their output and the execution time of their solution.


    
       Codecademy is an online interactive platform that offers free coding classes in 12 different Progamming languages including Python,Java,PHP (jQuery,AngularsJS,React.js),Ruby,SQl,Sass,as well as Markup languages HTML and CSS.


FREE CODE CAMP


     FreeCodeCamp is a nonprofit organization that consists of an interactive learning web platform, an online community forum, chat rooms,medium publications, and local organizations that intend to make learning web development accessible to anyone. Beginning with tutorials that introduce students to HTML, CSS, and JavaScript, students progress to project assignments that they must complete either alone or in pairs. Upon completion of all project tasks, students are partnered with other nonprofits to build web applications, giving the students practical development experience.

Sunday, July 16, 2017

REACT


React is a declarative, efficient, and flexible JavaScript library for building user interfaces.
It's used for handling view layer for web and mobile apps. ReactJS allows us to create reusable UI components. It is currently one of the most popular JavaScript libraries and it has strong foundation and large community behind it.


React Features

  • JSX − JSX is JavaScript syntax extension. It isn't necessary to use JSX in React development, but it is recommended.
  • Components − React is all about components. 
  • Unidirectional data flow and Flux − React implements one way data flow which makes it easy to reason about our app. 
  • License − React is licensed under the Facebook Inc. 


    React Advantages

  • React uses virtual DOM which is JavaScript object. This will improve apps performance since JavaScript virtual DOM is faster than the regular DOM.
  • React can be used on client and server side.
  • Component and Data patterns improve readability which helps to maintain larger apps.

    React can be used with other frameworks.

     React JSX

    React uses JSX for templating instead of regular JavaScript. It is not necessary to use it, but there are some pros that comes with it.

  • JSX is faster because it performs optimization while compiling code to JavaScript.
  • It is also type-safe and most of the errors can be caught during compilation.
  • JSX makes it easier and faster to write templates if you are familiar with HTML.
 
import React from 'react';

class App extends React.Component {
   render() {

      var i = 1;

      return (
         <div>
            <h1>{i == 1 ? 'True!' : 'False'}</h1>
         </div>
      );
   }
}

export default App;
 
 
 
  React component
 
This component is owner of Header and Content. We are creating Header and Content separately and just adding it inside JSX tree in our App component. Only App component needs to be exported.

App.jsx

import React from 'react';

class App extends React.Component {
   render() {
      return (
         <div>
            <Header/>
            <Content/>
         </div>
      );
   }
}

class Header extends React.Component {
   render() {
      return (
         <div>
            <h1>Header</h1>
         </div>
      );
   }
}

class Content extends React.Component {
   render() {
      return (
         <div>
            <h2>Content</h2>
            <p>The content text!!!</p>
         </div>
      );
   }
}
 
React State 

State is the place where the data comes from.If we have, for example, ten components that need data 
from the state, we should create one container component that will keep
 the state for all of them.


App.jsx

import React from 'react';

class App extends React.Component {
   constructor(props) {
      super(props);
		
      this.state = {
         header: "Header from state...",
         content: "Content from state..."
      }
   }
	
   render() {
      return (
         <div>
            <h1>{this.state.header}</h1>
            <h2>{this.state.content}</h2>
         </div>
      );
   }
}

export default App;