Skip to content

Instantly share code, notes, and snippets.

@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>
@mgurov
mgurov / wport
Created January 28, 2016 08:33
who has opened that port, probably mac-specific
wport() {
lsof -n -i4TCP:$1
}
@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 / 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 / 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 / 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 / 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 / gist:c333970b1f8ecd925b0e
Last active August 29, 2015 14:23
massive git remote migration
for GIT_DIR in $(find . -name ".git"); do git --git-dir=$GIT_DIR remote -v | cut -d ' ' -f 1 | uniq | grep old_repo | sed 's/old_repo/new_repo/' | xargs -n 2 git --git-dir=$GIT_DIR remote set-url; done
@mgurov
mgurov / gist:93062e3afaad5d09f0b2
Created June 8, 2015 21:15
.git/hooks/post-commit: sync remote automatically
#!/bin/sh
if git remote | grep autosync > /dev/null; then
for remote in $(git remote | grep autosync); do
git push $remote --all -f
done
fi
@mgurov
mgurov / gist:a58c010889124a0095b6
Created December 29, 2014 07:43
dual table at apache spark
import org.apache.spark.sql._
val hc = new org.apache.spark.sql.hive.HiveContext(sc)
val schema = StructType(Seq(StructField("dual", StringType, true)))
val rowRDD = sc.parallelize(Seq(Row("dual")))
val schemaRDD = hc.applySchema(rowRDD, schema)
schemaRDD.registerTempTable("dual")
hc.hql("select 'hello world' from dual").collect