Skip to main content


Showing posts from June, 2020

Installation of ns3 in Ubuntu | Ubuntu 24.04 | ns-3.42

How to read a CSV file in R | Lecture 4

How to read a CSV file in R CSV is called as Comma Separated Value file which can be easily generated using any spreadsheet application like OpenOffice, LibreOffice, MS Office, etc...  We can also create csv files using any text editor as well as given below.  Create a csv file as per the format given below: Name, Age, Science, Maths, Social Kumar,14,57,67,78 Anand,24,98,97,90 Balakumar, 25,35,45,56 To read this file > mydata=read.csv("users.csv"); > mydata        name age science maths social 1     kumar  14      57    67     78 2     Anand  24      98    97     90 3 Balakumar  25      35    45     56 To create a new file, df <- data.frame(name = c("Jon", "Bill", "Maria"),  age = c(23, 41, 32), science=c(20,30,40), maths=c(56,67,78), social=c(98,76,65)) write.csv(df,"anewfile.csv", row.names = FALSE)

Arrays and Matrices in R | Lecture 3

Arrays and Matrices in R Arrays are declared in R using the dim() or array() functions.  For example: > mycarsale.array<-1:30 > mycarsale.array  [1]  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 [17] 17 18 19 20 21 22 23 24 25 26 27 28 29 30 The above command allocates a vector of 1 to 30 to the variable array called mycarsale.array  To make it as a matrix, we can use dim() function as given below  > dim(mycarsale.array)<-c(3,5,2) > mycarsale.array , , 1      [,1] [,2] [,3] [,4] [,5] [1,]    1    4    7   10   13 [2,]    2    5    8   11   14 [3,]    3    6    9   12   15 , , 2      [,1] [,2] [,3] [,4] [,5] [1,]   16   19   22   25   28 [2,]   17   20   23   26   29 [3,]   18   21   24   27   30 In the above output 3 indicates the number of columns, 5 indicate the number of columns and 2 indicates the number of tables. Array in R > mycarsale.array[2,3,1] [1] 8 > mycarsale.array[2,3,2] [1] 23

How to Use R as a Calculator | Lecture 2

R as a Calculator How to use R as a calculator  Open R Studio either through GUI or through Command/Terminal Mode by typing  $] rstudio In the Console Window, type the following  > 2+3 > log(10) >log10(10) > 3^2+4^3 > exp(5) > exp(1) Check the output given in the following Window. To clear the console Window, use the Shortcut key Ctl+L,  in R, pi is recognised as PI = 3.141 >pi  [1] 3.141593 We can use -ve sign also in front of the numbers  > -9 + 1 [1] -8

Basics of R | Lecture 1

Basics of R Its a software and programming language used  for statistical computing and report generation.  Its Free and open source with GPL Licensing  It has a GUI to work upon called as RStudio.  This software can be installed using the following command in  Ubuntu $] sudo apt update $] sudo apt install build-essential autoconf automake libxmu-dev $] sudo apt install r-base rstudio To open the software, you can use either through the GUI or through terminal using  $] rstudio The GUI looks like this  R Studio Features of R Its based on object oriented design R Commands can be included or embedded with other software or applications or programming languages namely C++. Java and other commercial tools. It supports multiple Operating systems like Windows, Linux, Mac OS, etc. Advantages of R Good community to help  Works in a interactive way Plotting and graphs are easy to plot using the libraries. New libraries can be easily generated. Its completely modular and object oriented. See t

Printing Linux Environment using C Program

Linux provides each running program with an environment . The environment is a collection of variable/value pairs. Both environment variable names and their values are character strings. By convention, environment variable names are spelled in all capital letters. You’re probably familiar with several common environment variables already. For instance: USER contains your username. HOME contains the path to your home directory. PATH contains a colon-separated list of directories through which Linux searches for commands you invoke. DISPLAY contains the name and display number of the X Window server on which windows from graphical X Window programs will appear. //Printing the Execution Environment #include <stdio.h> /* The ENVIRON variable contains the environment. */ extern char ** environ; int main () { char ** var; for (var = environ; *var != NULL; ++var) printf (“%s\n”, *var); return 0; }

Printing the Uptime and Idle Time of processor (Linux)

