Monday, June 12, 2017

Java Practice

class FreshJuice {
   enum FreshJuiceSize{ SMALL, MEDIUM, LARGE }
   FreshJuiceSize size;
}

public class FreshJuiceTest {

   public static void main(String args[]) {
      FreshJuice juice = new FreshJuice();
      juice.size = FreshJuice.FreshJuiceSize.MEDIUM ;
      System.out.println("Size: " + juice.size);
   }
}


/*class FreshJuice {
    enum FreshJuiceSize{SMALL, MEDIUM, LARGE }
    FreshJuiceSize size;
}

public class FreshJuiceTest{
 
    public static void main(String args[]){
        FreshJuice juice = new FreshJuice();
        juice.size = FreshJuice.FreshJuiceSize.MEDIUM;
        System.out.println("Size: " + juice.size);
    }
}
*/
   

Friday, January 27, 2017

Leetcode python reverse digits of an integer( Has to be corrected though) assignments programming team

def revintegers(int num): #-321
 
    while num !=0 {
        if num > 0{
            mod = num % 10;  #-1
            num = num / 10; #
            revorder = revorder * 10 + mod;
            }
        elif num < 0 {
            num = -1 * num;
            mod = num % 10;
            num = num / 10;
            revorder = (revorder * 10 + mod) * -1;
            }
    return revorder;
        }
 
revintegers(321)

Tuesday, January 24, 2017

Java control flow

public class Conditionals {
public static void main(String[] args) {


if (1 < 4 && 0 > 5) {

System.out.println("You ordered a cup of hot, mint tea.");

} else if (21 <= 19 || 17 >= 28) {

System.out.println("You ordered freshly squeezed orange juice!");

} else if ( !(true == true) ) {

System.out.println("You ordered hot cocoa!");

} else {

System.out.println("You ordered a cup of Java!");

}

char answerChoice = 'C';

switch (answerChoice) {

case 'A': System.out.println("You answered: " + answerChoice + ". Please try again.");
break;

case 'B': System.out.println("You answered: " + answerChoice + ". Please try again.");
break;

case 'C': System.out.println("You answered: " + answerChoice + ". That is correct!");
break;

case 'D': System.out.println("You answered: " + answerChoice + ". Please try again.");
break;

default:
System.out.println("Please select a valid answer choice.");

}


}
}

JAVA (general) my first programming

String data type:

public class YourName {
public static void main(String[] args) {

System.out.println("Ashok");

}
}



Integer Data type:

public class DataTypes {
public static void main(String[] args) {

System.out.println(2);

}
}

Boolean data type:

public class DataTypesB {
public static void main(String[] args) {

System.out.println(true);

}
}

Make Bootbale USB

How to make Bootable USB from any windows CD or Copy an Existing Bootbale USB Without Downloading Software.

1. Open a cmd.exe command prompt as an an administrator. (Right click and run as administrator) 2. type in "diskpart" 3. type in "list disk" 4. type in "select disk _" where _ is the number corresponding to your usb disk 5. type in "clean" 6. type in "create partition primary" 7. type in select partition 1 8. type in "active" 9. type in "format fs=ntfs" 10. type in "assign" 11. type in exit to close the window 12. Change to the windows CD drive letter or existing windows bootable usb drive letter. "d:" 13. At the root of your drive letter, you need to change directories to the boot folder. "cd boot" 14. type in "bootsect.exe/nt60 f:" Where f: is the drive letter corresponding to the drive that you WANT to be putting the windows installation CD ON. 15. After everything has been done, just highlight all of the files/folders at the root of the CD or existing bootable usb, and copy them over to the new drive. It is now a bootable windows USB!

Monday, November 7, 2016

python class day1

class Employee:

def __init__(self,first,last,pay):
self.first = first
self.last = last
self.pay = pay
self.email = first + '.' + last + "@company.com"

