• 最近用 json_encode 儲存計算結果,因為計算結果有浮點數,就發現了神奇的現象。
    要儲存的資料是
    value = 3.36,但是透過 json_encode 之後,存進檔案竟然變成
    {"value": 3.3599999999999999}
    研究了一下發現,原來是 json_encode 預設採用 IEEE 754 的方式儲存,所以就 QQ 了~~
    要解決這個方法很簡單,只需要調整 php.ini
    把 serialize_precision 設為 -1 即可
    serialize_precision = -1
    或是透過 ini_set
    ini_set("serialize_precision","-1");
    也可以喔~~~
    PHP | 2193 觀看 | 2018-09-10 | 洪國恩 上傳
  • 353ecd01bfba00ae0eeccd8e693a8027.png開發網頁時,其實常常遇到 JS 無法執行。原因是因為透過 Line, WeChat 等等 IM 工具將連結發出去。雖然達到推廣效果,但卻常常因為部分功能沒有啟用 (像是 localStorage 等),造成 script error... 
    所以最好先判斷是否在 Webview 中,避免悲劇發生。
     
    這個 NPM library, https://www.npmjs.com/package/is-webview, 還不錯用,簡單輕巧。
     
    如果需要在當作一般 Js 使用,可以用附件 (is-webview.js),在 window 直接註冊了 isWebView(),呼叫後就會回傳 true / false 囉~~
     
     
    JavaScript | 2111 觀看 | 2018-08-22 | Kuann Hung 上傳
  • 4792d6bd5aa7c5992ed58d0828bb88c4.jpg
    Nginx 是一套相當強悍又好用的伺服器,特別在 reverse proxy 或是 load balancce 的使用上,都非常的方便好用。
    但一般都是用在 web 方便的應用較多。如果是其他服務,其實可以透過 nginx_tcp_proxy_module  達到代理或是 Load balance 的目的喔!!~
    Linux | 4215 觀看 | 2018-08-13 | Kuann Hung 上傳
  • 先來個最基本的 TensorFlow 實作
    869c27393f454e42406f2e55a5b2a34a.png
    這個範例是把圖片根據 "目錄名稱" 分類好,透過 retrain.py 來訓練,訓練後的結果會存在 output_graph.pb 跟 output_labels.txt 中,可以隨時調用。
     
     
    TensorFlow | 1889 觀看 | 2018-08-02 | Kuann Hung 上傳
  • 這是個滿方便的網站,如果需要繁簡互轉,而且包含一些用法轉換的話,像是 "資料庫" 會轉換成 "数据库"。
    好用又方便喔~ (如果文字太多就需要下載程式自行手動執行喔!~
     
     
    9885c017eeab09d1e94028e5099bb4dc.png
    Web 相關 | 2104 觀看 | 2018-07-31 | 洪國恩 上傳
  • 環境: CentOS 7
    Python 版本:python-3.5
    TensorFlow 版本: tensorflow-1.5.0
     
    pip install --ignore-installed --upgrade tensorflow
    OR (如果你有強大的 GPU 的話)
    pip install --ignore-installed --upgrade tensorflow-gpu
    輸出還滿多的,紀錄一下
    Collecting tensorflow
      Downloading https://files.pythonhosted.org/packages/c6/0e/8af18d9169ed4f1a1c72cd50defd95b8382a12f2cf7cb9b76ba053db79ad/tensorflow-1.8.0-cp27-cp27mu-manylinux1_x86_64.whl (49.1MB)
        100% |████████████████████████████████| 49.1MB 5.4kB/s
    Collecting protobuf>=3.4.0 (from tensorflow)
      Downloading https://files.pythonhosted.org/packages/27/e7/bf96130ebe633b08a3913da4bb25e50dac5779f1f68e51c99485423f7443/protobuf-3.6.0-cp27-cp27mu-manylinux1_x86_64.whl (7.1MB)
        100% |████████████████████████████████| 7.1MB 120kB/s
    Collecting astor>=0.6.0 (from tensorflow)
      Downloading https://files.pythonhosted.org/packages/b2/91/cc9805f1ff7b49f620136b3a7ca26f6a1be2ed424606804b0fbcf499f712/astor-0.6.2-py2.py3-none-any.whl
    Collecting backports.weakref>=1.0rc1 (from tensorflow)
      Downloading https://files.pythonhosted.org/packages/88/ec/f598b633c3d5ffe267aaada57d961c94fdfa183c5c3ebda2b6d151943db6/backports.weakref-1.0.post1-py2.py3-none-any.whl
    Collecting wheel (from tensorflow)
      Downloading https://files.pythonhosted.org/packages/81/30/e935244ca6165187ae8be876b6316ae201b71485538ffac1d718843025a9/wheel-0.31.1-py2.py3-none-any.whl (41kB)
        100% |████████████████████████████████| 51kB 931kB/s
    Collecting mock>=2.0.0 (from tensorflow)
      Downloading https://files.pythonhosted.org/packages/e6/35/f187bdf23be87092bd0f1200d43d23076cee4d0dec109f195173fd3ebc79/mock-2.0.0-py2.py3-none-any.whl (56kB)
        100% |████████████████████████████████| 61kB 679kB/s
    Collecting enum34>=1.1.6 (from tensorflow)
      Downloading https://files.pythonhosted.org/packages/c5/db/e56e6b4bbac7c4a06de1c50de6fe1ef3810018ae11732a50f15f62c7d050/enum34-1.1.6-py2-none-any.whl
    Collecting gast>=0.2.0 (from tensorflow)
      Downloading https://files.pythonhosted.org/packages/5c/78/ff794fcae2ce8aa6323e789d1f8b3b7765f601e7702726f430e814822b96/gast-0.2.0.tar.gz
    Collecting termcolor>=1.1.0 (from tensorflow)
      Downloading https://files.pythonhosted.org/packages/8a/48/a76be51647d0eb9f10e2a4511bf3ffb8cc1e6b14e9e4fab46173aa79f981/termcolor-1.1.0.tar.gz
    Collecting absl-py>=0.1.6 (from tensorflow)
      Downloading https://files.pythonhosted.org/packages/57/8d/6664518f9b6ced0aa41cf50b989740909261d4c212557400c48e5cda0804/absl-py-0.2.2.tar.gz (82kB)
        100% |████████████████████████████████| 92kB 797kB/s
    Collecting six>=1.10.0 (from tensorflow)
      Downloading https://files.pythonhosted.org/packages/67/4b/141a581104b1f6397bfa78ac9d43d8ad29a7ca43ea90a2d863fe3056e86a/six-1.11.0-py2.py3-none-any.whl
    Collecting tensorboard<1.9.0,>=1.8.0 (from tensorflow)
      Downloading https://files.pythonhosted.org/packages/4d/1e/3bfb48ff165e331c0c5fdca5de79d497fa5d71f3cb2eee2733ff22e898df/tensorboard-1.8.0-py2-none-any.whl (3.1MB)
        100% |████████████████████████████████| 3.1MB 183kB/s
    Collecting grpcio>=1.8.6 (from tensorflow)
      Downloading https://files.pythonhosted.org/packages/1d/0d/146582f71161a0074dda2378617ae5f7e2c3d6cf62d4588eb586c1d6b675/grpcio-1.12.1-cp27-cp27mu-manylinux1_x86_64.whl (8.9MB)
        100% |████████████████████████████████| 8.9MB 73kB/s
    Collecting numpy>=1.13.3 (from tensorflow)
      Downloading https://files.pythonhosted.org/packages/6a/a9/c01a2d5f7b045f508c8cefef3b079fe8c413d05498ca0ae877cffa230564/numpy-1.14.5-cp27-cp27mu-manylinux1_x86_64.whl (12.1MB)
        100% |████████████████████████████████| 12.1MB 86kB/s
    Collecting setuptools (from protobuf>=3.4.0->tensorflow)
      Downloading https://files.pythonhosted.org/packages/7f/e1/820d941153923aac1d49d7fc37e17b6e73bfbd2904959fffbad77900cf92/setuptools-39.2.0-py2.py3-none-any.whl (567kB)
        100% |████████████████████████████████| 573kB 318kB/s
    Collecting funcsigs>=1; python_version < "3.3" (from mock>=2.0.0->tensorflow)
      Downloading https://files.pythonhosted.org/packages/69/cb/f5be453359271714c01b9bd06126eaf2e368f1fddfff30818754b5ac2328/funcsigs-1.0.2-py2.py3-none-any.whl
    Collecting pbr>=0.11 (from mock>=2.0.0->tensorflow)
      Downloading https://files.pythonhosted.org/packages/b3/5d/c196041ffdf3e34ba206db6d61d1f893a75e1f3435699ade9bd65e089a3d/pbr-4.0.4-py2.py3-none-any.whl (98kB)
        100% |████████████████████████████████| 102kB 466kB/s
    Collecting bleach==1.5.0 (from tensorboard<1.9.0,>=1.8.0->tensorflow)
      Downloading https://files.pythonhosted.org/packages/33/70/86c5fec937ea4964184d4d6c4f0b9551564f821e1c3575907639036d9b90/bleach-1.5.0-py2.py3-none-any.whl
    Collecting futures>=3.1.1; python_version < "3" (from tensorboard<1.9.0,>=1.8.0->tensorflow)
      Downloading https://files.pythonhosted.org/packages/2d/99/b2c4e9d5a30f6471e410a146232b4118e697fa3ffc06d6a65efde84debd0/futures-3.2.0-py2-none-any.whl
    Collecting markdown>=2.6.8 (from tensorboard<1.9.0,>=1.8.0->tensorflow)
      Downloading https://files.pythonhosted.org/packages/6d/7d/488b90f470b96531a3f5788cf12a93332f543dbab13c423a5e7ce96a0493/Markdown-2.6.11-py2.py3-none-any.whl (78kB)
        100% |████████████████████████████████| 81kB 344kB/s
    Collecting werkzeug>=0.11.10 (from tensorboard<1.9.0,>=1.8.0->tensorflow)
      Downloading https://files.pythonhosted.org/packages/20/c4/12e3e56473e52375aa29c4764e70d1b8f3efa6682bef8d0aae04fe335243/Werkzeug-0.14.1-py2.py3-none-any.whl (322kB)
        100% |████████████████████████████████| 327kB 206kB/s
    Collecting html5lib==0.9999999 (from tensorboard<1.9.0,>=1.8.0->tensorflow)
      Downloading https://files.pythonhosted.org/packages/ae/ae/bcb60402c60932b32dfaf19bb53870b29eda2cd17551ba5639219fb5ebf9/html5lib-0.9999999.tar.gz (889kB)
        100% |████████████████████████████████| 890kB 96kB/s
    Building wheels for collected packages: gast, termcolor, absl-py, html5lib
      Running setup.py bdist_wheel for gast ... done
      Stored in directory: /root/.cache/pip/wheels/9a/1f/0e/3cde98113222b853e98fc0a8e9924480a3e25f1b4008cedb4f
      Running setup.py bdist_wheel for termcolor ... done
      Stored in directory: /root/.cache/pip/wheels/7c/06/54/bc84598ba1daf8f970247f550b175aaaee85f68b4b0c5ab2c6
      Running setup.py bdist_wheel for absl-py ... done
      Stored in directory: /root/.cache/pip/wheels/a0/f8/e9/1933dbb3447ea6ef57062fd5461cb118deb8c2ed074e8344bf
      Running setup.py bdist_wheel for html5lib ... done
      Stored in directory: /root/.cache/pip/wheels/50/ae/f9/d2b189788efcf61d1ee0e36045476735c838898eef1cad6e29
    Successfully built gast termcolor absl-py html5lib
    Installing collected packages: six, setuptools, protobuf, astor, backports.weakref, wheel, funcsigs, pbr, mock, enum34, gast, termcolor, absl-py, numpy, html5lib, bleach, futures, markdown, werkzeug, tensorboard, grpcio, tensorflow
    Successfully installed absl-py-0.2.2 astor-0.6.2 backports.weakref-1.0.post1 bleach-1.5.0 enum34-1.1.6 funcsigs-1.0.2 futures-3.2.0 gast-0.2.0 grpcio-1.12.1 html5lib-0.9999999 markdown-2.6.11 mock-2.0.0 numpy-1.14.5 pbr-4.0.4 protobuf-3.6.0 setuptools-39.0.1 six-1.11.0 tensorboard-1.8.0 tensorflow-1.8.0 termcolor-1.1.0 werkzeug-0.14.1 wheel-0.31.1
    
    TensorFlow | 2037 觀看 | 2018-06-28 | Kuann Hung 上傳
  • ae0f541be8bf4755cec3f7de324de903.png
    嗯,這是一個不能說的東西,如果有需要的人就自己拿去用吧!!~
    首先,你要先弄一個 VPS,如果這個都搞不訂的大概先不要想要怎麼弄吧!~
    Linux | 4440 觀看 | 2018-05-21 | Kuann Hung 上傳
  • 最近開始用 nodejs 做一些事情,最後希望變成系統服務來執行,所以紀錄一下作法
     
    5d7a90bcbd73c19060b45fb6e37ca20b.png
    JavaScript | 2335 觀看 | 2018-05-16 | Kuann Hung 上傳
  • #!/bin/sh
    
    cd /var/www
    mysqldump -q --opt -h localhost --user=root --password={password} --events --all-databases > /var/www/backup/db_$(date +%y%m%d).sql
    gzip -f /var/www/backup/db_$(date +%y%m%d).sql
    
    echo "Sync.... \r\n";
    java -jar /opt/SyncrifyClient/Loader.jar -console backup.syncrify
    
    Linux | 2420 觀看 | 2018-04-25 | Kuann Hung 上傳
  • 『黑啤闖進芬特克城後,又是學 #比特幣
    臺灣吧 - Taiwan Bar 動畫臺灣史 | 2183 觀看 | 2018-04-03 | Kuann Hung 上傳