/proc/uptime file contains only two values in seconds, one is the Uptime of the processor (the time upto which the processor was on) and another is the idle time of all the processors (cores). So idle is always higher than the uptime in case of multicore processors. The following C program shows the uptime and idle time in terms of days hours and minutes. This is a very simple program just tells you how to convert a given time in days, hours, minutes and seconds. using C FILE concept, the /proc/uptime file is been read using the “r” mode and values are fetched and then converted into days, hours and seconds. 1: // printing the uptime and idle time 2: #include <stdio.h> 3: /* Summarize a duration of time to standard output. TIME is the 4: amount of time, in seconds, and LABEL is a short descriptive label. */ 5: void print_time ( char * label, long time) 6: { 7: /* Conversion constants. */ 8: const long minute = 60; 9: const long hour =

Square and Sinusoidal Waveform in 8051 Microcontroller

Waveforms in 8051 Microcontroller Square Wave To create a square wave generation using Delay. let us say we want to construct a 1khz square waveform the processor instruction cycle of 8051 is 1.085microseconds so for 1khz (1milli seconds =1/1khz), is 1ms/1.085microseconds = 921.6 (this value is set to the for loop) #include <reg51.h> void delay() { int i=0; for(i=0;i<922;i++) } void main() { P0=0xff; delay(); P0=0x00; delay(); } Sine Wave generation Since sine wave is plotted in a digital device the number of samples determines the smoothness, hence in this case, more the samples, smoother is the waveform. so a lookup table is been created to get the samples. in the following examples, there are totally 36 samples are taken, starting from 0 degrees to 360 degrees with a step of 10 degrees Degrees A = 5 (1+Sin theta) Where 5 is the full scale voltage DAC = 25.6 * A 0 5 128 30 7.5 192 60 9.3 239 90 10 256 etc…like this we need to calculate for 13 samples  with a ste

Terminal Based Youtube downloader for Linux (youtube-dl)

Terminal Based Youtube downloader for Linux (youtube-dl) Downloading videos to local machine is always a challenge as the streaming sites keep on updating their policies in blocking the videos. But there is a tool that is available in the command line (Terminal based) on Linux Operating Systems. That is youtube-dl, this is a python based code and can be executed in linux OS without any hassles. youtube-dl in windows or Mac OS can be achieved by installing python interpreter and try it. for installing in linux, the command is $prompt] sudo yum install youtube-dl (in redhat or centos or fedora) $prompt]  sudo apt-get install youtube-dl (ubuntu or linux mint) See the image for downloading in Fedora 20 Youtube-dl in Fedora 20 In ubuntu, you can update the sudo package before installing the youtube-dl. sudo apt-get update To download videos  $prompt] youtube-dl the above command will download the video in the best possible format. Se

nohup command in Linux/Unix

nohup command in Linux/Unix Often you come across a situation where you try to open a machine remotely using ssh and try to start a server or run a command indefinitely. But once you close the ssh session, your session also terminates and the background process also terminates. So here is a solution. To open ssh remotely, prompt $] ssh username@machinename Ex: ssh root@ Ex: ssh  prompt $] ssh -X username @machinename  Ex. ssh -X root@  (this -X indicates the remote session can be opened in X window (GUI) mode) Assume we need to start a httpd server in the remote machine. we can issue the command like this usage: prompt$] nohup command  if any error or log information may be stored in the nohup.out file. if you want to redirect to a file use the redirected symbol (1>  indicates standard output and 2> indicates standard Error). Specify the filenames for the output. Here is the typical nohup command to start the httpd server. prompt $] nohup  /et

How to display the Product name and System Vendor name in Linux

This post will help you to find out the Product Name System Vendor Name  This will help you to find the suitable device drivers if any. The following is the command to find the System Vendor (in my case it is Hewlett Packard) prompt $] cat /sys/class/dmi/id/sys_vendor Here is the command to find the product name prompt $] cat /sys/class/dmi/id/product_name Printing the System Vendor and Product Name cat is the command to concatenate the files and print it to the standard output Pradeep Kumar TS

time command in Linux

time command in Linux The time command is linux is very much useful if you want to know the time information while running a program or a process. The time command usage is as follows prompt $] time <commandname> Example prompt $] time ls The output will be real 0m0.002s user 0m0.004s sys 0m0.000s If you want to see the detailed system parameters occupied during a program or process, then the command will be  prompt$] TIMEFORMAT="" time -v <commandname> See the screenshot given below The output of the above command is Desktop  Documents  Downloads  examples.desktop  Music Pictures  Public  Templates  Videos Command being timed: "ls" User time (seconds): 0.00 System time (seconds): 0.00 Percent of CPU this job got: 400% Elapsed (wall clock) time (h:mm:ss or m:ss): 0:00.00 Average shared text size (kbytes): 0 Average unshared data size (kbytes): 0 Average stack size (kbytes): 0 Average total size (kbytes): 0 Maximum resident set size (kbytes)