def fullname(self):
return('{} {}'.format(self.first, self.last))
emp_1 = Employee('Corey', 'Schafer' , 50000)
emp_2 = Employee('Test', 'User', 60000)


'''print(emp_1)
print(emp_2)

emp_1.first = "corey"
emp_1.email = "Test.User@gmail.com"

emp_2.first = "anderson"
emp_2.email = "nderson@gmail.com"'''

print(emp_1.email)
print(emp_2.email)
#print(emp_1.fullname())
print(Employee.fullname(emp_1))


output:
Corey.Schafer@company.com
Test.User@company.com
Corey Schafer
=> None   

Tuesday, February 9, 2016

RED HAT 7 Linux networking

Managing RED HAT ENTERPRISE LINUX NETWORKING

displaying ip addresses:
[ashok@localhost ~]$ ip addr show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: eno16777736: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 00:0c:29:fd:cb:90 brd ff:ff:ff:ff:ff:ff
    inet 192.168.1.101/24 brd 192.168.1.255 scope global dynamic eno16777736
       valid_lft 85235sec preferred_lft 85235sec
    inet6 fd84:6375:8789:0:20c:29ff:fefd:cb90/64 scope global noprefixroute dynamic
       valid_lft 6865sec preferred_lft 3265sec
    inet6 fe80::20c:29ff:fefd:cb90/64 scope link
       valid_lft forever preferred_lft forever
3: virbr0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN
    link/ether 00:00:00:00:00:00 brd ff:ff:ff:ff:ff:ff
    inet 192.168.122.1/24 brd 192.168.122.255 scope global virbr0
       valid_lft forever preferred_lft forever
4: virbr0-nic: <BROADCAST,MULTICAST> mtu 1500 qdisc pfifo_fast state DOWN qlen 500
    link/ether 52:54:00:05:c1:9d brd ff:ff:ff:ff:ff:ff

IP command may also be used to show stastics about network performances:

[ashok@localhost ~]$ ip -s link show  eno16777736

2: eno16777736: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT qlen 1000
    link/ether 00:0c:29:fd:cb:90 brd ff:ff:ff:ff:ff:ff
    RX: bytes  packets  errors  dropped overrun mcast
    247828     3430     0       0       0       0

 TO show ip routing information:
[ashok@localhost ~]$ ip route
default via 192.168.1.1 dev eno16777736  proto static  metric 100
192.168.1.0/24 dev eno16777736  proto kernel  scope link  src 192.168.1.101  metric 100
192.168.122.0/24 dev virbr0  proto kernel  scope link  src 192.168.122.1

To test connectivity::
[ashok@localhost ~]$ ping -c1 192.168.1.101
PING 192.168.1.101 (192.168.1.101) 56(84) bytes of data.
64 bytes from 192.168.1.101: icmp_seq=1 ttl=64 time=0.192 ms

--- 192.168.1.101 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.192/0.192/0.192/0.000 ms

[ashok@localhost ~]$ ss -ta
State      Recv-Q Send-Q Local Address:Port                 Peer Address:Port
LISTEN     0      5      192.168.122.1:domain                *:*        
LISTEN     0      128     *:ssh                   *:*
LISTEN     0      128    127.0.0.1:ipp                   *:*            
LISTEN     0      100    127.0.0.1:smtp                  *:*            
ESTAB      0      64     192.168.1.101:ssh                  192.168.1.140:57710
LISTEN     0      128    :::ssh                  :::*
LISTEN     0      128       ::1:ipp                  :::*                
LISTEN     0      100       ::1:smtp                 :::*                



    TX: bytes  packets  errors  dropped carrier collsns
    51345      479      0       0       0       0



Configuring network information with NMCLI:

to list all connections,add and list only active connections and many more:



