Sunday, June 5, 2016

Commands I often Use at work while working and at home as DevOps engineer and hobbist Developer

Tar
It is used to zip files in a format that can be extracted in proper format and tastes:

tar -zcvf UlyssesOs.tar.gz UlyssesOs/




##################################################
#   My Programming Languages                                                                           #
#                                                                                                                             #
# ################################################

* Mental note, I like to be seen as anonymous at coffee shops and public places so, I use the name aguy as a computer name...  LOL

* My favorite language is Ruby when it comes to coding

JAVA:

Unlike Ruby, Java needs a lot more code to run

Hello world is written like this (4 lines of code, SMH) Ruby does this in 1:




To give a simple output of this:
Notice you have to compile first before running because JAVA is a compiled language and not an interpreted, meaning running command line tricks are out of the question and it takes more time to market/scale.





Java's multi-tier applications like:

   - Spring framework:

fork my frame, and panel


Executed:


Result:




Git:

# - Start a brand new repo

echo "# RubyForm" >> README.md
git init
git add README.md
git commit -m "first commit"
git remote add origin https://github.com/Hawaiideveloper/RubyForm.git
git push -u origin master

# - Update an existing repo
git remote add origin https://github.com/Hawaiideveloper/RubyForm.git
git push -u origin master

Python : 


         I. (I also use it so I can sit down and run movies that I enjoy)

Command to launch my favorite movie via command line via Python:
import os  - a library used to start the linux terminal within the scrip
os.system("cd Videos/ a_movie/ vlc --fullscreen 1.mp4")






         II. (Sort files by date and place them into a folder by month)


import os, time, shutil, sys

 dir = sys.argv[1]
os.chdir(dir)
for f in os.listdir('.'):
    ftime = time.gmtime(os.path.getmtime(f))
    ctime_dir = str(ftime.tm_year) '-' str(ftime.tm_mon) '-' str(ftime.tm_mday)
    if not os.path.isdir(ctime_dir):
        os.mkdir(ctime_dir)
    dst = ctime_dir '/' f
    shutil.move(f, dst);
    print('File' f 'has been moved to' dst)




FIZZBUZZ in Python:

for num in xrange(1,61):
    if num % 5 == 0 and num % 3 == 0:  #if number is divisable by 5 and 3 with no remainders print fizzbuzz
        print "FizzBuzz"
    elif num % 3 == 0: #print fizz for numbers  with no remainders after dividing by 3
        print "Fizz"
    elif num % 5 == 0:  #print buzz for numbers  with no remainders after dividing by 3
        print "Buzz"
    else:        #otherwise print the current number
        print num

Ruby:

This will print the words "Hello, World" way easier than Java
 
puts 'Hello, world!' 






The example below (for loop in ruby) will count to 30 and put a space in between each number


#!/usr/bin/ruby

for numbers in (1..30)
    print numbers," "
end
print "\n"





RAILS / Passenger:



nano  config/database.yml
nano Gemfile
bundle install



### Create views and controllers
rails generate controller do_something index
nano config/routes.rb
rails generate model do_something title:string text:text
rake db:migrate
    
     #Edit the view to do something
       nano app/views/do_something/new.html.erb

# Going to production you will do this:
      #make permanent changes and migrate in production
      rails db:migrate RAILS_ENV=production

rails s



Things to remember when using coding with certain languages:

Dependency lookup is a pattern where a caller asks the container object for an object with a specific name or of a specific type. Dependency injection is a pattern where the container passes objects by name to other objects, via either constructors, properties, or factory methods.


MySQL:
mysql -u root -p

APIs:


Gems for Ruby:
- ActiveMerchant
- Bundler
- Capistrano
- Passenger
- FormTastic
- CarrierWave
- Shoulda
- Cocaine
- RMagic
- Spree
- CanCan



Mostly OpenStack:
- NOVA
- Neutron
- Cinder

###############################################################################
###############################################################################



Versioning  software SVN:

  - GitLab
  - GitHub
  - Jenkins
  - Redmine



Testing Frameworks:

  - JUnit:
  - MockIT
  - TestNG



Cisco Commands to Remember:

show config
wr config





Automation Tools:

Chef:


Ansible:

Puppet:



ansible-playbook



I. Linux:


top - every metric for PC
top -u every metric for a particular user
free -m memory displayed - what is the free memory available
df -h - display the existing hard drive space avaialable
pwd - what is the current working directory I am in
cd ~/ - go back to my home directory
chmod - change permission of folder/files
uptime - load average and users
iftop  - show the stats on the network interfaces

        A. Linux Authorized Key Setup:

     Setup a static ip or make sure your DNS is working as any variation of direct connectivity will cause this tutorial to fail:


The time of writing this I was on kernel "3.13.0.87" for Ubuntu and "4.3.3-301" for Fedora.

The concept it to show people that they can have both flavors of debian, and rpm based distributions working side by side.

