Skip to content

Instantly share code, notes, and snippets.

View chairco's full-sized avatar
🏠
Working from home

Jason chairco

🏠
Working from home
View GitHub Profile
@chairco
chairco / asyncio-producer-consumer-task_done.py
Created August 14, 2018 08:13 — forked from tomschr/asyncio-producer-consumer-task_done.py
Producer/Consumer pattern for asyncio (Python >=3.4)
# Original source from http://asyncio.readthedocs.io/en/latest/producer_consumer.html
# Rewritten for Python >=3.4
import asyncio
import random
@asyncio.coroutine
def produce(queue, n):
for x in range(n):

How to install OpenCV 3.1 on Ubuntu 14.04 64bits

Update latest packages and installed

$ sudo apt-get update
$ sudo apt-get upgrade

apt-get update - 更新最新的套件資訊 apt-get upgrade - 更新套件

# Open CV 3
sudo apt-get -y install libtiff5-dev
sudo apt-get -y install libavcodec-dev libavformat-dev libswscale-dev libdc1394-22-dev
sudo apt-get -y install libxine2-dev libv4l-dev
sudo apt-get -y install libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev
sudo apt-get -y install qt5-default libgtk2.0-dev libtbb-dev
sudo apt-get -y install libatlas-base-dev
@chairco
chairco / ubuntu_agnoster_install.md
Created March 29, 2018 01:49 — forked from renshuki/ubuntu_agnoster_install.md
Ubuntu 16.04 + Terminator + Oh My ZSH with Agnoster Theme

Install Terminator (shell)

sudo add-apt-repository ppa:gnome-terminator
sudo apt-get update
sudo apt-get install terminator

Terminator should be setup as default now. Restart your terminal (shortcut: "Ctrl+Alt+T").

Install ZSH

@chairco
chairco / nodejs-ubuntu-bind-port-80.md
Created March 21, 2018 02:52 — forked from guifromrio/nodejs-ubuntu-bind-port-80.md
Allow Node.js to bind to privileged ports without root access on Ubuntu

How to: Allow Node to bind to port 80 without sudo

TL;DR

Only do this if you understand the consequences: all node programs will be able to bind on ports < 1024

sudo setcap 'cap_net_bind_service=+ep' /usr/local/bin/node

Important: your node location may vary. Use which node to find it, or use it directly in the command:

Python Socket 编程详细介绍

Python 提供了两个基本的 socket 模块:

  • Socket 它提供了标准的BSD Socket API。
  • SocketServer 它提供了服务器重心,可以简化网络服务器的开发。

下面讲解下 Socket模块功能。

Socket 类型

@chairco
chairco / backend-architectures.md
Created February 8, 2018 15:07 — forked from ngocphamm/backend-architectures.md
Backend Architectures
@chairco
chairco / KMP.py
Created September 9, 2017 08:17 — forked from kylebgorman/KMP.py
The Knuth-Morris-Pratt algorithm in Python
#!/usr/bin/env python
# Knuth-Morris-Pratt demonstration
# Kyle Gorman <kgorman@ling.upenn.edu>
#
# A naive Python implementation of a function that returns the (first) index of
# a sequence in a supersequence is the following:
def subsequence(needle, haystack):
"""
Naive subsequence indexer; None if not found
@chairco
chairco / PyUtils.cpp
Created July 3, 2017 12:26 — forked from rjzak/PyUtils.cpp
Convert between Python list/tuples and C++ vectors
#include <Python.h> // Must be first
#include <vector>
#include <stdexcept>
#include "PyUtils.h"
using namespace std;
// =====
// LISTS
// =====
@chairco
chairco / Private-pypi-howto
Created March 17, 2017 08:20 — forked from Jaza/Private-pypi-howto
Guide for how to create a (minimal) private PyPI repo, just using Apache with directory autoindex, and pip with an extra index URL.
*