Skip to content

Instantly share code, notes, and snippets.

View EmilDafinov's full-sized avatar

Emil Dafinov EmilDafinov

View GitHub Profile
@EmilDafinov
EmilDafinov / postman-pre-request.js
Created September 1, 2021 13:35 — forked from bcnzer/postman-pre-request.js
Postman pre-request script to automatically get a bearer token from Auth0 and save it for reuse
const echoPostRequest = {
url: 'https://<my url>.auth0.com/oauth/token',
method: 'POST',
header: 'Content-Type:application/json',
body: {
mode: 'application/json',
raw: JSON.stringify(
{
client_id:'<your client ID>',
client_secret:'<your client secret>',
@EmilDafinov
EmilDafinov / example.md
Created September 1, 2021 13:35 — forked from sdnts/example.md
Postman pm.sendRequest example

To send a request via the sandbox, you can use pm.sendRequest.

pm.test("Status code is 200", function () {
    pm.sendRequest('https://postman-echo.com/get', function (err, res) {
        pm.expect(err).to.not.be.ok;
        pm.expect(res).to.have.property('code', 200);
        pm.expect(res).to.have.property('status', 'OK');
    });
});
fsdfsd sdfsdfsdfsdfsdfs
@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)
@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

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 / 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
@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/
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
}
}