Skip to content

Instantly share code, notes, and snippets.

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

kenwoodjw

💭
I may be slow to respond.
View GitHub Profile
@kenwoodjw
kenwoodjw / client.py
Created April 15, 2017 07:26 — forked from dongweiming/client.py
知乎API爬虫
# coding=utf-8
import os
import json
import time
import requests
from requests.auth import AuthBase
from settings import LOGIN_URL, CAPTCHA_URL
from config import (
API_VERSION, APP_VERSION, APP_BUILD, UUID, UA, APP_ZA, CLIENT_ID,
@kenwoodjw
kenwoodjw / excel2mysql.py
Created January 19, 2018 06:42 — forked from anubhavsinha/excel2mysql.py
simple excel to mysql in python
# following Python packages needs to be installed
# xlrd, xlsxrd, unidecode, MySQLdb
import xlrd
import xlsxrd
import MySQLdb as mdb
import re
import unidecode
@kenwoodjw
kenwoodjw / flask_upload.py
Created April 10, 2018 03:04
flask upload image return image base64
#coding:utf-8
import os,io
from flask import Flask, request, redirect, url_for,Response,render_template,send_file,make_response,jsonify,send_from_directory
from werkzeug import secure_filename
from flask_cors import CORS,cross_origin
ALLOWED_EXTENSIONS = set(['txt', 'pdf', 'png', 'jpg', 'jpeg', 'gif'])
APP_ROOT = os.path.dirname(os.path.abspath(__file__))
UPLOAD_FOLDER = os.path.join(APP_ROOT, 'static\\upload')
@kenwoodjw
kenwoodjw / latency.txt
Created April 11, 2018 11:41 — forked from jboner/latency.txt
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers
--------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
@kenwoodjw
kenwoodjw / pyscript_cdh.md
Last active April 17, 2018 09:30
pyscript_cdh

python scripy for cdh

hdfs

pip install hdfs
from hdfs import InsecureClient
hdfs_client = InsecureClient('http://192.168.0.251:50070',user='hive')
#列出文件
hdfs_client.list('.')
# 新建文件
hdfs_client.makedirs('/a/b/c')
@kenwoodjw
kenwoodjw / kvm
Last active April 24, 2018 06:10
kvm.md
```
virt-install \
--virt-type=kvm \
--name=master \
--vcpus=16 \
--memory=16384 \
--location=/home/CentOS-7-x86_64-Everything-1708.iso \
--disk path=/home/vms/master.qcow2,size=2048,format=qcow2 \
--network bridge=br0 \
#!/usr/bin/env bash
# #
# # Install main dependencies on CentOS:
# # Python 3.4.5, CMake 3.10.0, OpenCV 3.3.1
# # Author Andrii Lundiak (landike@gmail.com)
# #
# https://github.com/ageitgey/face_recognition/issues/191
# https://github.com/opencv/opencv/issues/8471
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>PC HLS video</title>
<link href="http://cdn.bootcss.com/video.js/6.0.0-RC.5/alt/video-js-cdn.min.css" rel="stylesheet">
</head>
<body>
@kenwoodjw
kenwoodjw / asyncio-producer-consumer-task_done.py
Created May 30, 2018 06:05 — 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):
#change pd model to tflite
bazel-bin/tensorflow/contrib/lite/toco/toco --input_file=model.pb --input_format=TENSORFLOW_GRAPHDEF --output_format=TFLITE --output_file=/tmp/mobile.tflite --inference_type=FLOAT --inference_input_type=FLOAT --input_arrays=input --output_arrays=Reshape --input_shapes=1,224,224,3
#build apk
bazel build -c opt --cxxopt='--std=c++11' //tensorflow/examples/tensorflow-android-speech-kws/android:tensorflow_demo
#华为 caffe 模型转换
./cngen_linux --prototxt mobilenet_v2_deploy.prototxt --model mobilenet_v2.caffemodel
#华为 tensorflow 模型转换