ããããã¹ãŠå§ãŸã£ãæ¹æ³
ããã¯ãã¹ãŠæ lazããå§ãŸããŸããã æ azineã¯çç£çã§ãããç§ã®å Žåãããã§ã¯ãªãããã§ã-æåã
æè¿ãNassim Talebã®ãLitresãã«é¢ããæ¬ãAnti-Fragilityããè³Œå ¥ããŸããã ç§ã¯ãããããŠã³ããŒãããèªæžå®€ã«æããŸããããç§ã¯ãããæã«å ¥ããŸããã§ããããã®åŸã劻ã圌女ããã©ãã°ããŠèªãã ããåäŸãé£ãããããŸã...ãããŠããã®èšäºã¯ãã¥ãŒã¹ã¬ã¿ãŒã§é£ã³ãŸããã çŸããã«ããŒãäœããŸã ã ã èŠããšããããã¹ãŠãçŸããããã«èŠããŸããããFortochkiããæèŒããè»ã¯æå ã«ãããŸãããç§ãã¡ã¯ãããã䜿çšãããã¯ã€ã³ãQemuã®ãããªã¬ã¹ã±ãããéããŠãããã®WordPageãå®è¡ããã®ã¯å°ãäžå¿«ã§ãã ããããç§ã¯æ¬ãå°å·ããŠãéåžžã®æ¹æ³ã§ïŒç§ãäœãã§ãã家ã®1éã®ããå°å·æ©ã§ïŒåžæã®åœ¢åŒã«åãåãããšãã§ããŸãã ããã¯ãæå ã®æ段ã䜿çšããå¿ èŠãããããšãæå³ããŸãã
ã¢ã€ãã¢
ç§ã®ãªãã£ã¹ã§ã¯ãå幎éãå°ããªbashã¹ã¯ãªããã䜿çšããŠãç°ãªãPDFããã¯ããŒã ããŸãšããŠããããžã§ã¯ãææžã®åäžã®æ§é ã圢æããŠããŸãã ãããã£ãŠãã¹ãã¢ããŒãã®åè£ã¯1ã€ã§ãã
å®éã«ã¯ã4ã®åæ°ã§ããä»»æã®ããªã¥ãŒã ã®ããŒãããã¯ã«ç¹å®ã®ã·ãŒã±ã³ã¹ã§åå¥ã®ããŒãžãã¬ã€ã¢ãŠããããšããã¢ã€ãã¢ã§ããã泚ææ·±ãèŠããšã1ã€ã®ããŒãããã¯ã·ãŒãã«ã¯3ã€ãŸãã¯5ã€ã§ã¯ãªãæ£ç¢ºã«4ã€ã®ããŒãžãå«ãŸããŠãããããŒãžã¯ã·ãŒãäžã§ç¹å®ã®é åºã§é 眮ãããŠããŸããç§ã¯åŸã§ãããçµããŸããããä»ã®ãšããããã¯ãã®ãŸãŸã§ãããããªãã¡ïŒ48ããŒãžã®ããŒãããã¯çšïŒïŒ
ããŒãžã㢠| äžæ¯ |
---|---|
1-48 | m =ïŒ1ïŒn =ïŒ48ïŒ |
2-47 | m =ïŒ1 + 1ïŒn =ïŒ48-1ïŒ |
3-46 | m =ïŒ1 + 2ïŒn =ïŒ48-2ïŒ |
... | ... |
24-25 | m =ïŒ1 + 23ïŒn =ïŒ48-23ïŒ |
ããã¯ããŸããæ¬ãiããŒãžã«åå²ãã次ã«åkããŒãžã®jåã®ããŒãããã¯ã«åå²ãã次ã«åããŒãããã¯ãã·ãŒãã«é 眮ã§ããããŒãžã®ãã¢ã«åå²ããŠãåäžã®ããŒãããã¯ãã¡ã€ã«ã«ãŸãšããããšãã§ããããšãæå³ããŸãã PDFããã¯ããŒã ã ãããããŠæ確ãª...
äžè¬çã«ãäŸåé¢ä¿ã¯åçŽã§ãã·ãŒãã®æåã®ããŒãžã¯a + bãæåŸã¯kbã§ããaã¯ããŒãããã¯ã®ã·ãªã¢ã«çªå·ã§ã0 <a <jãbã¯ãã¢ããŒãžã®ã·ãªã¢ã«çªå·ã0 <b <k / 2ã ã€ãŸã ããã¯forã«ãŒãïŒïŒb = 0; b <k / 2; b ++ïŒïŒã§ãããããã¹ãŠã®ããŒãžãåŠçããå¿ èŠããããŸãã
ãã®ããŒãããã¯ãforããŒãããã¯ïŒïŒa = 0; a <j; a ++ïŒïŒãä»ããŠå®è¡ããå¥ã®ãµã€ã¯ã«ã«è©°ã蟌ã¿ãŸã ã
次ã«ãGhostScriptããã±ãŒãžãImageMagicããã±ãŒãžãdjvulibreããã±ãŒãžãããã³bashãšLinuxã®çµã¿èŸŒã¿ã³ãã³ãã䜿çšããŸãã
解決ã®éçšã§ãã³ãŒãã®äžéšãå¥ã ã®é¢æ°ã«å ¥ããbashã§ãã¹ãŠãå®å šã«åå²ããæ¹ãè¯ãããšãå€æããŸãããã€ãŸããæ®ãã®ããŒãžã®ã¢ã»ã³ããªãæŽç·Žããå¿ èŠããããŸãã
echo "ã¡ã€ã³ã»ããã®ããŒãžã®çµã¿ç«ãŠãå®äºããŸãããããã§ãè¿œå ã®ããŒãããã¯ãçµã¿ç«ãŠãããšãã§ããŸãã" ã¬ãããŽãŒ let "LAST_W_BOOK = $ W_BOOK + 1"ïŒæåŸã®ããŒãããã¯ã®çªå·ã瀺ãå€æ°ãäœæãã if ["` expr $ TAIL_PAGESïŒ 4` "-eq" 0 "]ïŒæåŸã®ããŒãããã¯ã®ããŒãžæ°ã4ã®åæ°ã§ããå Žå ãããã echoããã¹ãŠãæ£åžžã§ããæåŸã®ããŒãããã¯ãäœæãç¶ããŸãã ã¢ã»ã³ããª$ LAST_W_BOOK $ TAIL_PAGES elseïŒæåŸã®ããŒãããã¯ã®ããŒãžæ°ã4ã®åæ°ã§ãªãå Žå echo "ããŒãããã¯ããããŸãã` expr 4-$ TAIL_PAGESïŒ 4` pagesïŒsïŒ " echo "ããããè¿œå ããå¿ èŠããããŸããæåã§è¿œå ããããããã°ã©ã ã«ãããå®è¡ãããããšãã§ããŸãã" ã¬ãããŽãŒ ïŒå¿ èŠãªæ°ã®ç©ºã®ãã¡ã€ã«ãè¿œå ããŠãããã¢ã»ã³ããªãç¶è¡ããŸã fi
ã¹ããã¯ã®å Žåãã·ãŒãäžã®ããŒãžã®é åºã¯äžã®ãã¬ãŒãã®é åºãšãŸã£ããåãã§ã¯ãªãããšãå€æããŸããããããã¯æ¬¡ã®ãšããã§ãã
ããŒãžã㢠| äžæ¯ |
---|---|
48-1 | n =ïŒ48ïŒm =ïŒ1ïŒ |
2-47 | m =ïŒ1 + 1ïŒn =ïŒ48-1ïŒ |
46-3 | n =ïŒ48-2ïŒm =ïŒ1 + 2ïŒ |
... | ... |
ããã¯éåžžã«åçŽã«æ±ºå®ããããã®ã§ãã
if ["` expr $ bïŒ 2` "-gt" 0 "] thenïŒããŒãžã®ãã¢ãå¥æ°ã®å Žå $ ba first.bmpãæœåºããŸã $ bb second.bmpãæœåºããŸã echo "$ ba-$ bbããŒãžã眮ã" elseïŒããŒãžã®ãã¢ãå¶æ°ã®å Žå $ bb first.bmpãæœåºããŸã $ ba second.bmpãæœåºããŸã echo "$ bb-$ baããŒãžã眮ã" fi
å ã®PDFããã¯ããŒã ããããŒãžãæœåºããããã«ãGhostScriptãã³ãã³ããšããŠäœ¿çšãããŸããã
gs -q -sDEVICE = bmpmono -r $ DPI -dFirstPage = $ 1 -dLastPage = $ 1 -sOutputFile = "$ TMP_DIR / $ 2" -dNOPAUSE -dBATCH * pdf
ç§ã®å ã®PDFããã¯ããŒã ã¯ããŒããŒã¬ã¹ã§ããããïŒèªè ã«ãšã£ãŠãã䟿å©ã§ãïŒãããŒãžã®åšå²ã«ImageMagicã®ããŒãžã³ãè¿œå ããŸããã
Convert "$ TMP_DIR / $ 2" -define bordercolor =ïŒffffff -border 10ïŒ "$ TMP_DIR / $ 2"
ããã«ãã¹ãŠãåå§çã§ãããããdjvulibreããã±ãŒãžããã°ã©ã ã䜿çšããŸãã
if ["$ b" -eq "0"] ãããã cjb2 -lossy "$ TMP_DIR / $ ba- $ bb" .pbm "$ 2" .djvu ä»ã« cjb2 -lossy "$ TMP_DIR / $ ba- $ bb" .pbm "$ TMP_DIR / $ ba- $ bb" .djvu djvm -i "$ 2" .djvu "$ TMP_DIR / $ ba- $ bb" .djvu fi
ããŒãããã¯ãã¡ã€ã«ã®æåã®ããŒãžãäœæãããµã€ã¯ã«ã®æåŸãŸã§æ®ãã®ããŒãžã«é çªã«ä»ããŠãããŸãã
ã¹ã¯ãªããèªäœ
ïŒïŒ/ bin / bash letsgoïŒïŒ{ echo "ç¶è¡ããŸããïŒïŒã¯ã/ [ããã]ïŒ" ç¶ããèªã if [-n "$ CONTINUE"] && [["$ CONTINUE" == y *]] || [["$ CONTINUE" == Y *]]ïŒè¡ã¯ç©ºã§ã¯ãªãããyããŸãã¯ãYãã§å§ãŸã ãããã§ã¯ãç¶ããŸããã...ããšãšã³ãŒããŸã ä»ã« rm -R $ TMP_DIR åºã fi } extractïŒïŒ{#FirstPageããã³LastPage = $ 1ãOutputFile = $ 2-ãã¬ãã£ãã¯ã¹ãªãïŒ gs -q -sDEVICE = bmpmono -r $ DPI -dFirstPage = $ 1 -dLastPage = $ 1 -sOutputFile = "$ TMP_DIR / $ 2" -dNOPAUSE -dBATCH * pdf convert "$ TMP_DIR / $ 2" -define bordercolor =ïŒffffff -border 10ïŒ "$ TMP_DIR / $ 2"ïŒçœãå¢çç·ãè¿œå ãã } ã¢ã»ã³ããªïŒïŒ{ sub_aïŒïŒ{ forïŒïŒb = 0; b <$ 1/2; b ++ïŒïŒdo let "ba = $ 3 + $ b"ïŒã·ãŒãã®æåã®ããŒãžã®çªå· let "bb = $ 4- $ b"ïŒã·ãŒãã®2çªç®ã®ããŒãžçªå· if ["` expr $ bïŒ 2` "-gt" 0 "] thenïŒããŒãžã®ãã¢ãå¥æ°ã®å Žå $ ba first.bmpãæœåºããŸã $ bb second.bmpãæœåºããŸã echo "$ ba-$ bbããŒãžã眮ã" elseïŒããŒãžã®ãã¢ãå¶æ°ã®å Žå $ bb first.bmpãæœåºããŸã $ ba second.bmpãæœåºããŸã echo "$ bb-$ baããŒãžã眮ã" fi å€æ+è¿œå $ TMP_DIR / first.bmp $ TMP_DIR / second.bmp "$ TMP_DIR / $ ba- $ bb" .pbm if ["$ b" -eq "0"] ãããã cjb2 -lossy "$ TMP_DIR / $ ba- $ bb" .pbm "$ 2" .djvu ä»ã« cjb2 -lossy "$ TMP_DIR / $ ba- $ bb" .pbm "$ TMP_DIR / $ ba- $ bb" .djvu djvm -i "$ 2" .djvu "$ TMP_DIR / $ ba- $ bb" .djvu fi rm "$ TMP_DIR / $ ba- $ bb" * ãã£ã } if ["$ 1" -gt "` expr $ FILE_COUNT / $ PAGES_IN_W_BOOK` "] ïŒæåŸã®ããŒãããã¯ãäœæ forïŒïŒa = 0; a <1; a ++ïŒïŒdo let "aa = $ 1"ïŒããŒãããã¯çªå· let "ab = $ FILE_COUNT / $ PAGES_IN_W_BOOK * $ PAGES_IN_W_BOOK + 1"ïŒããŒãããã¯ã®æåã®ããŒãžã®çªå· let "ac = $ FILE_COUNT"ïŒããŒãããã¯ã®æåŸã®ããŒãžã®çªå· echo "ããŒãž$ ab ... $ acã§æ§æãããããŒãããã¯$ aaããŸãšãã" sub_a $ 2 $ aa $ ab $ ac ãã£ã ãã®ä»ïŒéåžžã®å®è¡ forïŒïŒa = 0; a <$ 1; a ++ïŒïŒdo let "aa = $ a + 1"ïŒçŸåšã®ã«ãŒãã®å埩çªå·;ããã¯ããŒãããã¯ã®çªå·ã§ã let "ab = $ a * $ 2 + 1"ïŒããŒãããã¯ã®æåã®ããŒãžã®çªå· let "ac = $ a * $ 2 + $ 2"ïŒããŒãããã¯ã®æåŸã®ããŒãžã®çªå· echo "ããŒãž$ ab ... $ acã§æ§æãããããŒãããã¯$ aaããŸãšãã" sub_a $ 2 $ aa $ ab $ ac ãã£ã fi } mkdir / tmp / brochure_converterïŒäžæãã£ã¬ã¯ããªãäœæããŸã TMP_DIR = "/ tmp / brochure_converter"ïŒäžæãã£ã¬ã¯ããªãžã®ãã¹ãåæ ããå€æ°ãå²ãåœãŠã FILE_COUNT = `pdfinfo * pdf | awk '/ Pages / {print $ 2}' 'ïŒããã¥ã¡ã³ãã®ããŒãžæ°ãæ°ãã echo "1ã€ã®ããŒãããã¯ã®ããŒãžæ°ã4ã®åæ°ã§ç€ºããŸããããšãã°ã\" 8ã12ã16 \ "ãªã©ïŒ read PAGES_IN_W_BOOKïŒããŒãããã¯ã®å¯å€ããŒãžæ°ãèªã¿åããŸã let "W_BOOK = $ FILE_COUNT / $ PAGES_IN_W_BOOK"ïŒ1ã€ã®ããŒãããã¯ã®ããŒãžæ°ãèšç®ãã echo "åããŒãžã®$ PAGES_IN_W_BOOKããŒãžã®$ W_BOOKãã«ããŒãããã¯ãçæãããŸãã" let "TAIL_PAGES = $ FILE_COUNTïŒ $ PAGES_IN_W_BOOK"ïŒæåŸã®ããŒãããã¯ã®ããŒãžæ°ãèšç®ãã echo "äžå®å šãªã³ããŒããã¯ã$ TAIL_PAGESããŒãžã«æ®ã£ãŠããŸã" echo "åžæããç»å解å床ïŒDPIïŒãæå®ãããšãã°72" DPIãèªã¿åãïŒå°æ¥ã®ããã¥ã¡ã³ãã®ç»å解å床å€æ°ãå²ãåœãŠã ã¬ãããŽãŒ assembly $ W_BOOK $ PAGES_IN_W_BOOKïŒç·Žç¿åž³ã®æ°ãšããŒãžã®æ°ã®äœçœ®ãã©ã¡ãŒã¿ãããã·ãŒãžã£ã«æž¡ããŸã echo "ã¡ã€ã³ã»ããã®ããŒãžã®çµã¿ç«ãŠãå®äºããŸãããããã§ãè¿œå ã®ããŒãããã¯ãçµã¿ç«ãŠãããšãã§ããŸãã" ã¬ãããŽãŒ let "LAST_W_BOOK = $ W_BOOK + 1"ïŒæåŸã®ããŒãããã¯ã®çªå·ã瀺ãå€æ°ãäœæãã if ["` expr $ TAIL_PAGESïŒ 4` "-eq" 0 "]ïŒæåŸã®ããŒãããã¯ã®ããŒãžæ° ãããã echoããã¹ãŠãæ£åžžã§ããæåŸã®ããŒãããã¯ãäœæãç¶ããŸãã ã¢ã»ã³ããª$ LAST_W_BOOK $ TAIL_PAGES ä»ã« echo "ããŒãããã¯ããããŸãã` expr 4-$ TAIL_PAGESïŒ 4` pagesïŒsïŒ " echo "ããããè¿œå ããå¿ èŠããããŸããæåã§è¿œå ããããããã°ã©ã ã«ãããå®è¡ãããããšãã§ããŸãã" ã¬ãããŽãŒ ïŒå¿ èŠãªæ°ã®ç©ºã®ãã¡ã€ã«ãè¿œå ããŠãããã¢ã»ã³ããªãç¶è¡ããŸã fi rm -R $ TMP_DIR
åé¡
gs -q -sDEVICE = bmpmono -r2x2 -sOutputFile = $ TMP_DIR /ïŒ d.bmp -dNOPAUSE -dBATCH * pdfïŒPDFããããŒãžãäœè§£å床ã§æœåº FILE_COUNT = `ls -l $ TMP_DIR / * bmp | grep ^-| wc -l`ïŒãã£ã¬ã¯ããªå ã®ãã¡ã€ã«æ°ãã«ãŠã³ãããããšã«ãããããã¥ã¡ã³ãå ã®ããŒãžæ°ãã«ãŠã³ãããŸã
klirichekã«æè¬ããŸããçŸåšã¯æ¬¡ã®ããã«ãªã£ãŠããŸãã
FILE_COUNT = `pdfinfo * pdf | awk '/ Pages / {print $ 2}' '
ãããã«
ã¹ã¯ãªããã¯æªå å·¥ã§ãã 4ã®åæ°ã§ã¯ãªãããŒãžæ°ãå«ãPDFããã¯ããŒã ã®åŠçã¯å®äºããŠããŸãã; Chukchiãèªè ã§ãããããæåã«ããã«å ¬éããã€ããã¯ãããŸããã§ããã
ã* pdfããšæžãããŠããŸãããã³ãã³ãã©ã€ã³ããã®èµ·åãšäžé£ã®ãã¡ã€ã«ã®ãããåŠçãå«ãèµ·åãè¿œå ããäºå®ã§ãã
æåã®çµéšã¯ãããŸã蹎ããªãã§ãã ããã
ã¢ã€ãã¢ãšä¿®æ£ãäºåã«ããããšãããããŸãã