Step 1: On the Client (your laptop):
    
ssh-keygen -t rsa






enter your passphrase and keep it secret.  If you need to replace it type: 
ssh-keygen -p
 

Step 2: On the Client (copy your ssh rsa key to the server) "make sure your user exists there"

ssh-copy-id@your_server_dns_or_static_IP



Step 3: On the Server (give yourself authorization of sudo)

if your user exists and its name is called "aguy" type the following otherwise substitute aguy with your username:

 sudo adduser aguy sudo

Step 4: Optional (makes life simplistic for the day)

it is a temporary thing; but if your tired of putting your password you simply add the key to your id by doing this:


eval $(ssh-agent)

ssh-add


Step 5: Final step and to test your pub/pri keys

ssh aguy@myIPaddress

If you connect without password, success!!!!










Security of AWS / Linux 2-way(public/private) keys in one line:

(This will generate the security keys, copy the security key to the said server and then connect you all in one line of code)* make sure your private key is of "600" file premissions

ssh-keygen; ssh-copy-id yournamehere@yourhost.com; ssh yourhost.com





Vagrant

 vagrant box add {title} {url}
 vagrant init {title}
 vagrant up
 vagrant halt
 
 
 
 
 Tools for you to researched:
 
 
Abstract class 
Cloud Orchestrator: (vRealize, OpenStack, IBM Cloud ICO)) 
Java with Spring 
Clojure - 
Terraform - 
Jenkins
Bamboo
kubernetes
Mesosphere
Nomad
Consul
Perforce
Docker 
Travis ci
LXC
Puppet
Salt Stack
Chef
Contracted for Lenovo through third party doing these tools:
AngularJS 
Node.js 
EA frameworks: TOGAF, FEA, Zachman
 Travis CI  - Corey
Docker - Tariq
Android (SDK)- Tariq

----------------------------------------------------------------


Groupon:


MapReduce commands  - Corey
 
 
 
 
 
 
 
 
 Appendix:
 
 Wikipedia: https://en.wikipedia.org/wiki/Spring_Framework
 Ruby ApIs - http://code.tutsplus.com/articles/24-extremely-useful-ruby-gems-for-web-development--net-23863
 Java Swing assistance: https://www.youtube.com/watch?v=3ifwR5feRQI&list=PLfyq5A05w62_verkKr3DWKWbttvdgexH3&spfreload=5#t=85.999659
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Mass-scaled microservice/SOA architectures  - Tariq   DONE
engineering as a development (Infra As Code)- Corey   DONE

Architect and maintain multi-site, high-availability, production solutions - Tariq DONE
Improvements to the deployment process and tools - Corey DONE
Diagnose and resolve production system issues - Tariq DONE

Articulate clear goals to meet the strategy and track key metrics to measure success
Demonstrable skill in it at least one scripting language (e.g. shell, Python, Ruby) DONE


Experience with version control, preferably Git and/or  DONE


7x24x365 support rotation DONE


XML - Corey  DONE
JSON - Tariq DONE
Python - Corey DONE

Open Source, automation, self-healing infrastructure are our mojo. KISS, DRY, Immutabiliy are common sense for us. - Corey  DONE


Cloud security - Corey  DONE
weblogic 10.3 admin console Java Oracle(bea 103) DONE

Ansible - Tariq  DONE

AWS - Tariq DONE

Linux  - Corey  DONE
Ruby - Tariq  DONE
 
Java - Tariq  DONE


Docker - Corey Done

3-teir webs application  Done

Build multiple mobile applications with Firebase



############################ A history of my typical commands in Ruby

rails new UlyssesOs
    4  bundle show
    5  bundle show mysql
    6  bundle show actionalmailer
    7  cd UlyssesOs/
    8  bundle show
    9  rails generate controller Welcome index
   10  nano app/views/welcome/index.html.erb
   11  rails s
   12  nano config/routes.rb
   13  rails s
   14  rails generate controller Welcome index
   15  bundle install
   16  rake db:create
   17  rails s
   18  nano config/routes.rb
   19  rails s
   20  nano config/routes.rb
   21  rails routes
   22  rails s
   23  rails generate controller Articles
   24  rails s
   25  nano app/controllers/articles_controller.rb 
   26  rails s
   27  nano app/views/articles/new.html.erb
   28  rails s
   29  nano app/views/articles/new.html.erb
   30  rails s
   31  nano app/views/articles/new.html.erb
   32  rails s
   33  nano app/controllers/articles_controller.rb
   34  rails s
   35  nano app/controllers/articles_controller.rb
   36  rails s
   37  nano app/controllers/articles_controller.rb
   38  rails s
   39  rails generate model Article title:string text:text
   40  cd db
   41  ls
   42  cd migrate/
   43  ls
   44  nano 20160822185151_create_articles.rb 
   45  cd ..
   46  rails db:migrate

No comments:

Post a Comment