Skip to content

Instantly share code, notes, and snippets.

@porjo
porjo / ip6.sh
Last active August 29, 2015 14:03
linux ipv6 router
# ---------------
# Container
# ---------------
# Ensure that a default IPv6 route exists on the container (it should match the link-local address of the host running radvd)
ip -6 route
# ---------------
# Radvd Host
# ---------------
# Ensure that the host has IPv6 address and gateway *statically* assigned (don't rely on autoconf here)
@porjo
porjo / user_data.yaml
Created July 1, 2014 04:52
CoreOS cloud-config
#cloud-config
hostname: coreos-01
coreos:
etcd:
#discovery: https://discovery.etcd.io/xxxxxxxxxxxxxxxx
addr: $private_ipv4:4001
peer-addr: $private_ipv4:7001
units:
@porjo
porjo / docker_postfix.md
Last active August 29, 2015 14:03
Docker and postfix

UPDATE: 2014/09/05

Looks like this is now fixed as of Docker v1.2.0


For the benefit of the interwebs I'm documenting this here as I've spent several hours pulling my hair out.

Postfix does not play well inside a docker container

@porjo
porjo / README.md
Last active August 29, 2015 14:03 — forked from mmoulton/README.md
Docker stats collection for collectd

Forked from: https://gist.github.com/mmoulton/6224509

Docker stats collection for collectd

This script can be used to feed collectd with cpu and memory usage statistics for running docker containers using the collectd exec plugin.

This script will report the used and cached memory as well as the user and system cpu usage by inspecting the appropriate cgroup stat file for each running container.

Usage

@porjo
porjo / golower.sh
Last active August 29, 2015 14:05
lowercase Golang error messages
# Look for instantiations of error using fmt.Errorf or errors.New, where first letter is upper-case. Convert that letter to lowercase.
# e.g.
# return fmt.Errorf("User...
# return errors.New("User...
# becomes
# return fmt.Errorf("user...
# return errors.New("user...
find -name '*.go' -exec sed 's/\(\(errors\.New\|fmt\.Errorf\)("\)\([A-Z]\)\(.*\)/\1\l\3\4/' {} \;
// Forked from: https://gist.github.com/melbourne2991/8822609
//
// Below is an example of a directive that let's other directives know when there has been a change
// in a breakpoint, as well as a windows resize, the event is triggered on the window resize and
// broadcast on $rootScope. The arguments contain the current & previous breakpoints. Previous will
// be null if there is yet to be a change in breakpoint.
//
app.directive('bsBreakpoint', function($window, $rootScope, $timeout) {
return {
controller: function() {
@porjo
porjo / vim_tips.md
Last active August 29, 2015 14:07
vim tips

Replace all occurrences of text block A with block B

visually select A "ay , visually select B "by then :s/<ctrl-r>a/<ctrl-r>b/g

Note: pasting in from register produces ^M and ^I in place of newlines and tabs. These need to be converted to \n and \t respectively.

(Technique also documented here: http://vim.wikia.com/wiki/Search_and_replace)

@porjo
porjo / fedora21_wayland.md
Created November 5, 2014 09:27
Testing Wayland on Fedora 21 Live CD

Wayland on Fedora21 Live CD

Gnome does not use Wayland by default when the Live CD boots up. To use Wayland, do the following:

  • set a password on the user account e.g. open terminal and issue passwd
  • log out of Gnome
  • below the login prompt should be a small cog icon, click that and select Gnome on Wayland from the dropdown menu
  • login
@porjo
porjo / Postgres_Centos_Dockerfile
Last active August 29, 2015 14:09
Postgresql 9.3 on Centos7, Dockerfile
FROM centos:centos7
RUN yum update -y
RUN yum install -y http://yum.postgresql.org/9.3/redhat/rhel-7-x86_64/pgdg-centos93-9.3-1.noarch.rpm http://fedora.mirror.serversaustralia.com.au/epel/7/x86_64/e/epel-release-7-2.noarch.rpm
RUN yum install -y postgresql93-server postgis2_93 sudo
RUN /usr/pgsql-9.3/bin/postgresql93-setup initdb
# Adjust PostgreSQL configuration so that remote connections to the
# database are possible.
RUN echo "host all all 0.0.0.0/0 md5" >> /var/lib/pgsql/9.3/data/pg_hba.conf
@porjo
porjo / rsyslog_selinux_centos6.md
Last active February 15, 2017 19:58
Rsyslog and selinux on Centos6

Rsyslog and selinux on Centos6

I was configuring a Centos6 box to receive syslog from remote hosts. I wanted that log to be written to a non-standard path: /data/syslog

On my first attempt, this failed with the following log in /var/log/messages:

Nov 26 11:26:24 localhost rsyslogd-3000: Could not open dynamic file '/data/syslog/10.10.1.252/2014-11/26/syslog.log' [state -3000] - discarding message [try http://www.rsyslog.com/e/3000 ]

I then set the context of /data/syslog to match /var/log with: