Skip to content

Instantly share code, notes, and snippets.

View junjuew's full-sized avatar

Junjue Wang junjuew

View GitHub Profile
@junjuew
junjuew / zmqimage.py
Created April 26, 2018 02:10 — 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:
@junjuew
junjuew / sshfs_command.sh
Last active April 26, 2018 01:32
sshfs command to automatically reconnect
# Mount a path from a server to local machine
# Command to use on local machine
sshfs -o reconnect,ServerAliveInterval=15,ServerAliveCountMax=3 username@host:/host/path /mnt/path
# enter ssh password in stdin
sshfs -o password_stdin,reconnect,ServerAliveInterval=15,ServerAliveCountMax=3,StrictHostKeyChecking=no username@host:/host/path /mnt/path
# Reverse mount
# issue from the sshfs SERVER to let a CLIENT mount a SERVER directory
dpipe /usr/lib/openssh/sftp-server = ssh CLIENT sshfs :/mnt/host/path /mnt/client/path -o slave,reconnect,ServerAliveInterval=15,ServerAliveCountMax=3
mkfifo /tmp/testpipe
while true; do ffmpeg -f v4l2 -s 1280x720 -i /dev/video0 -f rawvideo -video_size 1280x720 -pix_fmt rgb24 - | ffmpeg -f rawvideo -video_size 1280x720 -pix_fmt rgb24 -i - -f rawvideo -pix_fmt rgb24 -video_size 1280x720 - > /tmp/testpipe; wait; done
cat /tmp/testpipe | mplayer -nosound -framedrop -benchmark -nostop-xscreensaver -nolirc -demuxer rawvideo -rawvideo w=1280:h=720:format=rgb24 -
@junjuew
junjuew / gstreamer cheat sheet
Last active November 17, 2017 02:51
gstreamer
# Use gstreamer with mpv
## source
gstreamer rtp source over udp:
gst-launch-0.10 v4l2src ! ffenc_mpeg4 ! rtpmp4vpay send-config=true ! udpsink host=127.0.0.1 port=5000
## sink
mpv play a sdp file: mpv --untimed /tmp/video.sdp
/tmp/video.sdp's content:
v=0
m=video 5000 RTP/AVP 96
@junjuew
junjuew / bash_parse_argument_template.sh
Last active September 15, 2017 15:55
Template File for Parsing Command Line Arguments in Bash
#! /bin/bash -ex
# Use -gt 1 to consume two arguments per pass in the loop (e.g. each
# argument has a corresponding value to go with it).
# Use -gt 0 to consume one or more arguments per pass in the loop (e.g.
# some arguments don't have a corresponding value to go with it such
# as in the --default example).
while [[ $# -gt 1 ]]
do
key="$1"
@junjuew
junjuew / xscreensaver-getimage-file
Last active September 11, 2017 23:23
xscreensaver rotate image in sequence
#!/usr/bin/env python3
import sys
import os
import time
import fcntl
def main(image_dir):
files = []
for (dirpath, dirnames, filenames) in os.walk(image_dir):
@junjuew
junjuew / getdocker.sh
Last active April 7, 2017 13:27
get.docker.com fix for apt-key add permission problem
#!/bin/sh
set -e
#
# This script is meant for quick & easy install via:
# 'curl -sSL https://get.docker.com/ | sh'
# or:
# 'wget -qO- https://get.docker.com/ | sh'
#
# For test builds (ie. release candidates):
# 'curl -fsSL https://test.docker.com/ | sh'
@junjuew
junjuew / Makefile
Created February 5, 2017 18:38 — forked from isaacs/Makefile
# Hello, and welcome to makefile basics.
#
# You will learn why `make` is so great, and why, despite its "weird" syntax,
# it is actually a highly expressive, efficient, and powerful way to build
# programs.
#
# Once you're done here, go to
# http://www.gnu.org/software/make/manual/make.html
# to learn SOOOO much more.
@junjuew
junjuew / flask-simple-static.py
Created October 31, 2016 18:57
Simple Flask Boilerplate
from flask import Flask, render_template
app = Flask(__name__)
@app.route('/<string:page_name>/')
def static_page(page_name):
return render_template('%s.html' % page_name)
if __name__ == '__main__':
app.run()
@junjuew
junjuew / test_numpy.py
Created September 13, 2016 14:57
Test script to see whether your numpy is using fast or slow BLAS
#!/usr/bin/env python
import numpy
import sys
import timeit
try:
import numpy.core._dotblas
print 'FAST BLAS'
except ImportError:
print 'slow blas'