Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Ruby Scripts To Make Life Easier
Search
Paulo Ancheta
December 06, 2016
Programming
1
130
Ruby Scripts To Make Life Easier
Introduction to subprocesses and how to use them for everyday use.
Paulo Ancheta
December 06, 2016
Tweet
Share
More Decks by Paulo Ancheta
See All by Paulo Ancheta
Demystifying Git
pauloancheta
0
40
A PR Has Been Submitted
pauloancheta
0
51
Other Decks in Programming
See All in Programming
それ CLI フレームワークがなくてもできるよ / Building CLI Tools Without Frameworks
orgachem
PRO
17
3.7k
AI Ramen Fight
yusukebe
0
130
PHPUnitの限界をPlaywrightで補完するテストアプローチ
yuzneri
0
380
DataformでPythonする / dataform-de-python
snhryt
0
150
ゲームの物理
fadis
3
770
変化を楽しむエンジニアリング ~ いままでとこれから ~
murajun1978
0
670
Vibe coding コードレビュー
kinopeee
0
420
CLI ツールを Go ライブラリ として再実装する理由 / Why reimplement a CLI tool as a Go library
ktr_0731
3
990
プロダクトという一杯を作る - プロダクトチームが味の責任を持つまでの煮込み奮闘記
hiliteeternal
0
420
Constant integer division faster than compiler-generated code
herumi
2
430
コーディングは技術者(エンジニア)の嗜みでして / Learning the System Development Mindset from Rock Lady
mackey0225
2
220
なぜあなたのオブザーバビリティ導入は頓挫するのか
ryota_hnk
5
570
Featured
See All Featured
A better future with KSS
kneath
239
17k
Become a Pro
speakerdeck
PRO
29
5.5k
Optimising Largest Contentful Paint
csswizardry
37
3.4k
Adopting Sorbet at Scale
ufuk
77
9.5k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
8
880
For a Future-Friendly Web
brad_frost
179
9.9k
Rebuilding a faster, lazier Slack
samanthasiow
83
9.1k
Raft: Consensus for Rubyists
vanstee
140
7.1k
Mobile First: as difficult as doing things right
swwweet
223
9.9k
Code Reviewing Like a Champion
maltzj
524
40k
Designing for humans not robots
tammielis
253
25k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
26k
Transcript
Ruby Scripts to Make Life Easier #MakeRubyGreatAgain
@PauloAncheta
We make alias-es all the time. We should make something
more useful.
# talk.rb system “echo hello world” $ ruby talk.rb hello
world
# talk* #! bin/env ruby `echo hello world` $ mv
talk.rb talk $ chmod u+x talk $ ./talk hello world
# talk* #! bin/env ruby string = “hello world” `echo
#{string}` $ ./talk hello world
# talk* #! bin/env ruby string = “hello world” `echo
#{string.gsub(/world/, “VanRuby”) } | grep file.txt` $ ./talk | more file.txt hello VanRuby
$ irb irb(main):001:0> files = `ls` => “Applications\nDesktop\nDocuments\nDow nloads\nLibrary\nMovies\nMusic\nPictur es\nPublic\ntalk\n”
irb(main):002:0> files.class => String
irb(main):003:0> system `ls` => true
All of that is great. How can I be productive
doe?
# clean-pg* #! bin/env ruby pg = `ps aux |
grep postgres | grep waiting` pg = pg.split(/\n/) pg.each do |waiting| # ... some process to get the pid `kill #{pid}` end
# split-branch* #! bin/env ruby # commits => 1z2y3 TICKET-number
msg specific_commits = `git log - -pretty - -oneline | grep #{ARGV}` `git checkout master && git pull origin master && git checkout -b test-branch` specific_commits.each do |commit| sha = commit[0..6] # => [123asdf, qwer456, … ] `git cherry-pick #{sha}` end
#MakeRubyGreatAgain