Skip to content

Instantly share code, notes, and snippets.

@mowings
mowings / gist:b20a475e470db1537bc0
Last active May 13, 2016 20:18
Keep LXC containers from losing host names in dnsmasq after a suspend/resume

By default, LXC sets up dnsmasq to issue a lease expiration of 1 hour. Thus if you suspend and resume your laptop after more than an hour has passed, your containers will lose their hostnames and can no longer communicate with one another by host name, as dnsmasq has forgotten about them.

To fix the issue for Ubuntu 14.04, edit /etc/default/lxc-net. Find the line:

LXC_DHCP_RANGE="10.0.3.2,10.0.3.254"

and change it to

LXC_DHCP_RANGE="10.0.3.2,10.0.3.254,72h"
@mowings
mowings / gist:fa7a0b790457e6497b73
Created October 21, 2014 19:36
Unattended ubuntu release upgrade

do-release-upgrade -f DistUpgradeViewNonInteractive

Note that any prompts might hang for 30 seconds or so before proceeding with the default answer.

@mowings
mowings / LXC Setup for Devs
Created November 21, 2014 18:37
LXC Setup and Upgrade for TS devs
Install Ubuntu 14.04 Server 64-bit into the VM of yor choice. Parallels works best on a Mac. Virtual Box also works, but is slower
Log in to your VM and run our LXC-host setup script. Thsi first run will take a while:
wget https://raw.github.com/turbosquid/lxc-host-setup/master/host-setup.sh
bash host-setup.sh
We assume you have a development directory on your macbook that contains subdirectories for each project. Use an NFS share on your host to map this directory in to your VM. Follow the instructions in this [gist](https://gist.github.com/mowings/9782264).
You should now be able to log in to your VM and do a `vagrant up` in anyproject subdirectory to bring up a container for the project. IMPORTANT: If you have just upgraded your vm, delete the old `.vagrant` directory in your project! Otherwise vagrant up will not provision the container. If you forget, just do a `vagrant provision` after your vagrant up.
@mowings
mowings / gist:017c80c188d1024ba3e7
Created June 26, 2015 21:48
golang -- get first non-loopback host ip that works on windows/linux
func externalIP() (string, error) {
addrs, err := net.InterfaceAddrs()
if err != nil {
return "", err
}
for _, addr := range addrs {
var ip net.IP
switch v := addr.(type) {
case *net.IPNet:
ip = v.IP
@mowings
mowings / multiple.json
Last active August 29, 2015 14:24
Restrict S3 bucket access to single / multiple IPs
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "PublicReadGetObject",
"Effect": "Allow",
"Principal": "*",
"Action": [
"s3:GetObject"
],
@mowings
mowings / diskpart.txt
Created July 5, 2015 17:53
AWS Create a raid0 volume from two ephemerals. Can be run on startup with diskpart /s diskpart.txt
select disk 1
convert dynamic
select volume 2
delete volume
select disk 2
convert dynamic
select volume 2
delete volume
create volume stripe disk=1,2
format quick recommended label="My Label"
@mowings
mowings / gist:f2d93596efb85745ff08
Created August 17, 2015 20:32
Change elastic search index replica count (would also work for shards, etc)
curl -XPUT 'localhost:9200/_settings' -d '
{
"index" : {
"number_of_replicas" : 0
} }
'
@mowings
mowings / gist:5d020f3a897409283636
Created August 28, 2015 14:08
imagemagick compositing
convert tmp/base.0100.png \( +clone -alpha Extract \) -channel RGB -compose Divide_Src -composite tmp/shadow.0100.png -compose Dst_Over -composite output/preview.0100.png
@mowings
mowings / gist:43db44de8011b9c0b4a9
Last active September 11, 2015 14:53
Fix OSX cut and paste crashes
# verify that /tmp exists and is accessible. pboard requires it
launchctl list | grep com.apple.pboard
launchtl start com.apple.pboard
Unfortunately, this often means restarting apps that maintain a connection to pboard. But better than a reboot when in a tight spot
Server Manager
Server Roles -- add file server and NFS. Then reboot
Policy Editor
Local Policies
Network Access: Let everyone permissions apply to anonymous users ENABLE
Reboot
Directory -> NFS Sharing
Set up anonymous r/w. Allow root access
Advanced -> Give Everyone full access