Monday, October 15, 2018

JenkinsCertification-Class 1(Jenkins Installation)

* https://console.cloud.google.com/networking/firewalls/details/default-allow-http?q=search&project=probable-cove-183916

* sudo rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io.key

*sudo wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat-stable/jenkins.repo

* sudo yum install jenkins

*sudo yum install wget

*Sudo systemctl start jenkins

sudo visudo

sudo vi /etc/ssh/sshd_config

sudo service sshd start

sudo service sshd restart


1 systemctl enable jenkins 2 systemctl start jenkins 3 systemctl status jenkins 4 java -version 5 yum install java 6 java -version 7 systemctl start jenkins 8 ps -ef jenkins 9 ps -ef | grep jenkins 10 cd /usr/lib/jenkins/ 11 ls -ltr 12 cd .. 13 cd usr 14 cd /usr 15 ps -ef | grep jenkins 16 cd /etc/default 17 ls -ltr 18 less instance_configs.cfg 19 cd /etc 20 ls -ltr 21 cd sysconfig 22 ls -ltr 23 less jenkins 24 pwd 25 pwd 26 ls -ltr 27 tail -f jenkins.log

Friday, October 5, 2018

Introvert or Extrovert

When you laugh a little loud, you are ill-mannered and when you laugh a little less, you are shy. Our social structures have made it a little complex for our Generation-Y aka millennial to grasp and apply these norms.Especially in context of Nepal, it is even more difficult to grow as a child; Because not only your parents, but also your neighbors, relatives and even friend's parents are watchdogs of your mannerism.Besides, there is this whole  decade long phenomenon and worshiper of discipline called school. The sad part, no child can escape it.I mean who as a scholar haven't heard this, " Does your parents teach this?" at school and "This is what you learn at school ?" at home .I believe every single of us.First of all please make sure who teaches what. This will make the life of a child more easier.Here, i am not trying to put blame on either of them. I couldn't have been grown up better and neither could have been educated better.So, both my parents and school have grabbed A+ on their transcripts.If allowed, i would give some partial credit to my neighbors and relatives as well.However, my problem is with the overall system and culture.

I cannot draw a conclusion representing my age group but i am trying to put my own perspective and experience.



Tuesday, September 18, 2018

4. Median of Two Sorted Arrays(Leetcode) Accepted solution

