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
入門Cureutils
Search
greymd
June 18, 2016
Programming
3
2.4k
入門Cureutils
2016/06/18に開催された「jus共催、第5回初心者向けとは言うものの午前のシェル勉強会/第23回梅雨でモワッとしたシェル芸勉強会」で発表したLT資料です。
greymd
June 18, 2016
Tweet
Share
More Decks by greymd
See All by greymd
狂気!AWS CloudShell細胞分裂!
greymd
0
2.2k
シェル芸人に必要なのは「マスキングテープ」だったのでは
greymd
19
10k
毎日叩ける シェル芸を覚えよう!
greymd
4
4.3k
Other Decks in Programming
See All in Programming
Enabling DevOps and Team Topologies Through Architecture: Architecting for Fast Flow
cer
PRO
0
340
CSC509 Lecture 12
javiergs
PRO
0
160
Less waste, more joy, and a lot more green: How Quarkus makes Java better
hollycummins
0
100
Micro Frontends Unmasked Opportunities, Challenges, Alternatives
manfredsteyer
PRO
0
110
flutterkaigi_2024.pdf
kyoheig3
0
150
Snowflake x dbtで作るセキュアでアジャイルなデータ基盤
tsoshiro
2
520
AI時代におけるSRE、 あるいはエンジニアの生存戦略
pyama86
6
1.2k
Hotwire or React? ~アフタートーク・本編に含めなかった話~ / Hotwire or React? after talk
harunatsujita
1
120
ペアーズにおけるAmazon Bedrockを⽤いた障害対応⽀援 ⽣成AIツールの導⼊事例 @ 20241115配信AWSウェビナー登壇
fukubaka0825
6
2k
エンジニアとして関わる要件と仕様(公開用)
murabayashi
0
300
Why Jakarta EE Matters to Spring - and Vice Versa
ivargrimstad
0
1.2k
3 Effective Rules for Using Signals in Angular
manfredsteyer
PRO
0
120
Featured
See All Featured
Speed Design
sergeychernyshev
25
620
Typedesign – Prime Four
hannesfritz
40
2.4k
Site-Speed That Sticks
csswizardry
0
31
Build The Right Thing And Hit Your Dates
maggiecrowley
33
2.4k
The Pragmatic Product Professional
lauravandoore
31
6.3k
Documentation Writing (for coders)
carmenintech
65
4.4k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
226
22k
What’s in a name? Adding method to the madness
productmarketing
PRO
22
3.1k
Optimizing for Happiness
mojombo
376
70k
Designing the Hi-DPI Web
ddemaree
280
34k
Building Flexible Design Systems
yeseniaperezcruz
327
38k
Bootstrapping a Software Product
garrettdimon
PRO
305
110k
Transcript
ೖCureutils @grethlen
~$ whoami Yasuhiro Yamada (HN: ͙Ε͞Μ) Twitter: @grethlen ϋΠύʔγΣϧܳΩϡΞΤϯδχΞ ओͳલՊ
• γΣϧܳ x WebεΫϨΠϐϯά (120stock) http://qiita.com/greymd/items/368faf898c161165fee7 • γΣϧܳ x ଟݴޠϚογϡΞοϓ (ͯͿҰҐʣ http://qiita.com/greymd/items/a4ecf8e70f11eb1e5f7 • γΣϧܳ x IoT (͋Γ͕ͪͳIoTܥهࣄ) http://www.slideshare.net/YasuhiroYamada1/arduino-52210988 • γΣϧܳ x Egison (270stock) https://github.com/greymd/egzact ྉཧͰ͖·ͤΜ
ϓϩάϥϛϯάڭҭ *1 https://twitter.com/13Mzawa2/status/741902695712182272/photo/1 2020ΑΓখֶߍ͔Βϓϩάϥϛϯά͕ඞमԽݟࠐΈ γΣϧεΫϦϓτ͔Δখֶੜ *1
ݒ೦.1 ಓ۩ద͔ʁ • ΞϧΰϦζϜ͚ͩڭ͑ͯҝʹͳΔͷ͔ʁ • γΣϧܳͷڭҭ༻πʔϧͱͯ͠ͷ ແବʹߴ͍ϙςϯγϟϧ 1. σʔλߏͷେֶ͞Δɻ ΞϧΰϦζϜ͚ͩͰͳ͍ɻ
2. ײ͞ɻωετ͠ʹ͍͘ɺ ੵΈΛੵΈ্͛Δײ֮ɻ 3. ෦Խͷେ͞ɻ Ұͭͷ෦Ұͭͷ͜ͱΛ͏·͘ɻ → S◦ratchΦϫίϯɻ࣌γΣϧܳ!? vs γΣϧܳͷྫ ڭҭ༻ιϑτͷྫ
ݒ೦.2 ۤखҙࣝͷέΞ ଟ͘ͷڞײʢˢ200RTʣΛੜΜͩ ࠃຽͷΛหͨ͠πΠʔτ*1 *1 https://twitter.com/grethlen/status/722066098758111232
ʲิࢿྉʳϓϦΩϡΞ • ຊ͕ੈքʹތΔ ࠃຽతΞχϝͷҰͭ • 13ઈࢍ์өதʂ ʮຐ๏͔͍ͭϓϦΩϡΞʯ • ςϨϏேܥྻ ༵ே8:30ʙ
γΣϧܳษڧձͷ࣍ͷ ૣ͘ى͖ͯ؍Α͏ *1 http://www.toei-anim.co.jp/tv/precure/ ఱୡ *1
ݒ೦3. ڭһΓ͍ͯΔͷ͔ʁ ্͕Δٕज़ऀͷٻਓഒ*1 Լ͕ΔϓϦΩϡΞͷࢹௌ*2 *1 http://doda.jp/guide/kyujin_bairitsu/#03 *2 http://prehyou2015.hatenablog.com/entry/shichourituichiran → ਂࠁԽ͢ΔएऀͷΩϡΞΤϯδχΞΕɻ
ʲ݁ʳࠓͷຊʹඞཁͳࣄ ʮγΣϧܳ & ϓϦΩϡΞʯ ͳ ٕज़ऀΛ૿͢ɻ
~$ man Cureutils Cureutils ʲ͖Ύ͋ΏʔͪΔͣʳ • ࣍ੈߴΩϡΞITਓࡐཆ༻ίϚϯυूɻ • UNIXॳֶऀͷֶश༻ʹɻ •
ͪΖΜۀʹཱͭɻ • Github: https://github.com/greymd/cureutils • RubyίϚϯυ • rubicure*1ΛґଘϥΠϒϥϦͱͯ͠࠾༻ɻ *1 https://github.com/sue445/rubicure
ಋೖํ๏ RubygemsొࡁΈ *1 • gemͰೖΕΒΕΔɻ $ sudo gem install cureutils
Πϯετʔϧ͢ΔͱcureίϚϯυ͕͑Δɻ • ͍ํͷදࣔɻ $ cure help *1 https://rubygems.org/gems/cureutils
~$ cure precures $ cure precures • ϓϦΩϡΞͷ໊લΛશһग़ྗ *1 *1
ݱࡏ·ͰͷςϨϏγϦʔζͷϝΠϯώϩΠϯͱΩϡΞΤίʔΛؚΊ46ਓɻ ʮΩϡΞʯ͕͔ͭͳ͍ͷؚΉɻΩϡΞ{ϒϥΠτ, ϒϧʔϜ}ͳͲͷ ಉҰਓͰҟ໊ͷϓϦΩϡΞʹͳΔͷഉআɻ೦ͳ͕Βຬͱ܆ؚ·ͣɻ
~$ cure girls $ cure girls • มલͷঁͷࢠͷ໊લΛશһग़ྗ
~$ cure {precures,girls} # ׆༻໘ • ςετ༻μϛʔσʔλ࡞ʹɻ • ৬/ֶߍͰͷ࡞Γʹɻ ʮणݶແݴ͑ΔΜͩɺ͍͢͝Ͷɻ͡Ό͋ϓϦΩϡΞʁʯ
• ࠾༻໘ରࡦʹɻ ʮFizzBuzzͩͤΔΑͶʁ͡Ό͋ϓϦΩϡΞͩͤΔʁʯ ʮ$ cure precuresʯ ʮ͛͐ͬɺγΣϧܳਓʂʯ
$ cure grep (1) $ cat text | cure grep
ࢲΩϡΞϒϥοΫͰ͢ɻ • ϓϦΩϡΞͷ໊લͷΈΛநग़͢Δɻ $ curl -Lso- goo.gl/L3Fp6h | cure grep | head -n 1 ΩϡΞϒϥοΫౖܹͨ͠ɻඞͣɺ… • ύΠϓͰͭͳ͙ͱண৭Λͣ͢ɻ
$ cure grep (2) • ਖ਼نදݱͰPBE͕ར༻Մೳʂ $ cat txt |
cure grep ‘ࢲ[:precure_name:]Ͱ͢ɻ’ ͜Μʹͪɺ ࢲΩϡΞϨϞωʔυͰ͢ɻ • ௨ৗͷBE (Bracket Expression) [:alnum:], [:lower:], [:upper:], [:space:] … • PBE (Precure Bracket Expressin) [:precure_name:] — ϓϦΩϡΞ໊ʹϚον [:human_name:] — ঁͷࢠ໊ʹϚον [:cast_name:] — ༏໊ʹϚον ͳͲ
~$ cure grep (3) γΣϧܳਓ͓ೃછΈͷίϚϯυϥΠϯΦϓγϣϯʂ • -o : Ϛον෦ͷΈग़ྗɻ •
-E : ͨͩͷ֦ுਖ਼نදݱΛ͏ɻ PBEແޮԽɻීஈͷgrepίϚϯυʹมʂ $ cat access.log | cure grep -E '192.168.1.1'
~$ cure grep #׆༻໘ • จষ͔ΒεϜʔζʹϓϦΩϡΞΛநग़ɻ • ࣄͷใࠂॻɺֶߍͷϨϙʔτͳͲɻ • Rubyͷਖ਼نදݱ͕͑Δgrepͱׂͯ͠ͱศར
• ෦ࣜݺͼग़͠*1ͱ͔͑Δ $ echo "aaaa\naabb" | \ cure grep '^(?<name>aa)\g<name>$' aaaa *1 http://docs.ruby-lang.org/ja/1.9.3/doc/spec=2fregexp.html
~$ cure transform • ϓϦΩϡΞΛมͤ͞Δɻ $ echo ‘ࢲͷ໊લेϦίͰ͢ɻ’ | cure
transform ࢲͷ໊લΩϡΞϚδΧϧͰ͢ɻ
~$ cure humanize • ϓϦΩϡΞͷมΛղআ͢Δɻ $ echo ΩϡΞ{ϋʔτ,Τʔε} | cure
humanize ૬ాϚφ ԁѥٱཬ
~$ cure {humanize,transform} # ׆༻໘ • ใͷਖ਼نԽɻ • Ұ୴શͯͷϓϦΩϡΞΛมͤ͞Δɻ •
grepΛ͔͚͘͢͢Δɻ
~$ cure date (1) $ cure date 2016-06-17 21:28:42 ຐ๏͔͍ͭϓϦΩϡΞʂ์өظؒ
• ݱࡏͷ࣌Λදࣔ͢Δɻ • ͦͷ࣌ͷϓϦΩϡΞؔ࿈ͷΠϕϯτදࣔɻ • ࣌์өதͷϓϦΩϡΞɻ • ॳճɾ࠷ऴճ์ө • ϓϦΩϡΞͷੜ • өըͷެ։ ͳͲ
~$ cure date (2) • -d ΦϓγϣϯରԠ $ cure date
-d ‘1 years ago’ • “+”ʹଓ͍ͯͷग़ྗϑΥʔϚοτΛࢦఆՄೳɻ $ cure date ‘+%Y-%m-%d @p’ • %Y : ྐྵ • %m : ݄ 01 - 12 • %d : 01 - 31 • @P : ϓϦΩϡΞؔ࿈ͷΠϕϯτ • ଞͷه๏ରԠ
~$ cure date #׆༻໘ • dateಉ༷ɺϩάͷग़ྗ࣌ࠁͱͯ͠ɻ • ϥΠϑϩάͷΤοηϯεͱͯ͠ɻ • ௨ৗͷdateίϚϯυͱҧ͍
YYYY-mm-dd HH:MM:SS ϑΥʔϚοτͰσϑΥϧτͰग़ྗɻ ͪΐͬͱ͋Γ͕͍ͨɻ
~$ cure echo (1) • ΩϡΞΤίʔͷมޱ্Λग़ྗ͢Δɻ • Φϓγϣϯ • -a
: ߈ܸͷޱ্ΛՃ • -q : ޱ্Λ͙͢ʹදࣔͤ͞Δɻ $ cure echo ΈΜͳͷࢥ͍ΛकΔͨΊʹ # ҎԼུ *1 http://cocoa08.com/anime/4287/ ܶ൛ݶఆͷϓϦΩϡΞ *1
~$ cure echo (2) • ͪΖΜଞͷϓϦΩϡΞʹରԠ • -p ϓϦΩϡΞΛࢦఆͰ͖Δɻ $
cure echo -p sword ϓϦΩϡΞϥϒϦϯΫʂ # ҎԼུ
~$ cure echo #׆༻໘ • ςετ༻μϛʔจষͷੜʹɻ • ҰൠϢʔβ͕rootʹͳΔ࣌ͷܯࠂͱͯ͠ɻ $ echo
“cure echo” >> /root/.bashrc • େ͖ͳྗʢݖݶʣΛ࣋ͬͨ͜ͱΛ֮ࣗͤ͞Δɻ • దٓམͪண࣌ؒ͘Λઃ͚ΒΕΔɻ → Φϖϛεͷݮ
~$ cure janken $ cure janken • ϐΧϦϯδϟϯέϯ͕Ͱ͖Δ • উഊʹΑΓ
ऴྃεςʔλε͕มԽɻ • উར: 0 • ഊ: 1 • ͍͋͜: 2 ϐΧϦϯ͡ΌΜ͚Μ by ΩϡΞϐʔε
~$ cure janken #׆༻໘ • ࣄதͷଉൈ͖ʹɻ • উෛڧ͍ਓ͚͕࣮ͩߦͰ͖ΔεΫϦϓτ࡞ʹɻ • ެฏͳ࡞ۀ୲ʹɻ
$ cure janken && mysql -u user ʮ࠷ॳʹউͬͨਓ͕drop table͠·͠ΐ͏Αɻʯ
ͦͷଞ GithubͰZsh༻ೖྗิεΫϦϓτΛެ։தʂ • Github: https://github.com/greymd/cureutils/blob/ master/etc/cure-completion.zsh RubyΛֶͿͨΊʹ࡞ͬͨͷɻ • RubylistͷํͷϑΟʔυόοΫͬͯ·͢ʂ