Slide 1

Slide 1 text

ΞεΩʔΞʔτ
 ϫϯϥΠφʔ @ୈ25ճγΣϧܳษڧձ େࡕαςϥΠτ (2016.10.29) MSR (@msr386)

Slide 2

Slide 2 text

໨࣍ ➤ ࣗݾ঺հ ➤ ࠓ·Ͱͷ൓ল ➤ ΞεΩʔΞʔτͳγΣϧܳ (όφʔܳ) ➤ ಥવͷࢮ ➤ slίϚϯυ ➤ λʔϛφϧը໘Λ͙ͪΌ͙ͪΌʹ͢Δ ➤ ·ͱΊ

Slide 3

Slide 3 text

ࣗݾ঺հ ➤ ϋϯυϧωʔϜ: MSR (@msr386) ➤ C++ϓϩάϥϛϯάɺαʔόʔӡ༻͕ಘҙ ➤ ٻ৬த ➤ Chromium Contributor (1ճ͚ͩ) ➤ Webϒϥ΢β࡞͍ͬͯ·͢ (http://app.tungsten-start.net/)

Slide 4

Slide 4 text

ࠓ·Ͱͷ൓ল

Slide 5

Slide 5 text

͜Ε·Ͱͷࣗ෼ͷओͳ LTൃදΛৼΓฦΔͱ

Slide 6

Slide 6 text

(1)Χφμͷങ͍੾ΓVPSͷ঺հ ӡ༻ʹ͸࢖͑ͳ͍͚ͲγΣϧܳ஁࿉ʹ͸ͽͬͨΓ?

Slide 7

Slide 7 text

(2) QRίʔυγΣϧܳ? QRةݥγΣϧܳ / QRίʔυγΣϧܳͷՄೳੑΛ໛ࡧ

Slide 8

Slide 8 text

΄ͱΜͲγΣϧܳͱ ؔ܎ͳ͍͡ΌΜ (ΨνͷγΣϧܳ΍Ζ͏ͥ)

Slide 9

Slide 9 text

࠷ۙͷόφʔܳͱ͍͏ ྲྀߦʹ৐Γ

Slide 10

Slide 10 text

ΞεΩʔΞʔτγΣϧ ܳΛ΍Γ·͢

Slide 11

Slide 11 text

1. ಥવͷࢮ

Slide 12

Slide 12 text

΁ ?P? ΁
 ɹɹc΁
 ɹɹ

Slide 13

Slide 13 text

ʘ ?P? ΁
 ɹʘc
 ɹɹɹʼ

Slide 14

Slide 14 text

ʻ ?P? ʼ
 ɹࡾ ࡾ
 ʻʉʉʼ

Slide 15

Slide 15 text

Є ?P? 
 ɹʻ ʼάΩο
 ʻʉʉʼ

Slide 16

Slide 16 text

ʊਓਓਓਓʊ
 ʼಥવͷࢮʻ
 ʉ:?:?:?:ʉ

Slide 17

Slide 17 text

ಥવͷࢮ ➤ 2012೥ࠒɺͱ͋Δܝࣔ൘ʹॻ͖ࠐ·Εͨ΋ͷ͕ݩωλͱݴΘΕ͍ͯΔ ➤ ࠷ޙͷғΈจࣈͷΞεΩʔΞʔτ͚͕ͩΑ͘࢖ΘΕ͍ͯΔ ➤ 2013೥ʹTwitterͰվߦίʔυ͕ରԠ͔ͯ͠Βڻҟతʹ֦ࢄ ➤ ओͳಛ௃ ➤ ൚༻ੑͷߴ͞ ➤ ΞεΩʔΞʔτͷ୯७͞ ➤ ݟͨ໨ͷྗڧ͞ ➤ ʮಥવͷࢮδΣωϨʔλʔʯͱ͍͏໊લͰWebαʔϏεԽɺiOS΍Android޲͚ʹΞϓ ϦԽ͞Ε͍ͯΔ

Slide 18

Slide 18 text

ಥવͷࢮɹγΣϧεΫϦϓτ൛͕ଘࡏ ➤ γΣϧεΫϦϓτ΋͋Δ (https://fumiyas.github.io/2013/12/25/echo-sd.sh-advent-calendar.html) $ echo -e "crontab -r\n突然の危険シェル芸" | echo-sd -s --center
 _人人人人人人人人人人人_
 >   crontab -r   <
 > 突然の危険シェル芸 <
 ‾Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^‾
 $ 
 $ echo-sd -v 縦書き
 _人人_
 > 縦 <
 > 書 <
 > き <
 ‾Y^Y^‾
 $

Slide 19

Slide 19 text

ಥવͷࢮɹγΣϧεΫϦϓτ൛͕ଘࡏ ➤ ॎॻ͖ɺ୹࡭ɺετϨεൃੜաఔϞʔυɺπΠʔτػೳͳͲػೳ͕๛෋ $ echo-sd --stress "crontab: no crontab for root" あれ?中身消えてる "(historyの結果) 334 sudo crontab -r" "eとr押し間違い!バック アップない!!" 危険シェル芸
 
 crontab: no crontab for root
     ↘
    あれ?中身消えてる
     ⾫
 (historyの結果) 334 sudo crontab -r
     ↘
    eとr押し間違い!バックアップない!!
     ⾫
 _人人人人人人人人_
 > 危険シェル芸 <
 ‾Y^Y^Y^Y^Y^Y^Y^Y^‾ $ echo-sd --tanzaku ":(){ :|:& };:"
 ┏-┷-┓
 ┃ ‥ ┃
 ┃ ⏜ ┃
 ┃ ⏝ ┃
 ┃ ⏞ ┃
 ┃  ┃
 ┃ ‥ ┃
 ┃ | ┃
 ┃ ‥ ┃
 ┃ & ┃
 ┃  ┃
 ┃ ⏟ ┃
 ┃ ; ┃
 ┃ ‥ ┃
 ┗━━┛

Slide 20

Slide 20 text

ϫϯϥΠϯ࣮૷ɺ։࢝

Slide 21

Slide 21 text

࢝ΊΔલʹ ୯७ԽͷͨΊʹɺҎԼͷΑ͏ͳखൈ͖Λ͠·͢ ➤ ౳෯ϑΥϯτʹಛԽ ➤ 1ߦ͚ͩରԠ
 ෳ਺ߦͰ͸ߟྀ͢΂͖͜ͱ͕૿͑ΔͨΊ ➤ શ֯จࣈ͚ͩରԠ
 ൒֯จࣈ͸ͱΓ͋͑ͣແࢹ͢Δ ➤ LANG=ja_JP .UTF-8 લఏ
 LANGʹΑΓจࣈ਺ܭࢉ͕͓͔͘͠ͳΒͳ͍Α͏ʹ͢ΔͨΊ

Slide 22

Slide 22 text

੍࡞աఔ 1. ಛ௃Λଊ͑Δ _人人人人人人_
 > 突然の死 <
 ‾Y^Y^Y^Y^Y^Y^‾ ಥવͷࢮ͸ɺจࣈ਺ʹԠ্ͯ͡෦ɺԼ෦ͷจࣈ਺͕มԽ͢Δ
 →্෦ʮਓʯͱԼ෦ʮY^ʯΛશ֯1จࣈʹରͯ͠1ݸͣͭ૿΍ͤ͹Α͍

Slide 23

Slide 23 text

੍࡞աఔ 2. จࣈ਺Λௐ΂Δʹ͸?
 awkͷlength()Λ࢖༻͢Δ
 for (i=0; i

Slide 24

Slide 24 text

ಥવͷϫϯϥΠφʔ୯७൛ $ echo 突然の死 | awk \
 '{for(i=0;i

Slide 25

Slide 25 text

ಥવͷϫϯϥΠφʔ୯७൛ɹ࣮ߦྫ $ echo 突然の死 | awk '{for(i=0;i

Slide 26

Slide 26 text

ಥવͷϫϯϥΠφʔ୯७൛ͷಛ௃ͱ໰୊఺ ಛ௃ ➤ awkҰൃܳ ➤ πΠʔτՄೳ(112จࣈ) ໰୊఺ ➤ ൒֯จࣈࠞ͟ΔͱͣΕΔͷ͸खൈ͖͠ա͗͡Όͳ͍?
 ൒֯จࣈͰͣΕΔݪҼ͸ɺawkͷlength()ͷ࢓༷ ➤ LANG؀ڥม਺ʹґଘ ➤ ja_JP .UTF-8ͷ৔߹ɺશ֯΋൒֯΋1Λฦ͢ ➤ ͳΒ͹ɺશ֯͸2ɺ൒֯͸1Λฦͤ͹ͣΕͳ͍ΑͶ?

Slide 27

Slide 27 text

ಥવͷϫϯϥΠφʔվྑ൛ $ echo 突然の死 | awk \
 '{for(i=1;i<=length();i++){ \
 len+=(substr($0,i,1)~/[\x01-\x7E]/)?1:2} \
 for(i=0;i

Slide 28

Slide 28 text

ಥવͷϫϯϥΠφʔվྑ൛ɹ࣮ߦྫ $ echo 突然のワンライナーEx | awk '{for(i=1;i<=length();i++){len +=(substr($0,i,1)~/[\x01-\x7E]/)?1:2}for(i=0;i

Slide 29

Slide 29 text

ಥવͷϫϯϥΠφʔվྑ൛ͷಛ௃ ➤ վળ ➤ ൒͕֯ࠞͬͯ͟΋ͣΕͳ͍ ➤ վѱ ➤ πΠʔτෆՄ

Slide 30

Slide 30 text

վྑ൛ͷղઆ ➤ awkΛ੔ܗ͢Δͱ͜ͷΑ͏ʹͳΔ {
 for(i = 1; i <= length(); i++) {
 len += ( substr($0,i,1) ~/[\x01-\x7E]/ ) ? 1 : 2
 }
 for(i = 0; i < len / 2 + 2; i++) {
 up = up "ਓ";
 dn = dn "Y^"
 }
 printf("ʊ%sʊ\nʼɹ%sɹʻ\nʉ%sʉ\n", up, $0, dn)
 }

Slide 31

Slide 31 text

վྑ൛ͷղઆ (1.)
 for(i = 1; i <= length(); i++) {
 len +=
 (substr($0,i,1)~/[\x01-\x7E]/)
 ? 1 : 2
 } (2.)
 for(i = 0; i < len / 2 + 2; i++) {
 up = up "ਓ";
 dn = dn "Y^"
 } (3.)
 printf("ʊ%sʊ\nʼɹ%sɹʻ\nʉ%sʉ\n", up, $0, dn) 1. จࣈ਺Λऔಘ
 1จࣈͣͭऔΓग़͠ɺจࣈ͕UTF-8Ͱ1όΠτ จࣈͰ͋Δ৔߹͸1ɺͦΕҎ֎͸2ͱ͢Δɻ
 UTF-8ͷ1όΠτจࣈ͸ɺ0x01ʙ0x7eؚ͕· Ε͍ͯΔ͔Ͳ͏͔Ͱ൑ఆ͢Δɻ 2. ্෦ʮਓʯɺԼ෦ʮY^ʯΛจࣈ਺ʹԠͯ͡ ૿΍͢
 ૿΍͢਺͸શ֯ج४Ͱ͋Δ͜ͱʹ஫ҙ 3. printfͰ੔ܗ

Slide 32

Slide 32 text

͞ΒͳΔվྑͷಓ ➤ ෳ਺ߦରԠ ➤ ϧʔϓճ਺ΛݮΒ͢ͳͲͷ࠷దԽ ➤ awkΛ࢖Θͳ͍ํ๏ ➤ etc. ➤ ΋ͬͱ͍͍ํ๏͸͋Δ͸ͣͳͷͰɺՋͳͱ͖ʹνϟϨϯδ͠·͠ΐ͏

Slide 33

Slide 33 text

൪֎ฤ _人人人人人人人_
 > 突然のSEGV <
 ‾Y^Y^Y^Y^Y^Y^Y^‾

Slide 34

Slide 34 text

൪֎ฤ ➤ SEGVͰམͪͨɾɾɾ࢓༷? $ awk --version
 GNU Awk 4.1.3, API: 1.1 (GNU MPFR 3.1.4, GNU MP 6.1.0)
 <ҎԼུ>
 $ echo ಥવͷSEGV | awk '{print $0~/[\x00-\x7F]/}'
 1
 $ echo ಥવͷSEGV | awk '{print $0~/[\x00-\x80]/}'
 awk: ίϚϯυϥΠϯ:1: க໋తΤϥʔ: ಺෦Τϥʔ: ηάϝϯςʔγϣϯҧ൓
 Aborted (core dumped)
 $

Slide 35

Slide 35 text

2. SLίϚϯυ

Slide 36

Slide 36 text

LSͷ͋Δ͋Δ࿩ ➤ lsͱೖΕΑ͏ͱͯ͠
 $ sl -l
 sl: command not found
 $ ➤ lʮ΋͔ͯ͠͠ʯ
 sʮΘͨͨͪ͠ʯ
 ҎԼུ ➤ lsͱؒҧ͑ͯslͬͯೖΕͪΌͬͨʂͱ͍͏͋Δ͋Δ࿩͔Βɺslͱ͍͏δϣʔΫίϚϯ υ͕஀ੜͨ͠

Slide 37

Slide 37 text

SLίϚϯυͷ௕͍ྺ࢙ ➤ 1987೥ɺUNIXχϡʔεάϧʔϓfj.sourceʹॳొ৔(࡞ऀ͸Վ୅࿨ਖ਼͞Μ) ➤ 1993೥ɺ๛ాਖ਼࢙͞Μ(ݱࡏɺ।ڭत)͕slίϚϯυΛϦϦʔε
 ͨͩͷδϣʔΫίϚϯυ͔ΒΩʔλΠϓڲਖ਼ίϚϯυʹਐԽ ➤ 1990೥୅ޙ൒ʙ LinuxσΟετϦϏϡʔγϣϯʹ౥ࡌ͞ΕΔΑ͏ʹͳΔ ➤ 2000೥୅ɺslͷվ଄൛͕ొ৔ ➤ དྷ೥Ͱ30प೥!

Slide 38

Slide 38 text

SLίϚϯυͷಛ௃ ➤ Ctrl+C (SIGINT) Λԡͯ͠΋தஅ͠ͳ͍
 ΩʔλΠϓڲਖ਼͕໨త͔ͩΒ ➤ lsΑΓ࣮ߦ͕࣌ؒ͸Δ͔ʹ௕͍
 ΩʔλΠϓڲਖ਼͕໨త͔ͩΒ ➤ Φϓγϣϯ͕lsʹࣅ͍ͯΔ
 Ωʔt δϣʔΫίϚϯυ͔ͩΒ

Slide 39

Slide 39 text

SLίϚϯυΛγΣϧܳͰ

Slide 40

Slide 40 text

৚݅ ➤ ݩωλͷΞεΩʔΞʔτΛϕʔεͱ͢Δ
 o 
 o 
 o ____
 -- |OO|
 _||__| |
 | |
 /-O=O O=O-- ➤ ंྠ͸ճΒͳ͍ ➤ ৠؾ͸ݻఆ͔ͭग़ͬͺͳ͠ ➤ ӈ͔Βࠨ΁ಈ͕͘ɺؿंશମ͸ৗʹදࣔͤ͞Δ ➤ Ctrl+C͸༗ޮ (ΩʔλΠϓڲਖ਼͕໨తͰ͸ͳ͍͔Β)

Slide 41

Slide 41 text

γΣϧܳखॱ̍ AAΛ1ߦʹ $ echo -e " o \n o \n o ____\n -- |OO|\n _||__| |\n | |\n/-O=O O=O--"
 o 
 o 
 o ____
 -- |OO|
 _||__| |
 | |
 /-O=O O=O--
 $

Slide 42

Slide 42 text

γΣϧܳखॱ̎ ӈ٧Ί͢Δ ؀ڥʹԠͯ͡ tput colsɺBSDܥͳΒ tput coɺBashͳΒecho $COLUMNS Ͱ୺຤ͷ෯͕ औಘͰ͖Δ $ echo $COLUMNS 120 awkͷ-vΦϓγϣϯͰγΣϧม਺Λ౉͠ɺεΫϦϓτ಺ͷprintfͰӈ٧Ίͤ͞Δ $ echo -e " o \n o \n o ____\n -- |OO|\n _||__| |\n | |\n/-O=O O=O--" | awk -v col=$COLUMNS '{printf("%" col "s\n", $0)}'

Slide 43

Slide 43 text

γΣϧܳखॱ̏ ӈ٧Ίͷ෯ΛݮΒ͍͖ͯ͠ɺ׬੒ for ; do ; doneΛ࢖༻͢Δ $ for ((i=$COLUMNS; i>=11; i--)); do clear; echo -e " o \n o \n o ____\n -- |OO|\n _||__| |\n | |\n/-O=O O=O--" | awk -v col=$i '{printf("%" col "s\n", $0)}'; sleep 0.06; done

Slide 44

Slide 44 text

͞ΒͳΔվྑͷಓ ➤ ͍͖ͳΓݱΕ͍͖ͯͳΓࢭ·ΔͷͰɺྻंࣄނͷΑ͏ʹݟ͑Δ
 ˞ݩωλ͸૸ΓڈΔ ➤ ୺຤ʹΑͬͯ͸ͪΒͭ͘͜ͱ͕͋Δ ➤ Ctrl-CΛແޮʹ͢Δʹ͸Ͳ͏ͨ͠Β͍͍? ➤ etc. ➤ ΋ͬͱ͍͍ํ๏͸͋Δ͸ͣͳͷͰɺՋͳͱ͖ʹνϟϨϯδ͠·͠ΐ͏(2ճ໨)

Slide 45

Slide 45 text

SLίϚϯυ൪֎ฤ(1) lsʹࣅͨΦϓγϣϯ΋ଘࡏ͢Δ ➤ $ sl -a
 HELP! ➤ $ sl -F
 ඈΜͩʂ ➤ $ sl -l
 ͪͬ͞ʂ ➤ $ sl -c
 C51ͩʂ(Α͘஌Βͳ͍) ➤ $ sl -aFlc
 શ෦৐ͤʂ

Slide 46

Slide 46 text

SLίϚϯυ൪֎ฤ(2) ➤ slίϚϯυͷιʔείʔυ͸githubʹɻϓϧϦΫͰ͞ΒʹਐԽ ➤ վ଄൛͸΋ͬͱ͍͢͝
 ʮSL վ଄ܭըʯhttp://www.izumix.xyz/sl/
 ʢύονద༻ࡁʣhttp://qiita.com/gm_kou/items/2840a6670dc2e733d00a
 ٬ं૿΍ͨ͠Γɺ౿੾ग़͖ͯͨΓɺSL͕ԟ෮ͨ͠Γɺ଎౓͕όϥόϥͩͬͨΓ͍Ζ͍Ζ
 δϣʔΫίϚϯυͷྖҬΛ௒͑ͨ࡞඼ ➤ Gistʹ͸ژٸԽύον͕͋Δ
 https://gist.github.com/poochin/1423262
 # SL͡Όͳ͍͡ΌΜʂͱ͍͏໺฻ͳಥࠐΈ͸͝ԕྀ͍ͩ͘͞

Slide 47

Slide 47 text

3.λʔϛφϧը໘Λ
 ͙ͪΌ͙ͪΌʹ

Slide 48

Slide 48 text

λʔϛφϧը໘Λ͙ͪΌ͙ͪΌʹ ➤ ANSIΤεέʔϓγʔέϯεΛ࢖͏͜ͱͰɺจࣈʹ৭Λ͚ͭͨΓɺഎܠ৭Λม͑ͨΓ ͕Ͱ͖Δ ➤ ͜ΕΛར༻ͯ͠ɺը໘Λ͙ͪΌ͙ͪΌʹ͢Δ͜ͱ͕Մೳ

Slide 49

Slide 49 text

എܠ৭Λม͑ΔANSIΤεέʔϓγʔέϯε ➤ എܠ৭Λม͑ΔΤεέʔϓγʔέϯε(جຊ8৭)
 ESC[ʻ40ʙ47ʼm
 40: ࠇ, 41: ੺, 42: ྘, 43: ԫ, 44: ੨, 45: Ϛθϯλ, 46: γΞϯ, 47: ന
 ※୺຤ʹΑΓ৭͸ඍົʹҟͳΔ ➤ എܠ৭Λม͑ΔΤεέʔϓγʔέϯε(256৭)
 ESC[48;5;ʻ৭൪߸ʼm
 48: ֦ுഎܠ৭; 5: 256৭ΠϯσοΫεΧϥʔ; ৭൪߸: 0ʙ255Λࢦఆ ➤ ΤεέʔϓγʔέϯεͷϦηοτίʔυ (͜Ε͕ͳ͍ͱ৭͕Ϧηοτ͞Εͳ͍)
 ESC[0m

Slide 50

Slide 50 text

➤ echoίϚϯυͰ͸"\e"Λ࢖͏
 
 
 
 ※"\e"Λೝࣝ͠ͳ͍؀ڥ΋͋Δ ➤ printfίϚϯυͰ͸"\033"Λ࢖͏ $ printf "\033[45m%s\033[0m\n" Ϛθϯλ ANSIΤεέʔϓγʔέϯε෇͖Ͱදࣔ Ϛθϯλ $ echo -e “\e[46mγΞϯ\e[0m] γΞϯ

Slide 51

Slide 51 text

λʔϛφϧը໘͙ͪΌ͙ͪΌɹ˞௿଎ $ clear; while :; do c=`expr $RANDOM % 256`; echo -en "\e[48;5;$ {c}m \e[0m"; done

Slide 52

Slide 52 text

λʔϛφϧը໘͙ͪΌ͙ͪΌɹվྑ൛ ➤ echo
 
 
 ➤ printf
 
 
 
 ※ൈ͚Δʹ͸sleep 500Λফ͔͢Ctrl+CͰ $ clear; for color in `od -vAn -tu1 -N $(($COLUMNS*$LINES)) < /dev/urandom` ; do echo -en "\e[48;5;${color}m \e[0m"; done; sleep 500 $ clear; for color in `od -vAn -tu1 -N $(($COLUMNS*$LINES)) < /dev/urandom` ; do printf "\033[48;5;${color}m \033[0m"; done; sleep 500

Slide 53

Slide 53 text

ղઆ 1. 0ʙ255·Ͱͷཚ਺Λऔಘ
 odͱ/dev/urandomΛ࢖༻͢Δ
 $ od -vAn -tu1 -N 1 < /dev/urandom
 15 2. ୺຤ͷը໘͍ͬͺ͍ʹͳΔΑ͏ʹɺܻ਺ * ߦ਺ճ͚ͩཚ਺Λऔಘ͢Δ
 $ od -vAn -tu1 -N $(($COLUMNS*$LINES)) < /dev/urandom
 241 178 43 211 3 255 29 178 181 247 234 112 157 18 152 29 3. ΤεέʔϓγʔέϯεͰ৭Λม͑ͤ͞Δ
 $ echo -en “\e[48;5;${color}m \e[0m”
 $ printf “\033[48;5;${color}m \033[0m” 4. 2.ͰٻΊͨ݁ՌΛforͰճͤ͹׬੒

Slide 54

Slide 54 text

·ͱΊ ➤ ಥવͷࢮδΣωϨʔλʔͱslίϚϯυͳͲΛϫϯϥΠφʔͰ࣮ݱ ➤ awkͷ൚༻ੑ͸෠Εͳ͍ ➤ δϣʔΫίϚϯυΛγΣϧܳͰ࣮ݱͤ͞Δͷ͸ָ͍͠ ➤ ΋ͬͱ͍͍ํ๏͸͋Δ͸ͣͳͷͰɺՋͳͱ͖ʹνϟϨϯδ͢Δͷ΋Α͍ͱࢥ͍·͢