TO list all connection:
[ashok@localhost ~]$ nmcli con show
NAME                UUID                                  TYPE            DEVICE
virbr0              7ec8faaf-3b7a-4a92-9333-0a405e875b17  bridge          virbr0
Wired connection 1  7a07cec3-1711-4715-8d0f-bc543a511ecc  802-3-ethernet  --
eno16777736         d844d1c9-dac7-40dc-9cfe-ffc71461203e  802-3-ethernet  eno16777736


To list all active connections::

[ashok@localhost ~]$ nmcli con show --active
NAME         UUID                                  TYPE            DEVICE
virbr0       7ec8faaf-3b7a-4a92-9333-0a405e875b17  bridge          virbr0
eno16777736  d844d1c9-dac7-40dc-9cfe-ffc71461203e  802-3-ethernet  eno16777736
[ashok@localhost ~]$



to view the details of specific connections:
[ashok@localhost ~]$ nmcli con show eno16777736
connection.id:                          eno16777736
connection.uuid:                        d844d1c9-dac7-40dc-9cfe-ffc71461203e
connection.interface-name:              eno16777736
connection.type:                        802-3-ethernet
connection.autoconnect:                 yes
connection.autoconnect-priority:        0
connection.timestamp:                   1454379297
connection.read-only:                   no
connection.permissions:
connection.zone:                        --
connection.master:                      --
connection.slave-type:                  --
connection.autoconnect-slaves:          -1 (default)
connection.secondaries:
connection.gateway-ping-timeout:        0
connection.metered:                     unknown
802-3-ethernet.port:                    --
802-3-ethernet.speed:                   0
802-3-ethernet.duplex:                  --
802-3-ethernet.auto-negotiate:          yes
802-3-ethernet.mac-address:             --
802-3-ethernet.cloned-mac-address:      --
802-3-ethernet.mac-address-blacklist:
802-3-ethernet.mtu:                     auto
802-3-ethernet.s390-subchannels:
802-3-ethernet.s390-nettype:            --
802-3-ethernet.s390-options:
802-3-ethernet.wake-on-lan:             1 (default)
802-3-ethernet.wake-on-lan-password:    --
ipv4.method:                            auto
ipv4.dns:
ipv4.dns-search:
ipv4.addresses:
ipv4.gateway:                           --
ipv4.routes:
ipv4.route-metric:                      -1
ipv4.ignore-auto-routes:                no
ipv4.ignore-auto-dns:                   no
ipv4.dhcp-client-id:                    --
ipv4.dhcp-send-hostname:                yes
ipv4.dhcp-hostname:                     --
ipv4.never-default:                     no
ipv4.may-fail:                          yes
ipv6.method:                            auto
ipv6.dns:
ipv6.dns-search:
ipv6.addresses:
ipv6.gateway:                           --
ipv6.routes:
ipv6.route-metric:                      -1
ipv6.ignore-auto-routes:                no
ipv6.ignore-auto-dns:                   no
ipv6.never-default:                     no
ipv6.may-fail:                          yes
ipv6.ip6-privacy:                       -1 (unknown)
ipv6.dhcp-send-hostname:                yes
ipv6.dhcp-hostname:                     --
GENERAL.NAME:                           eno16777736
GENERAL.UUID:                           d844d1c9-dac7-40dc-9cfe-ffc71461203e
GENERAL.DEVICES:                        eno16777736
GENERAL.STATE:                          activated
GENERAL.DEFAULT:                        yes
GENERAL.DEFAULT6:                       no
GENERAL.VPN:                            no
GENERAL.ZONE:                           --
GENERAL.DBUS-PATH:                      /org/freedesktop/NetworkManager/ActiveConnection/0
GENERAL.CON-PATH:                       /org/freedesktop/NetworkManager/Settings/0
GENERAL.SPEC-OBJECT:                    /
GENERAL.MASTER-PATH:                    --
IP4.ADDRESS[1]:                         192.168.1.101/24
IP4.GATEWAY:                            192.168.1.1
IP4.DNS[1]:                             208.59.247.45
IP4.DNS[2]:                             208.59.247.46
IP4.DNS[3]:                             192.168.1.1
IP4.DOMAIN[1]:                          cable.rcn.com
DHCP4.OPTION[1]:                        requested_domain_search = 1
DHCP4.OPTION[2]:                        requested_nis_domain = 1
DHCP4.OPTION[3]:                        requested_time_offset = 1
DHCP4.OPTION[4]:                        requested_broadcast_address = 1
DHCP4.OPTION[5]:                        requested_rfc3442_classless_static_routes = 1
DHCP4.OPTION[6]:                        requested_classless_static_routes = 1
DHCP4.OPTION[7]:                        requested_domain_name = 1
DHCP4.OPTION[8]:                        expiry = 1454463610
DHCP4.OPTION[9]:                        domain_name = cable.rcn.com
DHCP4.OPTION[10]:                       next_server = 0.0.0.0
DHCP4.OPTION[11]:                       broadcast_address = 192.168.1.255
DHCP4.OPTION[12]:                       dhcp_message_type = 5
DHCP4.OPTION[13]:                       requested_subnet_mask = 1
DHCP4.OPTION[14]:                       dhcp_lease_time = 86400
DHCP4.OPTION[15]:                       routers = 192.168.1.1
DHCP4.OPTION[16]:                       ip_address = 192.168.1.101
DHCP4.OPTION[17]:                       requested_static_routes = 1
DHCP4.OPTION[18]:                       requested_interface_mtu = 1

 TO view the status of device and its details:
[ashok@localhost ~]$ nmcli dev status
DEVICE       TYPE      STATE         CONNECTION
virbr0       bridge    connected     virbr0
eno16777736  ethernet  connected     eno16777736
virbr0-nic   ethernet  disconnected  --
lo           loopback  unmanaged     --

COnfiguring host name and name resolution ::

[root@localhost ~]# hostname
localhost.localdomain


[root@localhost ~]# hostnamectl set-hostname ashok.expanor.com
[root@localhost ~]# hostname

To check the status
[root@localhost ~]# hostnamectl status
   Static hostname: ashok.expanor.com
         Icon name: computer-vm
           Chassis: vm
        Machine ID: 544bc3a26e5840ce9f5be98967078dd4
           Boot ID: 817341ebd2e647b48d6e10eed6183368
    Virtualization: vmware
  Operating System: CentOS Linux 7 (Core)
       CPE OS Name: cpe:/o:centos:centos:7
            Kernel: Linux 3.10.0-327.el7.x86_64
      Architecture: x86-64


[root@localhost ~]# cat /etc/hostname
ashok.expanor.com

 The host HOSTNAME used to test DNS server connectivity..

root@localhost ~]# host ashok.expanor.com
ashok.expanor.com has2.168.11.4i3 address 66.96.147.120
ashok.expanor.com mail is handled by 30 mx.expanor.com.


getent hosts hostname command is used to test host name resolution with the /etc/hosts..

root@localhost ~]# getent hosts ashok.expanor.com
66.96.147.120   ashok.expanor.com




practice exercises::
IPADRR=10.0.2.1 /etc/sysconfig/network-scripts/ifcfg-lab1
[root@ashok1 ~]# vi /etc/sysconfig/network-scripts/ifcfg-lab1
[root@ashok1 ~]# echo "PREFIX=24 /etc/sysconfig/network-scripts/ifcfg-lab1
> ^C
[root@ashok1 ~]# vi /etc/sysconfig/network-scripts/ifcfg-lab1
[root@ashok1 ~]# echo "IPADDR=10.0.2.1" >> /etc/sysconfig/network-scripts/ifcfg-lab1
[root@ashok1 ~]# vi /etc/sysconfig/network-scripts/ifcfg-lab1
[root@ashok1 ~]# echo "10.0.2.1 private " >> /etc/hosts
[root@ashok1 ~]# vi  /etc/hosts
[root@ashok1 ~]# hostname