How to open Ports in CentOS using i-tables

CentOS is the most preferred alternative OS for RHEL. Those who cannot afford to purchase the support license of RHEL, they can use CentOS that comes with almost similar to RHEL. This post tells you about the usage of CentOS when web servers are installed and accessed from remote machines. CentOS is a Server based OS and most of the ports are closed by default and you need to open it for access from outside (remote). For ex. if wordpress is installed in CentOS with a hostname   which is very well accessed within the server. When the same is tried from outside like ( , then it will not get accessed. The problem is the closure of ports in CentOS. So you need to open it and save it to iptables, here are the commands that will help you to do that. CentOS Port number : 80 is used here $prompt] ifconfig (find out which interface uses the assigned ip, eth1, eth0, etc) $prompt] iptables --line -vnL (See which line the input has to be

Change InnoDB file format to Barracuda

MySQL and MariaDB uses innoDB for storing the tables in a file format called Antelope.  For large sites, the Antelope format doesn't support more columns which makes the backup option a tedious process. so it will be advised to change the file format to Barracuda. There are various options to do that. Here is a small workaround to change it to barracuda. Open Mysql from the command prompt and execute the commands one by one $] mysql -u root -p The username is root here It will ask for the password: (Input the password here). mysql> select  version(); mysql> show variables like "%innodb_file%"; The output will be like this +--------------------------+----------+ | Variable_name            | Value    | +--------------------------+----------+ | innodb_file_format       | Antelope | | innodb_file_format_check | ON       | | innodb_file_format_max   | Antelope | | innodb_file_per_table    | ON       | +--------------------------+----------+ 4 rows in set (0.00 sec) mys

How to access ext2, ext3 and ext4 filesystems in windows 10

Dual boot with Windows and Linux leads to the access of files in other Operating Systems. Viewing a windows partition on a Linux OS is not a big task. One can simply mount the OS and can see the files of windows within Linux. But accessing Linux EXT2, EXT3 and EXT4 files within Windows can be done only through an external software. EXt2FSD is a software that does this job. you can download the software from this link Once installed, its as easy as possible to “assign a drive letter ” to the partition.  Figure below shows that. Ext2FSD Ext2FSD Its just a simple process to access the linux files within windows. This is really helpful for the machines with UEFI partition. When Linux Boot loader is deleted, this will help to retrieve the files. Any other info, please comment below.

vokoscreen - a screen recorder for Linux

There are many screen recorders available for Windows and Mac. But over these years, getting a screen recorder for Linux is always a challenge.  There have been some screen recorders like recordmydesktop, gtk-recordmydesktop, qt-recordmydeskop. They are not user friendly and not suitable for productive recordings. So, there should be some alternatives to control the video, audio, web camera, etc. Two such tools are available. Simple Screen Recorder (for installing and configuring in Linux, click here) vokoScreen is the other tool that works nicely in Linux Here is the step to do that $] sudo add-apt-repository ppa:vokoscreen-dev/vokoscreen-daily $] sudo apt-get update $] sudo apt-get install vokoscreen But in the latest version of Ubuntu (16.04), it can given directly as $] sudo apt install vokoscreen Once installed, its very easy to use as shown in the following figures vokoscreen Video configuration Vokoscreen Audio Control vokoscreen webcamera control vokoscreen

Installation of NS2 (ns-2.35) in Ubuntu 20.04

Installation of NS2 (ns-2.35) in Ubuntu 20.04 LTS Step 1: Install the basic libraries like      $] sudo apt install build-essential autoconf automake libxmu-dev Step 2: install gcc-4.8 and g++-4.8 open the file using sudo mode $] sudo nano /etc/apt/sources.list Include the following line deb bionic main universe $] sudo apt update $] sudo apt install gcc-4.8 g++-4.8 Step 3:  Unzip the ns2 packages to home folder $] tar zxvf ns-allinone-2.35.tar.gz $] cd ns-allinone-2.35/ns-2.35 Modify the following make files. ~ns-2.35/ Change @CC@ to gcc-4.8 change @CXX@ to g++-4.8 ~nam-1.15/ ~xgraph-12.2/ ~otcl-1.14/ Change in all places  @CC@ to gcc-4.8 @CPP@ or @CXX@ to g++-4.8 open the file: ~ns-2.35/linkstate/ls.h Change at the Line no 137  void eraseAll() { erase(baseMap::begin(), baseMap::end()); } to This void eraseAll() { this->erase(baseMap::begin(), baseMap::end()); } All changes made Step 4: Open a new termi