Tuesday, January 8, 2019

Cheat sheet for echo


The syntax for echo is:
echo [option(s)] [string(s)]
1. Input a line of text and display on standard output
$ echo Tecmint is a community of Linux Nerds 
Outputs the following text:
Tecmint is a community of Linux Nerds 

Cheat sheet for cat command


Display content of the file
cat /etc/passwd

View contents of the multiple files in the terminal
cat sample1 sample2
First sample
This is the second sample;

Create file with cat ctrl+d to exit
cat >testcat
Testing file with cat command


cheat sheet for ls



1. List Files using ls with no option
ls with no option list files and directories in bare format where we won’t be able to view details like file types, size, modified date and time, permission and links etc.


[vn04nxr@client-236651385-1-270480917 ~]$ ls
affiliate_spend_viq_08-13-2018_to_08-23-2018.tsv  employee    first_file  
2 List Files With option –l 
Here, ls -l (-l is character not one) shows file or directory, size, modified date and time, file or folder name and owner of file and its permission.
[vn04nxr@client-236651385-1-270480917 ~]$ ls -l
total 64
-rw-rw-r-- 1 vn04nxr vn04nxr    22 Aug 23 19:11 affiliate_spend_viq_08-13-2018_to_08-23-2018.tsv
-rw-rw-r-- 1 vn04nxr vn04nxr 14510 Sep  3 14:58 cat_more
-rw-rw-r-- 1 vn04nxr vn04nxr    35 Aug 23 21:46 employee

SQL question challenge (Employee Dept)

Link to Github

These are the list of tables which includes employees, projects and department table. It also shows the relationship between these tables
employees                             projects
  +---------------+---------+           +---------------+---------+
  | id            | int     |<----+  +->| id            | int     |
  | first_name    | varchar |     |  |  | title         | varchar |
  | last_name     | varchar |     |  |  | start_date    | date    |
  | salary        | int     |     |  |  | end_date      | date    |
  | department_id | int     |--+  |  |  | budget        | int     |
  +---------------+---------+  |  |  |  +---------------+---------+
          |  |  |
  departments                  |  |  |  employees_projects
  +---------------+---------+  |  |  |  +---------------+---------+
  | id            | int     |<-+  |  +--| project_id    | int     |
  | name          | varchar |     +-----| employee_id   | int     |
  +---------------+---------+           +---------------+---------+

1) SELECT EMPLOYEES FROM
     DEPARTMENT WHERE SALARY IS GREATER THAN 40K

select concat(employees.first_name,' ',employees.last_name) as employee_name,names 
  from employees,departments 
  where employees.department_id=departments.id 
  group by employees.id,employees.salary 
  having employees.salary > 40000;

SQL question challenge (Employee Boss)



DDL Scripts :

Employee table
 create table employee(employee_id integer,department_id integer,boss_id 
         integer,name varchar(50),salary integer);
 
 insert into employee values(1,1,2,'John Smith',20000);
 insert into employee values(2,5,4,'Ava Muffinson',10000);
 insert into employee values(3,2,5,'Cailin Ninson',30000);
 insert into employee values(4,2,5,'Mike Peterson',20000);
 insert into employee values(5,2,1,'Ian Peterson',80000);
 insert into employee values(6,3,null,'John Mills',50000);

 +----+------------+-----------+--------+---------------+
 | id | first_name | last_name | salary | department_id |
 +----+------------+-----------+--------+---------------+
 |  1 | John       | Smith     |  20000 |             1 |
 |  2 | Ava        | Muffinson |  10000 |             5 |
 |  3 | Cailin     | Ninson    |  30000 |             2 |
 |  4 | Mike       | Peterson  |  20000 |             2 |
 |  5 | Ian        | Peterson  |  80000 |             2 |
 |  6 | John       | Mills     |  50000 |             3 |
 +----+------------+-----------+--------+---------------+
 


Friday, December 28, 2018

Tensorflow


  • Interface for expressing machine learning algorithms
  • Implementation for executing such algorithms
  • Framework for creating ensemble algorithms for today's most challenging problems

Friday, October 26, 2018

System design Twitter


Overview

Designing the architecture of Twitter and similar social networks is a popular engineering interview question asked at companies like LinkedIn, Microsoft, Google, Snapchat, NVidia and others.No solution is right or wrong and might have trade-offs.Let's try our best to take different features and design a high level solution to the problem.

Approach

When we design a  system. we first need to list the features what we need.
Lets build the system feature by feature and later test for performance and improve on it.

Let us consider 3 main features of twitter system

1.Tweeting
     This would have all the tweets.
2.Timeline
    -User
       List of all the tweets within that timeline.Content of this would be less as this would be the list of
       tweets that the user has done at a particular timeline
    -Home
       List of all the tweets of the users whom we are following. Each users might have thousands of             tweets at a particular timeline.
3.Following
      These are the list of the users that we are following. This would not dynamically change and                would have less load on the system