Skip to content

Instantly share code, notes, and snippets.

@JinhaiZ
JinhaiZ / opencv_cplus.md
Last active February 8, 2018 19:24
c++ opencv manipulation
  1. get the size of a multi-dimensional cv::Mat
std::cout << "cvMat.dims = " << cvMat.dims << "cvMat.size = [";
for(int i = 0; i < cvMat.dims; ++i) {
    if(i) std::cout << " X ";
    std::cout << cvMat.size[i];
}
std::cout << "] cvMat.channels = " << cvMat.channels() << std::endl;
@JinhaiZ
JinhaiZ / image_processing.md
Last active January 21, 2018 08:42
basic image processing using OpenCV library for Python

Algo

Converting multiple BMPs to an AVI without compression

You can use the huffyuv encoder to create a lossless output:

ffmpeg -i img%d.jpg -vcodec huffyuv output.avi
@JinhaiZ
JinhaiZ / install_opencv.sh
Created January 3, 2018 21:08
How to install Opencv library for Python
pip install opencv-python
@JinhaiZ
JinhaiZ / ssh_login_by_key.md
Created December 8, 2017 10:02
Configuration SSH connection between client and server

Server side

  1. install ssh server

    sudo apt-get install openssh-server
    

Client side

@JinhaiZ
JinhaiZ / Local_Kubernetes.md
Last active December 5, 2017 09:56
Installation and configuration for local kubernetes environment

Download Kubectl

  1. Download the lastest release

     `curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl`
    
  2. Make it executable

    chmod +x ./kubectl

@JinhaiZ
JinhaiZ / Direct_ethernet_connection.md
Last active September 28, 2021 19:35
Direct Ethernet connection to Raspberry Pi/Odroid without router (with DHCP, tested on Ubuntu 16.04)

Creative Commons License
This work is licensed under a Creative Commons Attribution 4.0 International License.

Direct Ethernet connection to Raspberry Pi/Odroid without router

The solution is based on running DHCP service at your workstation (your notebook for example), and use it to attribute an IP address to your Raspberry Pi/Odroid. Then use ssh to connect to your Raspberry Pi/Odroid through this IP address.

Terminology Explaination
Client Your Single Board Computer, such as a Raspberry Pi or an Odroid
Server Your workstation with any linux based systems, like Ubuntu
@JinhaiZ
JinhaiZ / connection.py
Created November 19, 2017 16:39
connect to MongoDB via ssh tunnel
from sshtunnel import SSHTunnelForwarder
import pymongo
MONGO_HOST = "IP_ADDRESS"
MONGO_USER = "USERNAME"
MONGO_PASS = "PASSWORD"
MONGO_DB = "DATABASE_NAME"
MONGO_COLLECTION = "COLLECTION_NAME"
# define ssh tunnel
@JinhaiZ
JinhaiZ / 每个程序员都应该知道的延迟时间表.md
Last active August 12, 2024 09:45
每个程序员都应该知道的延迟时间表 翻译自:https://gist.github.com/jboner/2841832
操作 延迟(纳秒) 延迟(微秒) 延迟(毫秒) 参考
CPU L1 级缓存访问 0.5 ns
分支预测错误* 5 ns  
CPU L2 级缓存访问 7 ns 14x L1 cache
互斥体Mutex 加锁/解锁 25 ns
内存访问 100 ns 20x L2 cache, 200x L1 cache
用Zippy压缩1K字节 3,000 ns 3 us
在1 Gbps速率的网络上发送1K字节 over 10,000 ns 10 us
从SSD读取4K长度的随机数据 150,000 ns 150 us ~1GB/sec SSD
@JinhaiZ
JinhaiZ / raspberry_install.sh
Created October 23, 2017 21:02
Install various software on Raspberry 3
# install Scrapy
sudo apt-get install libffi-dev
sudo apt-get install libxml2-dev
sudo apt-get install libxslt1-dev
sudo apt-get install python-dev
sudo pip install scrapy
# install MongoDB
sudo apt-get update
sudo apt-get install mongodb-server