Automating Your Daily Tasks with Scripting презентация

Содержание

Agenda What is Scripting Why Scripting Several Cases Script Management Q & A

Слайд 1Automating Your Daily Tasks with Scripting
Adler Hsieh
RubyConf Taiwan
2015-9-11


Слайд 2Agenda
What is Scripting
Why Scripting
Several Cases
Script Management
Q & A


Слайд 3Only Basic Concept


Слайд 4Who am I
Adler Hsieh
Software Engineer at OneAD
Ruby, JavaScript, PHP




Github: adlerhsieh
Twitter: @adler_hsieh
Blog:

http://motion-express.com

Слайд 5What is Scripting


Слайд 6Let’s make it simple


Слайд 9Let’s make it a little useful


Слайд 10How do I get my local ip address?


Слайд 11> ifconfig


Слайд 12What is scripting
192.168.1.149
Your local ip address


Слайд 13What is scripting


Слайд 14What is scripting
Basically…
Small programs
solving
Small problems


Слайд 15Plus…
Saves time
Easy to write
Easy to manage


Слайд 16And…

Show off


Слайд 17Cases
Cleaning old files
Shutdown local server
MySQL Database import from .sql


Слайд 18Cleaning Old Files
Scenario
All downloaded files are in one directory
Directory becomes

very large

Слайд 19Cleaning Old Files


Слайд 20Cleaning Old Files


Слайд 21Cleaning Old Files
Use it with Cron


Слайд 22Shutdown Server
Scenario
Local server crashes
I cannot shut down my rails server with

ctrl + c

Слайд 23Shutdown Server
> lsof –i:3000






> kill -9 PID


Слайд 24Shutdown Server


Слайд 25Importing MySQL database with .sql
Scenario
When there is bug
Importing production DB to

local DB

Слайд 26Importing MySQL database with .sql
> ssh username@100.100.100.100
> mysqldump –u username –p

db_name > db.sql
> exit
> scp username@100.100.100.100:db.sql db.sql
> mysql –u username –p db_name < db.sql

Слайд 27Importing MySQL database with .sql


Слайд 28Cases
Scripts are task-specific
Find patterns in your tasks


Слайд 29Managing Scripts


Слайд 30Managing Scripts
If you do not manage scripts…
Scripts everywhere
You have to remember

file locations

Слайд 31Managing Scripts
Purpose
All scripts at a glance
Write once, run everywhere


Слайд 33Managing Scripts
Rake
Managing all rake tasks in ~/.rake folder
task_a.rake
task_b.rake
Prefixing ‘rake’ command
Description support


Слайд 34Managing Scripts


Слайд 35Managing Scripts
Managing tasks like in Rails
restart.rake
import.rake
local_ip.rake
clean.rake

Thus, run `rake` command from anywhere
(add

–g option if necessary)


Слайд 36Executables


Слайд 37Managing Scripts
Make scripts executables
Separate scripts by commands

The bad part
Too many commands
Conflicting

with existing commands

Слайд 38Managing Scripts


> chmod 755 hello.rb
> mv hello.rb

hello
> ./hello

Слайд 39Managing Scripts
Change the following line in your ‘.bashrc’:
export PATH=“/user/bin:/usr/local/bin”
To:
export PATH=“/user/bin:/usr/local/bin:/scripts”
And you

can do:
> hello

Слайд 40That’s it!


Слайд 41Recap
Scripts are small programs solving small problems
Scripts are case-specific
Automation saves energy

& time
Managing scripts with rake

Слайд 42Make your own scripts!


Слайд 43Thank you!
Slides are available on my Twitter
@adler_hsieh


Обратная связь

Если не удалось найти и скачать презентацию, Вы можете заказать его на нашем сайте. Мы постараемся найти нужный Вам материал и отправим по электронной почте. Не стесняйтесь обращаться к нам, если у вас возникли вопросы или пожелания:

Email: Нажмите что бы посмотреть 

Что такое ThePresentation.ru?

Это сайт презентаций, докладов, проектов, шаблонов в формате PowerPoint. Мы помогаем школьникам, студентам, учителям, преподавателям хранить и обмениваться учебными материалами с другими пользователями.


Для правообладателей

Яндекс.Метрика