Skip to content

Instantly share code, notes, and snippets.

@mowings
mowings / install lxc
Last active December 25, 2015 14:29
install lxc on ubuntu 12.04 host (AWS)
git clone git@github.com:lxc/lxc.git
apt-get install automake pkg-config libcap-dev
./autogen.sh
./configure
make
make install
# to make a package -- you may need to clean up depedencies
checkinstall
# TODO: autostart the networking
@mowings
mowings / gist:7235687
Last active December 27, 2015 00:09
Install lxc-0.9.0 on Ubuntu 12.04 so that it works with vagrant-lxc You'll need to build it and be sure it does NOT install in /usr/local
apt-get install automake pkg-config libcap-dev # You'll need these to build 0.9.0
sudo apt-get install lxc # Get 0.7.5 so you get upstart scripts and networking stuff
wget https://github.com/lxc/lxc/archive/lxc-0.9.0.tar.gz # Get 0.9.0
tar -xzvf lxc-0.9.0.tar.gz
cd lxc-lxc-0.9.0
./autogen.sh
./configure --prefix=/usr
make
make install
@mowings
mowings / gist:9782264
Last active March 8, 2020 11:34
Set up NFS share from mac to Parallels Linux Guest

On the mac, edit /etc/exports and add a line like so:

"/Users/<username>/develop/" -network 10.211.55.0 -mask 255.255.255.0  -mapall=<username>

The network and mask parameters indicate what hosts we'll share with; in my case, this network is used by the parallels shared network adapter; yours may differ.

You may need to reload nfsd:

sudo nfsd update
@mowings
mowings / gist:a875d40879ce5ba60011
Last active November 3, 2015 04:22
Network speed test with nc or ssh
On the receiver
nc -l -v 1234 > /dev/null
On the sender
dd if=/dev/zero bs=4096 count=104800 | nc <host> 1234
if can be a file if desired, but I found there were no real differences. Do NOT use
/dev/urandom, as urandom itself can be a huge bottleneck (depending on hardware)
A file might look like this:
@mowings
mowings / default.conf
Last active August 29, 2015 14:03
Generic lxc-container nginx vhost. Access web services in an lxc container generically
# Allows you to specify just a container, or to prepend
# a port to get to something not running on 80
# ie, http://foo, or http://p9200.foo
# Obviously, you still need a host lookup mechanism for these
server {
listen 80 default_server;
server_name "~^(p(?<port>\d+)\.)?(?<container>[^\.]+)";
location / {
if ($port = '') {
set $port 80;
@mowings
mowings / gist:3f4fccc9ec4552b6aba0
Last active August 29, 2015 14:04
Stream 1080p video with raspberry pi and vlc
# This uses http at rotates my output 270 degrees (camera is in a werid position)
# I'm only doing 10 fps -- which keeps the load on the pi at around 1.5. Note that you need to
# be sure to max the framerate used by the pi with the framerate used by cvlc
sudo raspivid -o - -t 0 -w 1900 -h 1080 -rot 279 -fps 10 |cvlc -vvv stream:///dev/stdin --sout '#standard{access=http,mux=ts,dst=:8160}' :demux=h264 :h264-fps=10
# Use rtsp -- this is less firewall friendly but gracefuly trades off quality/framerate and loads up the pi less
# As above, carefully note that fps has to match on both sides. Note that the higher the fps, the lower the quality
# and visa-versa. Of course, you can also drop the resolution
sudo raspivid -o - -t 0 -w 1900 -h 1080 -rot 279 -fps 24 |cvlc -vvv stream:///dev/stdin --sout '#rtp{sdp=rtsp://:8554/}' :demux=h264 :h264-fps=24
@mowings
mowings / gist:7210816c88fb3328b3ad
Last active December 3, 2021 08:34
Raspberry Pi raspivid output to mp4
# Stream 60 seconds of video to an mp4 file
sudo raspivid -o - -t 60000 -ex night -br 50 -w 1920 -h 1080 -rot 279 -fps 8 | sudo ffmpeg -r 8 -i - -y -vcodec copy /mnt/pi/camera/foo.mp4
@mowings
mowings / .profile
Last active August 29, 2015 14:04
Keep tmux from losing your ssh socket between sessions
# Predictable SSH authentication socket location.
SOCK="$HOME/.ssh/ssh-agent-sock"
if test $SSH_AUTH_SOCK && [ $SSH_AUTH_SOCK != $SOCK ]
then
ln -sf $SSH_AUTH_SOCK $SOCK
export SSH_AUTH_SOCK=$SOCK
fi
@mowings
mowings / gist:7231988a2fd6ee7089d0
Last active August 29, 2015 14:05
rsync as sudo-ed user on the remote host. Needed to preserve permissions, get special files over, etc
# Remote user must have NOPASSWD set in sudoers
# This example mirrors an entire directory
rsync --progress -avz --delete --rsync-path="sudo rsync" /path/to/sync/ user@host:/path/to/sync
@mowings
mowings / gist:97d9738290489e31bf33
Created August 14, 2014 17:48
rsync all lxc containers in a directory from one host to another host intact
rsync --progress --numeric-ids -avz --delete --rsync-path="sudo rsync" /mnt/lxc/ user@host:/mnt/lxc