Wednesday, August 5, 2020

Git & GitHub Crash Course: Create a Repository From Scratch!

git clone URL

git status

git add README.md

git status

git commit -m "Initial commit"

git push origin master

git add index.html (adding to git after creating index.html)

git diff README.md (what lines have changed)

git commit -m "Second commit" (m stands for message here)

git log

git checkout README.md (undo if you mess up your code)


Friday, April 24, 2020

Making Circle from Square in Python using turtle module

import turtle

my_turtle = turtle.Turtle()

def square(length, angle):
    for i in range(4):       
        my_turtle.forward(length)
        my_turtle.right(angle)

for i in range(50):
    my_turtle.right(10)
    square(100,90)


Thursday, March 26, 2020

Visit Count Session in Node and Express

        if(!request.session.visitcount){
            request.session.visitcount = 0;
        }
        request.session.visitcount += 1
        console.log(`Number of visits: ${request.session.visitcount}`)

Sunday, March 22, 2020

Node JS Tricks


  • If Cannot install thirdparty application via terminal, you will need package.json file for that.

To install package.json file, write this in your terminal

npm init

  • For automated loading of console in visual code or other text editor, you need to install nodemon. For that, you need to install globally with keyword -g
npm install -g nodemon 


  • To access in console bar with nodemon, write this in terminal
    nodemon .\demo.js
  • If  You see the error while running nodemon, Visual studio code cmd error: Cannot be loaded because running scripts is disabled on this system, follow this link

Simple Test and Async Test with Jasmine

npm install --save-dev jasmine

./node_modules/.bin/jasmine init

npm install --save-dev request

Sunday, March 15, 2020

Get Local IP In node.js

'use strict';

var os = require('os');
var ifaces = os.networkInterfaces();

Object.keys(ifaces).forEach(function (ifname) {
  var alias = 0;

  ifaces[ifname].forEach(function (iface) {
    if ('IPv4' !== iface.family || iface.internal !== false) {
      // skip over internal (i.e. 127.0.0.1) and non-ipv4 addresses
      return;
    }

    if (alias >= 1) {
      // this single interface has multiple ipv4 addresses
      console.log(ifname + ':' + alias, iface.address);
    } else {
      // this interface has only one ipv4 adress
      console.log(ifname, iface.address);
    }
    ++alias;
  });
});

// en0 192.168.1.101
// eth0 10.0.0.101