Skip to content

Instantly share code, notes, and snippets.

View EmilDafinov's full-sized avatar

Emil Dafinov EmilDafinov

View GitHub Profile
@EmilDafinov
EmilDafinov / travis_bintray_credentials.sh
Last active July 8, 2017 04:02
Creates the credentials file for sbt-bintray
#!/bin/bash
echo "Creating credentials directory"
mkdir ~/.bintray/
BINTRAY_FILE=$HOME/.bintray/.credentials
ARTIFACTORY_FILE=$HOME/.bintray/.artifactory
echo "Writing Bintray credentials file at $BINTRAY_FILE"
cat <<EOF >$BINTRAY_FILE
realm = Bintray API Realm
host = api.bintray.com
@EmilDafinov
EmilDafinov / Future-retry.scala
Last active April 18, 2017 16:00 — forked from viktorklang/Future-retry.scala
Asynchronous retry for Future in Scala
import akka.actor.Scheduler
import akka.pattern.after
import scala.concurrent.{ExecutionContext, Future}
import scala.concurrent.duration._
/**
* Given an operation that produces a T, returns a Future containing the result of T, unless an exception is thrown,
* in which case the operation will be retried after _delay_ time, if there are more possible retries, which is configured through
* the _retries_ parameter. If the operation does not succeed and there is no retries left, the resulting Future will contain the last failure.
@EmilDafinov
EmilDafinov / bintray_settings.xml
Created May 17, 2017 19:56
A maven settings.xml file configured for bintray deployment
<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<pluginGroups>
</pluginGroups>
<proxies>
</proxies>
implicit val getResultWithColumns = new GetResult[Map[String, AnyRef]] {
override def apply(v1: PositionedResult) = {
val metadata = v1.rs.getMetaData
(1 to metadata.getColumnCount)
.map(index => metadata.getColumnLabel(index) -> v1.nextObject())
.toMap
}
}
@EmilDafinov
EmilDafinov / gist:7d87b32ca83e398f25820e6593dff0aa
Created October 7, 2017 20:03
Sample HAPROXY configuration
# Sample docker-compose service configuration that would use the haproxy config below
#haproxy:
# image: haproxy:1.7-alpine
# ports:
# - "9998:80"
# - "9999:81"
# volumes:
# - ./haproxy/:/usr/local/etc/haproxy/
@EmilDafinov
EmilDafinov / gist:48258cdaa3017d664e067bdfc999b390
Created October 7, 2017 23:45
Docker compose snippet for a wiremock HTTP mock. Dupm
# Provides mocking for any HTTP services the reporting service
# depends on.
# See http://wiremock.org/docs/stubbing/ for details
# Place files in the mapped directory for defining pre-canned HTTP responses
dummy-http:
image: rodolpheche/wiremock:2.8.0-alpine
volumes:
- ./wiremock/:/home/wiremock/mappings

Keybase proof

I hereby claim:

  • I am emildafinov on github.
  • I am edafinov (https://keybase.io/edafinov) on keybase.
  • I have a public key ASDhWVt_uRBe-oJ63kpeVkSOZTjeiP0auxs0eIl8SPTJLQo

To claim this, I am signing this object:

@EmilDafinov
EmilDafinov / get-latest-tag-on-git.sh
Created January 5, 2018 02:36 — forked from rponte/get-latest-tag-on-git.sh
Getting latest tag on git repository
# The command finds the most recent tag that is reachable from a commit.
# If the tag points to the commit, then only the tag is shown.
# Otherwise, it suffixes the tag name with the number of additional commits on top of the tagged object
# and the abbreviated object name of the most recent commit.
git describe
# With --abbrev set to 0, the command can be used to find the closest tagname without any suffix:
git describe --abbrev=0
# other examples
@EmilDafinov
EmilDafinov / get-latest-tag-on-git.sh
Created January 5, 2018 02:36 — forked from rponte/get-latest-tag-on-git.sh
Getting latest tag on git repository
# The command finds the most recent tag that is reachable from a commit.
# If the tag points to the commit, then only the tag is shown.
# Otherwise, it suffixes the tag name with the number of additional commits on top of the tagged object
# and the abbreviated object name of the most recent commit.
git describe
# With --abbrev set to 0, the command can be used to find the closest tagname without any suffix:
git describe --abbrev=0
# other examples
@EmilDafinov
EmilDafinov / gist:72360dcae1cb8c84597dc7c3342d0c88
Created January 9, 2018 21:48
Get distance from last tag from describe
#If you are wondering what the heck is going on here, we
# describe -> which gives us a string like "[last-tag]-[distance-from-last-tag]-[current-tag-hash]"
# reverse the string
# use cut with delimiter '-' to get the second token
# the reverse is done bacause the last tag can potentially contain '-' characters
echo $(echo "${$(git describe)}"| rev | cut -d '-' -f 2)