matplotlibã®ã°ã©ããã¤ã³ã¿ã©ã¯ãã£ããªã¾ã¾ä¿åãã
savefig() ã§ç»åã«ä¿åãã¡ããã¨ãç©å½¢æ¡å¤§ã¨ããã§ããªããã
show() ãã¡ããã¨éãããæ¶ãããã¤ã³ã¿ã©ã¯ãã£ããªã¾ã¾ä¿åã§ãããããã®ã«ã¨æã£ã¦èª¿ã¹ã¦ã¿ãã
https://stackoverflow.com/questions/4348733/saving-interactive-matplotlib-figures
https://stackoverflow.com/questions/29160177/matplotlib-save-file-to-be-reedited-later-in-ipython
MATLABã«ã¯ããããæ©è½ãæ¢ã«ããã¿ããã§ãããã¾ã欲ãããªãããã
matplotlibã®å ´åãfigureãªãã¸ã§ã¯ããpickleã§ä¿åããã°ããã¿ããã§ãã
æ¥æ¬èªã§ãæ
å ±ããã¾ããããã®ã¨ã³ããªãæ¸ãæå³ãã»ã¨ãã©ç¡ããªã£ã¦ãã¾ã£ãã
http://kuroneko0208.hatenablog.com/entry/2014/07/28/161453
ããããã¡ã¤ã«ãä½ã£ã¦ããã¦ãpickleãã¡ã¤ã«ãæ¾ãè¾¼ãã°ããã«è¦ãããã¿ãããªæãã«ãã¦ããã°ããã®ããªã¼ã
pngã§ãpickleã§ãä¿åãã¦ããã¦ãä¸èº«ã詳ããè¦ãããªã£ããã¤ã³ã¿ã©ã¯ãã£ãã¢ã¼ãã§ãè¦ããã¿ãããªå½¢ã«ãã¦ããã¨ä¾¿å©ããª
ä¿åããå´
#! /usr/bin/python2.7 # coding: utf-8 import matplotlib.pyplot as plt import pickle xs = range(10) ys = [x**2 for x in xs] fig = plt.figure() ax = fig.add_subplot(111) ax.plot(xs, ys) #plt.show() with open('figure_image.pkl', 'wb') as ofs: pickle.dump(fig, ofs)
表示ããå´
#! /usr/bin/python2.7 # coding: utf-8 import matplotlib.pyplot as plt import pickle import sys filename = 'figure_image.pkl' if len(sys.argv) > 1: filename = sys.argv[1] with open(filename) as ifs: fig = pickle.load(ifs) plt.show()
rem plt_viewer.bat cd %~dp0 python plt_viewer.py %1
pickleãã¡ã¤ã«ããã©ãã°ï¼ããããã§æ¾ãè¾¼ãã¨ãã°ã©ããpickleã§ãªã¹ãã¢ãã¦è¡¨ç¤ºããã
Seleniumã®ChromeDriverãèªåæ´æ°ããbashã¹ã¯ãªãã
Seleniumã®å¦çã§ã¨ã©ã¼ãåºã¦ãããchromeã®webdriverãæ´æ°ããã¦ãããã¨ã«æ°ãã¤ãã¦ãã¡ã¤ã«ãç½®ãæãããã¨ããã®ãä½åº¦ãç¹°ãè¿ãã¦ã¦ã³ã¶ãªãã¦ããã®ã§èªååãããã¨ã«ãã¾ããã
ã¹ã¯ãªãããcronçã«ä»æãã¦ããã°ã常ã«ææ°ã®chromedriverãèµ·åãããããã«ã§ãã¾ãã
åæã¨ãªããã£ã¬ã¯ããªæ§æ
/home/username/bin/ ... ã¦ã¼ã¶ã¼usernameã®ãã¼ã ãã£ã¬ã¯ããªé ä¸ã®binããããããä½æãã¦ããã
selenium-chromedriver/ ... chromedriverã®åãã¼ã¸ã§ã³ãä¿æãããã£ã¬ã¯ããªããããããä½æãã¦ããã
2.27/ ... chromedriverã®ãã¼ã¸ã§ã³ãèªåã§ä½æãããã
chromedriver ... chromedriverã®å®è¡å¯è½ãã¡ã¤ã«ãèªåã§ä½æãããã
2.28/
chromedriver
X.XX/
chromedriver
chromedriver ... ææ°ã®chromedriverãã¤ããªã¸ã®ã·ã³ããªãã¯ãªã³ã¯ãèªåã§ä½æã»æ´æ°ãããã
Python2/3ã§gmailããã¡ã¼ã«ãéä¿¡ãã(gmailã©ã¤ãã©ãªä½¿ç¨ç·¨)
ã¨ã³ããªPython2.7ã§GMailããæ¥æ¬èªã¡ã¼ã«ãéä¿¡ããã§ã¯ããã¹ãã¡ã¼ã«ãéããã¹ã¯ãªãããæ¸ãã¾ããããHTMLã¡ã¼ã«ã ã¨ãæ·»ä»ãã¡ã¤ã«ã¯ã¤ããããªãã®ã§ãããã«ä¸æºãã§ã¦ããã¨æãã¾ããã¨ãããåºã¦ãã¾ãããæå ã§ã¯é½åº¦å°ãã¥ã¤æ¹é ãã¦ä½¿ã£ã¦ãã¾ãããã©ã¤ãã©ãªã使ãã®ãå¹çãè¯ãã¨æãã¾ãã
ã¨ãããã¨ã§ãPyPIã"gmail"ã§æ¤ç´¢ãã¦ä¸çªã«åºã¦ããã©ã¤ãã©ãªã使ã£ã¦ã¿ã¾ãããgmailã¨ããååã§ããç´çã§ããã
ã¤ã³ã¹ãã¼ã«æ¹æ³
pip install gmail
Pythonã§pickleã使ã£ã¦æ°¸ç¶åãããæéä»ãã¡ã¢åãã³ã¬ã¼ã¿
æ¢ã¾ã£ã¡ããããã°ã©ã ã®å¿æ¥å¦çã¨ãã¦ãpickleã§ãã£ãã·ã¥ãæ°¸ç¶åããã¡ã¢åé¢æ°ãæ¸ããã®ã§ã¤ãã§ã«gistã«ããã¾ããããã¤ãã¾ã使ãæ°ãããã
ã¡ã¢åããé¢æ°ãã³ã¼ã«ããã¯é¢æ°ãåãåãã¿ã¤ãã®é¢æ°ã ã£ãã®ã§ããã£ãã·ã¥ã®ãã¼ãä½ã段éã§é¢æ°åã®æååã«ç½®ãæãã¡ãã£ã¦ã¾ãã
windowsã§xargs -Pãããã
windowsã§xargs -P 10 -n 2ã¿ãããªãã¨ããããã£ãã®ã§ããã
- powershellã¨ãã§ã¯ãããããã¨ãã§ããªããã
- cygwinã¯å ¥ããããªã
ã¨ãããã¨ã§èªåã§å®è£
ãããã¨ã«ãã¾ããã
æä½éå¿
è¦ãª-P(--max-procs) -n(--max-args) {}(ãã¬ã¼ã¹ãã«ã)ã¯å®è£
ããã¦ã¾ãã
ããã§ä¸¦åå®è¡ããããã¨ã§7åæãã£ã¦ãå¦çã3åã«ãªãã¾ããã
multiprocessingã¯æ¬å½ã«ä¾¿å©ã
python pipã§ã¤ã³ã¹ãã¼ã«ç¨ãã¡ã¤ã«ããã¼ã«ã«ã«ä¿åãã¦ãã
ã¢ããªã±ã¼ã·ã§ã³ãå¥ã®ãµã¼ãã¼ã«è¼ãæ¿ãããçã®çç±ã§ãã¤ã³ã¹ãã¼ã«ããã¦ããpythonããã±ã¼ã¸ããå¥ã®ãã·ã³ã¸å±éããããã¨ãããã¾ãã
ããããæpipãªããpip freezeã§ããã±ã¼ã¸åã¨ãã¼ã¸ã§ã³ã®ä¸è¦§ãåºåãã¦ãä»ãã·ã³ã§ãã®ä¸è¦§ãå
ã«installããã¨ç°¡åã§ãã
[HOST A]$ pip freeze > /nas/pip/requirements.txt [HOST A]$ cat /nas/pip/requirements.txt BeautifulSoup==3.2.1 Flask==0.10.1 Jinja2==2.7.3 ... terminado==0.5 toolz==0.7.1 tornado==4.1 wheel==0.24.0 [HOST B]$ pip install -r /nas/pip/requirements.txt
ããããããã ã¨freezeã§ä¸è¦§ã«ããå¾ã«ãã©ã¤ãã©ãªã®ç¹å®ã®ãã¼ã¸ã§ã³ãå
¬éåæ¢ããããããããã¯ã©ã¤ãã©ãªèªä½ã
å
¬éåæ¢ãããã¨ããã¾ãå±éã§ããªããªãããä¸é¨ã®æ©è½ãåããªãï¼ã¨ããå¤ã«åãããããï¼ã¯ãã
ããã ã¨å°ãã®ã§ãä»ã®ç¶æ
ã§ãäºãä¾åããã©ã¤ãã©ãªãå«ããå
¨ã¦ãã¼ã«ã«ã«ä¿åãã¦ããããã
ãããPyPIããä¸ã¤ä¸ã¤è½ã¨ãã¦ããã®ãæéã§ãã
ããããã¨ãã«ä¾¿å©ãªã³ãã³ãã¯ç¡ãã®ãâ¦
installã³ãã³ãã«--downloadã¨ãããªãã·ã§ã³ãããã¾ããã
æå®ããã¨ãã¤ã³ã¹ãã¼ã«ç¨ã®.tar.gzã.whlãã¡ã¤ã«ããã©ã«ãã«æ¾ãè¾¼ãã§ããã¾ãã
ãã¦ã³ãã¼ãã¾ã§ã§ãã¤ã³ã¹ãã¼ã«ã¯ããã¾ãããããã§ä»ããpythonç°å¢ããã¼ã«ã«ã«è½ã¨ãã¦ããã¾ãã
[HOST A]$ pip freeze > /nas/pip/requirements.txt [HOST A]$ pip install --download /nas/pip/archive -r /nas/pip/requirements.txt
ãã¨ã¯å±éãããå´ã§ãã®ãã©ã«ããåç §ãã¦pip installããã°OKã§ãã
[HOST B]$ pip install --no-index --find-links=file:///nas/pip/archive -r /nas/pip/requirements.txt ...(ç¥) Collecting wheel==0.24.0 (from -r ..\requirements.txt (line 34)) Installing collected packages: pyquery, pytz, pyzmq, redis, requests, selenium, tornado, terminado, toolz, wheel Running setup.py install for pyquery Running setup.py install for redis Running setup.py install for selenium Running setup.py install for tornado Running setup.py install for terminado Running setup.py install for toolz Successfully installed pyquery-1.2.9 pytz-2014.10 pyzmq-14.6.0 redis-2.10.3 requests-2.5.1 selenium-2.44.0 terminado-0.5 toolz-0.7.1 tornado-4.1 wheel-0.24.0
ãªããcx_Oracleã¨ãscipyã¨ãpylzmaã¨ãã®Cæ¡å¼µãå«ã¾ããå ´åã¯ãé¢é£ããã³ã³ãã¤ã©ãªã©ãæã£ã¦ããå¿
è¦ãããæ°ããã¾ãã
ãã¨ãpip以å¤ããããã±ã¼ã¸ãã¤ã³ã¹ãã¼ã«ãã¦ããå ´å(aptã¨ãyumã§å
¥ãã¦ãå ´å)ãå½ç¶ããã§ã¯å±éã§ããªãã®ã§è¦æ³¨æã§ãã
â»pip 1.5.6(python2.7)ã§åä½ç¢ºèªãã¦ã¾ãã
åèï¼
User Guide â pip 6.1.1 documentation
How to use Python's pip to download and keep the zipped files for a package? - Stack Overflow
Project Eulerã®æ¥æ¬èªè¨³ã¸ã®ãªã³ã¯ãå¼µãuser scriptï¼2015/4/30æç¹ï¼
Project Eulerã®æ¥æ¬èªè¨³ã¸ã®ãªã³ã¯ãå¼µãuser scriptãæ´æ°ãã¾ããã
Chrome 42.0.2311.90 m
Tampermonkey 3.10.84
ã§åä½ç¢ºèªãã¦ã¾ãã
// ==UserScript== // @name ScriptEuler // @namespace http://d.hatena.ne.jp/yatt/ // @description link euler project problem to http://odz.sakura.ne.jp/ // @include https://projecteuler.net/archives* // ==/UserScript== (function(){ var lst = document.getElementsByClassName('id_column') var prefix = 'http://odz.sakura.ne.jp/projecteuler/index.php?cmd=read&page=Problem%20' for (var i = 1 ; i < lst.length; i++) { var no = lst[i].innerHTML var a = document.createElement('a') a.href = prefix + no a.innerText = no lst[i].innerText = '' lst[i].appendChild(a) } })()
é¢é£