Skip to content

Instantly share code, notes, and snippets.

View PatWie's full-sized avatar
💭
waiting for the end of the AI hype

Patrick Wieschollek PatWie

💭
waiting for the end of the AI hype
View GitHub Profile
@PatWie
PatWie / zmqimage.py
Created January 17, 2017 22:22 — forked from jeffbass/zmqimage.py
zmqimage.py -- classes to send, receive and display OpenCV images from a headless computer to a display computer using cv2.imshow()
# zmqimage.py -- classes to send, receive and display cv2 images via zmq
# based on serialization in pyzmq docs and pyzmq/examples/serialization
'''
PURPOSE:
These classes allow a headless (no display) computer running OpenCV code
to display OpenCV images on another computer with a display.
For example, a headless Raspberry Pi with no display can run OpenCV code
and can display OpenCV images on a Mac with a display.
USAGE:
@PatWie
PatWie / npzmq.py
Created January 17, 2017 22:24 — forked from minrk/npzmq.py
Edited version of example script for farming out image saves via zmq ventilator
import numpy
import zmq
def send_array(socket, A, flags=0, copy=True, track=False):
"""send a numpy array with metadata"""
md = dict(
dtype = str(A.dtype),
shape = A.shape,
)
socket.send_json(md, flags|zmq.SNDMORE)
@PatWie
PatWie / benchmark_staging.py
Created February 9, 2017 08:56
compare staging vs FIFO
import tensorflow as tf
from tensorflow.python.ops import data_flow_ops
import time
from contextlib import contextmanager
@contextmanager
def benchmark(name="unnamed context"):
elapsed = time.time()
yield
@PatWie
PatWie / update-tensorflow.sh
Last active December 4, 2019 18:24
simple cronjob script to frequently build TensorFlow from source automatically
#!/bin/bash
# Patrick Wieschollek
# =============================================================
# UPDATE SOURCE
# =============================================================
git checkout -- .
git pull origin master
@PatWie
PatWie / distributed-tf-example.py
Last active April 27, 2017 15:58
distributed TensorFlow
# -*- coding: utf-8 -*-
# File: base.py
# Author: Patrick Wieschollek <mail@patwie.com>
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import numpy as np
@PatWie
PatWie / letsencrypt_2017.md
Created June 6, 2017 17:48 — forked from cecilemuller/letsencrypt_2020.md
How to setup Let's Encrypt for Nginx on Ubuntu 16.04 (including IPv6, HTTP/2 and A+ SLL rating)

How to setup Let's Encrypt for Nginx on Ubuntu 16.04 (including IPv6, HTTP/2 and A+ SLL rating)

There are two main modes to run the Let's Encrypt client (called Certbot):

  • Standalone: replaces the webserver to respond to ACME challenges
  • Webroot: needs your webserver to serve challenges from a known folder.

Webroot is better because it doesn't need to replace Nginx (to bind to port 80).

In the following, we're setting up mydomain.com. HTML is served from /var/www/mydomain, and challenges are served from /var/www/letsencrypt.

@PatWie
PatWie / ngrok-selfhosting-setup.md
Created June 16, 2017 19:56 — forked from lyoshenka/ngrok-selfhosting-setup.md
How to setup Ngrok with a self-signed SSL cert

Intro

The plan is to create a pair of executables (ngrok and ngrokd) that are connected with a self-signed SSL cert. Since the client and server executables are paired, you won't be able to use any other ngrok to connect to this ngrokd, and vice versa.

DNS

Add two DNS records: one for the base domain and one for the wildcard domain. For example, if your base domain is domain.com, you'll need a record for that and for *.domain.com.

Different Operating Systems

@PatWie
PatWie / README.md
Created June 16, 2017 20:01 — forked from gdamjan/README.md
Setup for an easy to use, simple reverse http tunnels with nginx and ssh. It's that simple there's no authentication at all. The end result, a single ssh command invocation gives you a public url for your web app hosted on your laptop.

What

A lot of times you are developing a web application on your own laptop or home computer and would like to demo it to the public. Most of those times you are behind a router/firewall and you don't have a public IP address. Instead of configuring routers (often not possible), this solution gives you a public URL that's reverse tunnelled via ssh to your laptop.

Because of the relaxation of the sshd setup, it's best used on a dedicated virtual machine just for this (an Amazon micro instance for example).

Requirements

@PatWie
PatWie / decode.py
Last active July 3, 2017 11:17
decode.py
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
import cv2
import argparse
import numpy as np
from tensorpack import *
"""
starting in with black's turn
------ START internal representation ------------------
WHITE (O) vs BLACK (X)
x 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8
A B C D E F G H J K L M N O P Q R S T y
19 . o x . . . . . . . . . . . . . . . . 19 0
18 . x o x . . . . . . . . . . . . . . . 18 1