Skip to content

Instantly share code, notes, and snippets.

@strygul
strygul / ResilientClientSamples.scala
Created June 17, 2022 07:58 — forked from mishriky/ResilientClientSamples.scala
Samples for Finagle Client Configuration
/**
* This is not meant to cover ALL possible ways of creating service clients; instead it focuses on the simplest way to
* do so, while maintaining the capability to customize the clients based on service level agreements/expectations
*
* @note Most of the filters can be applied to the HTTP client as well but have been omitted from the sample code to improve
* readability
*/
trait ClientSamples extends LazyLogging {
private[this] lazy val config = ConfigFactory.load()
@strygul
strygul / convo_streamer_execution_plan_after_optimizing_tags.txt
Last active January 26, 2021 11:03
Convo streamer query execution plan after optimizing tags
EXPLAIN ANALYZE SELECT
filtered_conversations.numeric_id AS id,
filtered_conversations.created_at,
filtered_conversations.initial_channel,
filtered_conversations.requester_user_id AS requester_id,
users1.name AS requester_name,
users1.email AS requester_email,
users1.phone_number AS requester_phone_number,
filtered_conversations.queued_at,
@strygul
strygul / convo_streamer_execution_plan_before_optimizing_tags
Last active January 26, 2021 11:04
Convo streamer query execution plan before optimizing tags
SELECT
filtered_conversations.numeric_id AS id,
filtered_conversations.created_at,
filtered_conversations.initial_channel,
filtered_conversations.requester_user_id AS requester_id,
users1.name AS requester_name,
users1.email AS requester_email,
users1.phone_number AS requester_phone_number,
filtered_conversations.queued_at,
filtered_conversations.queue_id,
@strygul
strygul / es_join_query_with_filter_for_children_example
Created July 27, 2020 14:50
An example of a join query for Elasticsearch with an extra filter for children
"GET my_index_name/_search?"{
"query":{
"bool":{
"filter":[
{
"term":{
"organization_id":"some organization id"
}
}
],
@strygul
strygul / es_join_query_example
Last active July 27, 2020 14:41
An example of a join query for Elasticsearch
GET my_index_name/_search?
{
"query": {
"bool": {
"filter": [
{
"term": {
"organization_id": "some organization id"
}
}
@strygul
strygul / es_testcontainers_test_example.go
Created March 25, 2020 19:55
Testing Elasticsearch With Testcontainers
package elasticsearch
import (
"bytes"
"context"
"fmt"
log "github.com/sirupsen/logrus"
"github.com/testcontainers/testcontainers-go"
"github.com/testcontainers/testcontainers-go/wait"
"os"
@strygul
strygul / elasticsearc_client_mock.go
Created March 12, 2020 10:17
How to mock Elasticsearch client for unit testing
package elasticsearch_test
import (
"context"
"github.com/olivere/elastic/v7"
"github.com/stretchr/testify/assert"
"net/http"
"net/http/httptest"
"testing"
)
@strygul
strygul / Dump
Last active March 18, 2019 13:49
Scripts to dump and restore MongoDB that resides in a Docker container
#!/bin/sh
export CONTAINER_NAME="mongodb-planets"
export DATABASE_NAME="planets"
export BACKUP_LOCATION="/home/planets/Projects/datenkollektiv/backups"
export TIMESTAMP=$(date +'%Y%m%d%H%M%S')
docker exec -t ${CONTAINER_NAME} mongodump --out /data/${DATABASE_NAME}-backup-${TIMESTAMP} --db ${DATABASE_NAME}
docker cp ${CONTAINER_NAME}:/data/${DATABASE_NAME}-backup-${TIMESTAMP} ${BACKUP_LOCATION}
@strygul
strygul / Scala and SBT Dockerfile
Created February 2, 2019 23:15
A template to create a Dockerfile with Scala and SBT
#
# Scala and sbt Dockerfile
#
# Pull base image
FROM openjdk:8
# Env variables
ENV SCALA_VERSION 2.12.8
ENV SBT_VERSION 1.2.8
@strygul
strygul / youtube-dl.md
Created January 29, 2018 11:21
Using youtube-dl to download courses from Pluralsight

Download courses from learning sites with youtube-dl

You can download whole courses from an array of tutorial sites with the CLI tool youtube-dl. In the example further down I'm using my Pluralsight account to get videos from a course at their site. Here is a list of all supported sites that you can download from with this tool

The flags you have to supply may vary depending on which site you make a request to.

You can get a free 3 month trial to Pluralsight by signing up for free to Visual Studio Dev Essentials

Installation