Skip to content

Instantly share code, notes, and snippets.

@mgurov
mgurov / gist:3c296b6362879aa0cd20
Created June 29, 2015 19:58
Vagrantfile for docker in place of boot2docker
# -*- mode: ruby -*-
# vi: set ft=ruby :
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "precise64"
config.vm.box_url = "http://files.vagrantup.com/precise64.box"
config.vm.provision "docker"
@mgurov
mgurov / drm.sh
Last active February 7, 2016 07:07
Docker remove all cotainers except for with given name (mvn_repository) and untagged images
#!/bin/bash -eux
E=$(docker ps -aq --filter "name=mvn_repository")
docker ps -aq | grep -v ${E:-lookup_failed} | xargs docker rm -f
docker images | sed -E 's/ +/ /g' | grep "^<none> <none>" | cut -d ' ' -f 3 | xargs docker rmi -f
@mgurov
mgurov / pom.xml
Created August 23, 2015 15:28
docker-maven-plugin-testing
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<!--
Simple demo project demonstrating the usage of rhuss/docker-maven-plugin
-->
<groupId>com.github.mgurov</groupId>
<artifactId>docker-maven-runs</artifactId>
<version>0.0.1</version>
@mgurov
mgurov / string_case.sh
Created December 18, 2015 10:44
bash string case manipulations
awk '{print toupper(substr($0,1,1)) substr($0,2) }'
@mgurov
mgurov / wait-port.sh
Created January 11, 2016 15:32
waiting for an oracle database to become available
#!/bin/sh -eu
# Wait for port to get available
LOOPS="1000"
PORT=$1
i=0
while ! nc localhost $PORT >/dev/null 2>&1 < /dev/null; do
i=`expr $i + 1`
if [ $i -ge $LOOPS ]; then
@mgurov
mgurov / wport
Created January 28, 2016 08:33
who has opened that port, probably mac-specific
wport() {
lsof -n -i4TCP:$1
}
@mgurov
mgurov / maven.goodies
Created June 10, 2016 07:14
mvn settings.xml et al.
<profile>
<id>skipTests</id>
<properties>
<skipTests>true</skipTests>
</properties>
</profile>
<profile>
<id>dontGenerateBackupPoms</id>
<properties>
#!/bin/bash -eux
shopt -s nullglob
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
while true; do
files=( x* )
if (( ${#files[@]} )); then
echo file found: $files
select
nspname || '.' || relname as "relation",
pg_size_pretty(
pg_relation_size(C.oid)
) as "size",
to_char(round( pg_relation_size(C.oid) /(
select
sum( pg_relation_size( C.oid ) ) as "totalsize"
from
pg_class C
@mgurov
mgurov / pgctl
Created May 28, 2019 12:29
connect to a postgres instance behind kubectl
#!/bin/bash -eux
CONTEXT=pro
APP=purple
exec 3< <(
pgid=$!
echo "kill $pgid"
kubectl --context=${CONTEXT} --namespace=${APP} port-forward ${APP}-${APP}-db-0 :5432
)