Skip to content

Instantly share code, notes, and snippets.

View Casxt's full-sized avatar
💭
I may be slow to respond.

Forer Casxt

💭
I may be slow to respond.
View GitHub Profile
@Casxt
Casxt / pass_socket.py
Created August 1, 2017 10:37 — forked from josiahcarlson/pass_socket.py
An example of passing a socket between processes using Python's multiprocessing library
'''pass_socket.py
Written September 14, 2012
Released into the public domain.
Works on Python 2.6, 2.7, and may need minor changes for 3+.
'''
import multiprocessing
@Casxt
Casxt / http.go
Last active July 11, 2018 06:59
[Golang]从req.RemoteAddr中提取IP || Match IP from RemoteAddr
func route(res http.ResponseWriter, req *http.Request) {
path := req.URL.Path
log.Println(req.RemoteAddr[0:strings.LastIndex(req.RemoteAddr, ":")], req.Method, path)
}
//OutPut: 2018/07/11 14:54:35 [::1] GET /favicon.ic
@Casxt
Casxt / SqlDealNull.go
Created July 17, 2018 17:32
[Golang] Use pointer to deal sql null value | 使用指针处理SQL NULL 值
var (
nullInt *int
nullTime *time.Time
nullString string
)
row := course.QueryRow("SELECT NULL,NULL,NULL FROM Table", LineID)
DBErr = row.Scan(&nullInt, &nullTime, &nullString);
if DBErr != nil {
return
@Casxt
Casxt / example.html
Created July 30, 2018 07:23 — forked from kylebarrow/example.html
Prevent links in standalone web apps opening Mobile Safari
<!DOCTYPE html>
<head>
<title>Stay Standalone</title>
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
<script src="stay_standalone.js" type="text/javascript"></script>
</head>
<body>
<ul>
<li><a href="http://google.com/">Remote Link (Google)</a></li>
@Casxt
Casxt / Build Caffe with python3.6.7
Last active November 12, 2018 00:58
Build Caffe with python3.6.7
# 编译boost
``` bash
./bootstrap.sh --with-python=/usr/local/bin/python3.6 --with-python-root=/usr/local/python3.6.7
./bootstrap.sh --with-python=/usr/local/bin/python3.6
./b2 --clean
./b2 --with-python
./b2 install --prefix=/data/zhangkai/.local/boost
```
@Casxt
Casxt / opencv process to rmtp
Last active November 19, 2018 11:10
rstp to rmtp in python use ffmpeg
pipe = subprocess.Popen([FFMPEG_BIN,
'-y', # (optional) overwrite output file if it exists
'-f', 'rawvideo',
#'-loglevel','error',
#'-probesize','10M',
'-s', framesize, #'420x360', # size of one frame
'-pix_fmt', 'bgr24',
'-r', str(self.fps), # frames per second
'-i', '-', # The input comes from a pipe
'-an', # Tells FFMPEG not to expect any audio
@Casxt
Casxt / python3.6 编译
Created November 27, 2018 01:45
python3.6 编译
yum install gcc openssl-devel bzip2-devel expat-devel gdbm-devel readline-devel sqlite-devel
./configure --enable-ipv6 --enable-optimizations --with-ensurepip --enable-shared --prefix="/usr/local/python3.6.7"
# --with-optimizations --with-lto 是编译时的优化选项 --with-valgrind 不明 --prefix="/usr/local" --enable-profiling
#不指定path,安装完成后python会自动把自己加到系统目录里
sudo make -j4
sudo make install
#在/etc/ld.so.conf.d下创建python3.conf写入/usr/local/python3.6.7/lib
ldconfig
@Casxt
Casxt / postgresql常用操作.md
Last active November 28, 2018 07:35
postgresql常用操作

安装

yum install postgresql-server postgresql-contrib
sudo postgresql-setup initdb
sudo systemctl start postgresql
sudo systemctl enable postgresql

默认位置/var/lib/pgsql/{version}/data

配置

@Casxt
Casxt / benchmark
Created December 10, 2018 06:55
Pillow & skimage & OpenCV image encode benchmark
import numpy
from skimage import io
import time
from PIL import Image
import cv2
import sys, os
sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
from config import projectPath
@Casxt
Casxt / opencv_imgencode_usage.py
Created December 10, 2018 07:27
opencv imgencode usage
ret, imgBytes = cv2.imencode(".jpg", cv2_img)
if ret:
bytes = imgBytes.tobytes()