Skip to content

Instantly share code, notes, and snippets.

View philips's full-sized avatar
👨‍💻
at the keebs

Brandon Philips philips

👨‍💻
at the keebs
View GitHub Profile
systemctl enable --runtime /media/state/units/docker-local.service
systemctl daemon-reload
systemctl start docker-local
@philips
philips / gist:9339210
Last active August 29, 2015 13:56
How to destroy your disk or make it rw
rootfs=/dev/xvda3
ro_compat_offset=$((0x464 + 3))
printf '\000' | sudo dd of="${rootfs}" seek=$((offset + ro_compat_offset)) \
conv=notrunc count=1 bs=1
@philips
philips / gist:9108489
Last active August 29, 2015 13:56
Howto get an ssh agent forwarded into your vagrant host.

Setup your ssh client so it can ssh into your vagrant machine like a regular host:

vagrant ssh-config --host coreos-vagrant >> ~/.ssh/config
vagrant ssh-config --host coreos-vagrant | sed -n "s/IdentityFile//gp" | xargs ssh-add

Login! Using 'ssh -A' forwards an agent from your host machine into your vagrant machine.

This causes rethink to eat 100% cpu:
r.db('roller').table('app_event').groupedMapReduce(
r.js('(function(row) { return row.Version })'),
function(event) { return 1; },
function(acc, count) { return acc.add(count); }, 0)
RqlRuntimeError: Cannot convert javascript `undefined` to ql::datum_t. in:
r.db("roller").table("app_event").groupedMapReduce(r.js("this.Version"), function(var_12) { return 1; }, function(var_13) { return var_13.add(var_14); }, {base: 0})
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
$ docker run busybox echo foo
2014/02/19 02:12:37 Error: create: create: command not found
core@localhost ~ $ docker run -i -t busybox exit 1
2014/02/19 02:14:00 Unable to locate exit
[error] client.go:2279 Error getting size: bad file descriptor
core@localhost ~ $ echo $?
0
r.db('roller').table('app_event').groupedMapReduce(
function(event) { return event('DateTime').minutes(); },
function(event) { return 1; },
function(acc, count) { return acc.add(count); }, 0)
r.db('roller').table('app_event').filter(function(event) {
return event("DateTime").minutes().eq(15);
}).count
Return 52
r.db('roller').table('app_event').groupedMapReduce(
function(event) { return event('DateTime').minutes(); },
function(event) { return 1; },
function(acc, event) { acc.add(1); return acc; }, r.expr(0))

This is a temporary workaround to disable auto updates. As we move out of the alpha there will be a nicer method.

Add a unit file to stop update-engine-reboot-manager

There is a single simple script called "update-engine-reboot-manager" that does an automatic reboot after update-engine applies an update to your CoreOS machine. To stop automatic reboots after an update has been applied you need to stop this daemon. You can do this via a service file that is started at boot.

Create a file called /media/state/units/stop-reboot-manager.service that has the following contents:

[Unit]
@philips
philips / gist:8324564
Last active May 24, 2016 11:29
I love go. SSH client using the agent in under 50 lines of code.
// example: go run ssh.go core myhost:22 "ps aux | head -n 5"
package main
import (
"log"
"net"
"os"
"code.google.com/p/go.crypto/ssh"
)
@philips
philips / gist:8064737
Last active January 1, 2016 00:09
oem-release file prototype
NAME=Rackspace
ID=rackspace
VERSION_ID=168.0.0
PRETTY_NAME="Rackspace Cloud Servers"
HOME_URL="http://www.rackspace.com/cloud/servers/"
BUG_REPORT_URL="https://github.com/coreos/coreos-overlay"
NAME=Brightbox
ID=brightbox
VERSION_ID=168.0.0