class Solution:
def findMedianSortedArrays(self,l1,l2):
sorted_new_list = l1 + l2
sorted_new_list.sort()
val = len(sorted_new_list)
if (val % 2 != 0):
return float(sorted_new_list[val //2])
else:
num1 = sorted_new_list[val//2 -1]
num2 = sorted_new_list [val//2]
return (num1 +num2 )/2
a = Solution()
print(a.findMedianSortedArrays([1,2,3,4,5] ,[6,7,8,9]))

Monday, September 17, 2018

leetcode problem2 (brute force) not all test cases passed

class Solution:
  def lengthOfLongestSubstring(self, s):
    if len(s) == 0:
      return 1
    else:
        self.l = ''
        self.count = 0
        self.mlist = []
        length =0
        for i in s:
            if i not in self.l:
                self.l += i
                self.count +=1
            elif i in self.l:
                self.mlist.append(self.count)
                self.count =0
                self.l = ''
                self.l +=i
                self.count +=1
            #return max(self.mlist)
            for i in self.mlist:
                if i > length:
                    length = i
            return length

a = Solution()
print(a.lengthOfLongestSubstring(""))

Tuesday, September 11, 2018

Leetcode problem1 brute force

class Solution:
def twoSum(self,nums, target):
thisdict = {}
#new_list = []
for i in range(0,len(nums)):
thisdict[nums[i]] = i
for i in thisdict:
rem = target - i
if rem in thisdict and rem != i:
return[thisdict[i],thisdict[rem] ]
a = Solution()
print(a.twoSum([3,3],6)) # It doesn't satisfy this use case

Data science class statisctisc

''def mean(x):
sum = 0
avg = 0

try:
for i in x:
sum+= i
avg = sum /len(x)
print(avg)
except ZeroDivisionError:
print("Division by zero error")
mean([])'''

import math
def mean(x):
return sum(x)/len(x) if len(x) is not 0 else 0
print(mean([1,2,3,5]))

def de_mean(x_list):
return abs(x_list[i]-mean(x_list[i]) for i in range(len(x_list)
print(de_mean([1,2,3,4,5]))







Tuesday, September 4, 2018

Python Data visualization, (Applied Data Science Class)

#sample code for plotting a bar diagram

import matplotlib.pyplot as plt
movies = ["Annie Hall", "Ben-Hur", "Casablanca", "Gandhi", "West Side Story"]
num_oscars = [5,11,3, 8, 10]
xs = [i + 0.1 for i, _ in enumerate(movies)]
plt.bar(xs, num_oscars)
plt.ylabel("# of Academy Awards")
plt.title("My favorite movies")
plt.xticks([i + 0.5 for i, _ in enumerate(movies)], movies)
plt.show()




#Create a Histogram of 1000 random grades

from collections import Counter
import matplotlin
matplotlib.use("Agg")
import matplotlib
grades =[]
#create a list of 1000 random grades between 0 and 100
decile = lamda grade:grade // 10 *10
histogram = COunter(decile(grade) for grade in grades)
plt.bar([x-4 for x n histogram.keys()], histogram.values(), 8)
plt.axis([-5, 105, 0, 5])
plt.xticks([10 * i for i in range(11)])
plt.xlabel("Decile")
plt.ylabel("# of Students")
plt.title("Distribution of the grades")
plt.savefig("histogram.png")

Saturday, August 4, 2018

Simply Me


Life, the word itself is wordplay, a really interesting one.At once your mother says "Why don't you ever think about your life." and on the same day your friend mocks you " Why do you think a lot about your life."Basically, it all resides between that thinking too less and too much. Doesn't it seem so simple. Alas,we all wish it was ! Don't we ?

Tuesday, July 31, 2018

A Milestone In A Long Run; Cricket for me and for my Nation


Mark the date August 1 2018 with golden letters because this is the date Nepal played its first ever one day International cricket match. Every Nepalese cricket fans had waited for this day for a long time and finally it knocked on the door. Without having to wait much longer, the victory came after two days on second O.D.I. and  boy, what a nerve-cracking win that was, with just a single run. It could not have been better scripted and who else deserved more than our very own captain, Mr. Paras Khadka to lead it. We welcomed both of these historic days with pride and jubilation..This was the first step towards a big tomorrow to get established as the formidable cricketing giant. In this world of power, possession and identity, Nepal has always been isolated and suffered identity crisis for decades. Kudos to some of  the blessings nature has put on us, from time to time we get to quote ourselves as "land of Everest" or "a small yet beautiful country on lap of Himalayas in south-east Asia where Buddha was born" if not merely Federal Democratic Republic of Nepal.

Perhaps this is the reason we get an inch or half extra emotional and react instantly even in slightest of matter whenever country is  in stake. Fair enough, a child should defend his old and ill mother whenever neighbors  demean her.
However, hopefully this particular day on calendar will be a milestone for both cricket's and country's future if they both really behold. At least our cricketers are roaring so; if not now Never !!
PC:http://assets-cdn.ekantipur.com/images/the-kathmandu-post/miscellaneous/Nepal-Cricket-team-21022017063213-1000x0.jpg
ImageSource:http://assets-cdn.ekantipur.com/images/the-kathmandu-post/miscellaneous/Nepal-Cricket-team-21022017063213-1000x0.jpg
No copyright infringement intended
Personally, cricket has never been just one more sport to relish.It is a mere reflection and reminiscence of my growing up.If someone asks my mother what one thing about me that made her life difficult those days, she would say my cricket bat and ball.Believe me i have cleaned countless dishes and washed plenty of clothes as the punishment for being home late; Used to leave at early morning with that empty belly and return back at late dusk with the same empty belly but with heart full of joy victory(well certainly, not always!). Every Saturday, those promises to return by lunch time were never been kept  unless she knows where i am playing and decides to do one or two batting by herself. It seems funny now but things turned out pretty serious when my teachers once had to come on field to meet on their home-visit trip just a day before some terminal examination from school.Oh Good ol' days !! Innit?

Even today, when we old mates from the school and hometown catch up, every memories we talk about includes cricket. My first outing, my first fight, my first cigarette and my first girlfriend, there is nothing where cricket does not get involved and so it does to all of my friends growing up  along with me.So when the stake is on cricket, it is not only passion that rises up but also endless emotions.
ImageSource:https://www.thestar.com.my/travel/asia/2014/09/13/the-ancient-city-of-bhaktapur-living-history-in-nepal/
No Copyright Infringement Intended
I was never a child prodigy and destined for the sport( I guess i should accept it by now(wink)) . I was just the passionate one if not the gifted one. But we always had a formidable  team.We were winners,weren't we? Still today, whenever i step into the field, i absolutely hate to lose and play with all my heart out.It gives me that adrenaline rush that no other object in the world will ever reach close to.In particular, it all dates back to the faint memory of 2003 ICC World Cup and since then it has been a beautiful journey together growing up as a cricket fan.It is why when these 11 players play on red and blue jersey on the field, i play along with them under these four walls.Congratulations team for the first victory.This is just the beginning. A beginning of a new journey and good luck guys for the exciting journey ahead. Make us Proud . Jay Chandra Surya !!

Monday, July 9, 2018

Python Scripting -BMI(Body Mass Index)

#!/usr/bin/env python3.7 2 3 #BMI = (weight in kg / height in meters sqaured) 4 #Imperial version: BMI * 703 5 6 def gather_info(): 7 height = float (input("What is your height? (inches or meters)")) 8 weight = float(input("What is your weight? (pounds or kilograms)")) 9 system = input("Are your measurements in metric or imperial units?").low er().strip() 10 return (height, weight, system) 11 12 def calculate_bmi(weight, height, system = 'metric'): 13 ''' 14 Return the Body Mass Index (BMI) for the 15 given weight, height and measurement system. 16 ''' 17 if system == 'metric': 18 bmi = (weight / (height ** 2)) 19 else: 20 bmi = 703 * (weight / (height **2)) 21 return bmi 22 23 while True: 24 height, weight , system = gather_info() 25 if system.startswith('i'): 26 bmi = calculate_bmi(weight, system=system,height= height) 27 print(f"Your BMI is {bmi}") 28 break 29 elif system.startswith('m'): 30 bmi = calculate_bmi(weight, height) 31 print(f"Your BMI is {bmi}") 32 break

Sunday, July 8, 2018

Docker commands

sudo docker tag hello-world prabhu4029/imagename



DevOps-Docker

mkdir dockerinstall 287 cd dockerinstall 288 sudo yum install docker 289 docker version 290 maven version 291 mvn version 292 sudo nohup docker daemon -H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock & 293 sudo docker ps 294 sudo nohup docker daemon -H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock & 295 sudo docker ps 296 sudo docker pull hello-world 297 sudo docker ps 298 ps -ef | grep docker 299 sudo docker pull jenkins 300 sudo docker images -a 301 sudo docker run hello-world 302 cd /usr/libexec/docker/ 303 sudo ln -s docker-runc-current docker-runc 304 sudo docker run hello-world 305 ln -s docker-runc-current docker-runc 306 sudo ln -s docker-runc-current docker-runc 307 sudo docker run hello-world 308 sudo ln -s /usr/libexec/docker/docker-runc-current /usr/bin/docker-runc 309 sudo docker run hello-world 310 sudo docker images 311 sudo docker pull jenkins:alphine 312 sudo docker pull jenkins:alpine 313 sudo docker images 314 sudo docker ps -a 315 shutdown 316 sudo shutdown 318 systemctl status jenkins 319 ls -l 320 mvn -version 321 cd maveninstall 322 echo $PATH 323 echo M2_HOME=/home/kafleashok1/maveninstall 324 export M2_HOME=/home/kafleashok1/maveninstall 325 export PATH-${M2_HOME}/maven/bin:${PATH} 326 export M2_HOME=/home/kafleashok1/maveninstall 327 echo $PATH 328 ps -ef | grep docker 329 sudo nohup docker daemon -H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock & 330 ps -ef | grep docker 331 cd .. 332 ls -ltr 333 git init 334 cd maveninstall 335 ls -l 336 git clone git clone https://github.com/Prabhu4tx/jenkins-pipeline 337 git clone https://github.com/Prabhu4tx/jenkins-pipeline 338 ls -ltr 339 cd .. 340 docker login 341 sudo docker login 342 sudo docker pull ashokkafle96/hello-noble 343 docker images -a 344 sudo docker images -a 345 sudo docker logout 346 sudo docker images 347 sudo docker tag --help 348 sudo docker tag hello-noble docker.io/hello-world 349 sudo docker create image hello-noble 350 sudo docker tag hello-noble ashokkafle96/hello-noble 351 sudo docker tag hello-world ashokkafle96/hello-noble 352 sudo docker images

Wednesday, June 27, 2018

Installing Python3 on Centos7

$ sudo su -
[root] $ yum groupinstall -y "development tools"
[root] $ yum install -y \
  libffi-devel \
  zlib-devel \
  bzip2-devel \
  openssl-devel \
  ncurses-devel \
  sqlite-devel \
  readline-devel \
  tk-devel \
  gdbm-devel \
  db4-devel \
  libpcap-devel \
  xz-devel \
  expat-devel

[root ] $ cd /usr/src
[root ] $ wget http://python.org/ftp/python/3.6.4/Python-3.6.4.tar.xz
[root ] $ tar xf Python-3.6.4.tar.xz
[root ] $ cd Python-3.6.4
[root ] $ ./configure --enable-optimizations
[root ] $ make altinstall
[root ] $ exit
List of commands: 

1  bash script.sh    2  ls -l    3  yum update    4  yum groupinstall -y "development tools"    5  yum install -y lsof wget vim-enhanced words which    6  exit    7  yum groupinstall -y "development tools"    8  yum yum install -y libffi-devel    9  yum  install -y libffi-devel zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel tk-devel gdbm-devel libpcap-devel xz-devel expat-devel    10  cd /usr/src/   11  ls -l   12  wget https://www.python.org/ftp/python/3.7.0/Python-3.7.0.tgz   13  ls   14  tar xf Python-3.7.0.tgz    15  cd Python-3.7.0   16  ./configure --enable-optimizations   17  make altinstall   18  exit   19  history

Python 3 Scripting for System Administrators


Setting Up a Cloud Server Development Environment:


git config --global user.name "Ashok Kafle" 14 git config --global user.email "ashokkafle96@gmail.com" 15 curl https://raw.githubusercontent.com/linuxacademy/content-python3-sysadmin/master/helpers/bashrc -o ~/.bashrc 16 exec $SHELL 17 curl https://raw.githubusercontent.com/linuxacademy/content-python3-sysadmin/master/helpers/vimrc -o ~/.vimrc 18 vim ~/.vimrc

Saturday, June 16, 2018

Devops --installing apache maven on CENTOS7

136 java -version 137 sudo -d 138 sudo -s 139 ls 140 cd 141 ls-ltr 142 ls -ltr 143 mkdir maveninstall 144 cd maveninstall/ 145 pwd 146 wget httpcd ..//www-eu.apache.org/dist/maven/maven-3/3.5.3/binaries/apache-maven-3.5.3-bin.tar.gz 147 ls -ltr 148 sudo tar xzf apache-maven-3.5.3-bin.tar.gz 149 sudo ln -s apache-maven-3.5.3 maven 150 sudo vi /etc/profile.d/maven.sh 151 cd /etc/ 152 ls -ltr 153 cd /profile 154 cd /profile.d 155 cd profile.d 156 ls 157 vi maven.sh 158 ls -ltr 159 pwd 160 cd .. 161 cd /etc/profile.d/ 162 ls -ltr 163 sudo maven.sh 164 sudo vi maven.sh 165 ls -ltr 166 cd .. 167 sudo chmod 755 /etc/profile.d/maven.sh 168 cd /etc/profile.d/maven.sh 169 170 pwd 171 cd 172 cd maveninstall/ 173 ls -ltr 174 cd local 175 cd /local 176 ls -ltr 177 cd /usr/ 178 ls 179 cd .. 180 pwd 181 cd home 182 ls 183 cd ashokkafle96/ 184 ls 185 pwd 186 cd maveninstall/ 187 pwd 188 export M2_HOME=/home/ashokkafle96/maveninstall 189 cd maven 190 ls -ltr 191 export PATH=${M2_HOME}/maven/bin:${PATH} 192 echo $M2_HOME 193 history[ashokkafle96@nobletecg ~]$ cd /etc/profile.d