Skip to content

Instantly share code, notes, and snippets.

View shm007g's full-sized avatar
🎯
Focusing

Szymon shm007g

🎯
Focusing
  • Neutron Research Center
View GitHub Profile
@shm007g
shm007g / cv2_timestamp.py
Last active September 17, 2021 14:16
照片打时间戳脚本
import cv2
def mark_photo(text, path, output_path=None):
img = cv2.imread(path)
height, width = img.shape[:2]
font = cv2.FONT_HERSHEY_SCRIPT_COMPLEX
img = cv2.putText(img, text, (width - 500, height - 80), font, 1.2, (0, 255, 255))
if output_path is None:
path_parts = path.split('.')
@shm007g
shm007g / mnist.py
Created November 22, 2018 08:27 — forked from akesling/mnist.py
import os
import struct
import numpy as np
"""
Loosely inspired by http://abel.ee.ucla.edu/cvxopt/_downloads/mnist.py
which is GPL licensed.
"""
def read(dataset = "training", path = os.path.join(os.path.dirname(__file__), 'mnist')):
  • First, you need install jupyter notebook using pip install jupyter
  • Second, you need run notebook on the work dir using jupyter notebook --no-browser --port=9998 --NotebookApp.base_url=/notebook.
    • this make you notebook run on port 9998 with base url '/notebook', you need this base url for nginx dispatching
  • Third, config you nginx config, and test is with sudo nginx -t -c /etc/nginx/nginx.conf, if ok reload nginx with sudo nginx -s reload -c /etc/nginx/nginx.conf
       location /notebook/ {
               proxy_pass http://localhost:9998;
               proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
 proxy_set_header X-Real-IP $remote_addr;

replica and load-balance

  • apt-get install haproxy
  • vim /etc/haproxy/haproxy.cfg and add text below:
        stats   uri /stats
        stats   auth    sunmingming:solomon

frontend main
 bind *:80

about git log

For the importance of commit-logs to committed-changes-review, logs are frequently checked. Effective and beautiful logs would double the efficiency. Then comes the question, how? One way is to making rules. Rules and convention makes logs lawful. The other way is to making the style. Beautiful styles makes logs delightful.

Convention

Angualr Convension is a popular and proper convention for this job. It regularizes logs with 'type-scope-msg' convention. Just like those below. Click-here-to-see-detail

贝叶斯定理在检测吸毒者时很有用。假设一个常规的检测结果的敏感度与可靠度均为99%,也就是说,当被检者吸毒时,每次检测呈阳性(+)的概率为99%。而被检者不吸毒时,每次检测呈阴性(-)的概率为99%。

从检测结果的概率来看,检测结果是比较准确的,但是贝叶斯定理却可以揭示一个潜在的问题。

假设某公司将对其全体雇员进行一次鸦片吸食情况的检测,已知0.5%的雇员吸毒。我们想知道,每位医学检测呈阳性的雇员吸毒的概率有多高?

令“D”为雇员吸毒事件,“N”为雇员不吸毒事件,“+”为检测呈阳性事件。

可得:

  • P(D)代表雇员吸毒的概率,不考虑其他情况,该值为0.005。因为公司的预先统计表明该公司的雇员中有0.5%的人吸食毒品,所以这个值就是D的先验概率。
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
!j::Send, {Left}
!l::Send, {Right}
!k::Send, {Down}
!i::Send, {Up}