Skip to content

Instantly share code, notes, and snippets.

View walchko's full-sized avatar

Kevin walchko

View GitHub Profile
@walchko
walchko / sloc.sh
Created September 15, 2017 02:43
Count lines of code in a git repo
#!/usr/bin/env bash
set -e
TMP=/var/tmp/temp-linecount-repo
git clone --depth 1 "$1" ${TMP}
printf "('${TMP}' will be deleted automatically)\n\n\n"
cloc ${TMP}
rm -rf ${TMP}
@walchko
walchko / mjpeg3.py
Created March 26, 2018 05:05
mjpeg server using cv2 and bottle
#!/usr/bin/env python2
# https://gist.github.com/ph1ee/58d55a736462cc2f4f2d
from gevent import monkey; monkey.patch_all()
from bottle import route, run, template, request, response
# import simplejson as json
import cv2
from bottle import debug
debug(True)
@walchko
walchko / mjpeg.py
Created April 1, 2018 06:01
bottle cv2 mjpeg server
#!/usr/bin/env python2
# https://gist.github.com/ph1ee/58d55a736462cc2f4f2d
from gevent import monkey; monkey.patch_all()
from bottle import route, run, template, request, response
import cv2
from bottle import debug
debug(True)
CRLF = "\r\n"
@walchko
walchko / mult-namespace.py
Last active April 1, 2018 13:56
python multiprocessing namespace example
#!/usr/bin/env python3
from __future__ import division, print_function
import multiprocessing as mp
from collections import namedtuple # immutable data class
import time
# data class
Vector = namedtuple('Vector', 'x y z')
@walchko
walchko / pull-all.sh
Created April 1, 2018 14:33
Bash script to automatically update git repos
#!/bin/bash
#
# Update a bunch of git repos on command
#
set -e
# get a list of non-hidden directories
shopt -u dotglob
@walchko
walchko / basic.html
Created April 2, 2018 04:34
simple html template iframe embed pdf example
<!DOCTYPE html>
<html>
<header></header>
<body>
<p>Embed a PDF in an html page</p>
<object width="400" height="400" data="test.pdf"></object>
<iframe src="http://www.google.com" height="400" width="250"></iframe>
@walchko
walchko / find_sloc.bash
Created April 2, 2018 04:38
measure sloc of a git repo
#!/usr/bin/env bash
set -e
loc () {
echo "=========================================="
echo " $1"
echo "=========================================="
TMP=/var/tmp/temp-linecount-repo
@walchko
walchko / Dockerfile
Last active April 8, 2018 15:05
debian docker with python and jupyter
# Installs Jupyter Notebook and IPython kernel from the current branch
# Another Docker container should inherit with `FROM jupyter/notebook`
# to run actual services.
#
# For opinionated stacks of ready-to-run Jupyter applications in Docker,
# check out docker-stacks <https://github.com/jupyter/docker-stacks>
#
# build: docker build -t rpi .
# run: docker run -ti -p 8888:8888 -v `pwd`/notebooks:/notebooks rpi /bin/bash
#
@walchko
walchko / serial.c
Last active July 17, 2018 14:24
Serial port
#include <stdio.h>
#include <fcntl.h> // File Control Definitions
#include <termios.h> // POSIX Terminal Control Definitions
#include <unistd.h> // UNIX Standard Definitions
#include <errno.h> // ERROR Number Definitions
#include <sys/ioctl.h> // define both TIOCMBIS and TIOCMBIC
/** References
https://xanthium.in/Serial-Port-Programming-on-Linux
http://xanthium.in/Controlling-RTS-and-DTR-pins-SerialPort-in-Linux
@walchko
walchko / pip-recursive-uninstall.py
Created April 15, 2018 18:42
recursively removes python modules using pip
#!/usr/bin/env python2
# as of this time, pip 10.0.0 has no dependencies as shown by pip show pip
# this should not in any way harm pip, setuptools, or wheel
from __future__ import print_function, division
import sys
import pip
import subprocess
# from subprocess import Popen,PIPE,STDOUT,call