Skip to content

Instantly share code, notes, and snippets.

@Shemeikka
Shemeikka / restore_test.sh
Created November 9, 2020 09:11
Script for testing PostgreSQL database backups and WAL files. Script downloads backup file from S3 bucket and creates a new PostgreSQL server from that backup. The script uses restore_command to replay WAL files.
#!/bin/bash
# Exit immediately if any step fails
set -eo pipefail
# Variables
host=<hostname>
datetime=$(date +"%Y-%m-%dT%H%M")
tmp_folder=/tmp/restore_test_${datetime}
@Shemeikka
Shemeikka / fizzbuzz.exs
Created October 30, 2019 17:49
Simple FizzBuzz example using Elixir
defmodule FizzBuzz do
defguard is_fizz(value) when is_integer(value) and rem(value, 3) == 0
defguard is_buzz(value) when is_integer(value) and rem(value, 5) == 0
def run(val) do
1..val
|> Enum.each(fn val -> word(val) |> IO.inspect() end)
end
defp word(val) when is_fizz(val) and is_buzz(val), do: "fizzbuzz"
@Shemeikka
Shemeikka / queue_test.py
Created November 22, 2017 16:36
Small benchmarks for Python queues
from collections import deque
import Queue
import time
import gevent.queue
def queue_test(n):
q = Queue.Queue()
start = time.time()
@Shemeikka
Shemeikka / filebeat.log
Created October 3, 2017 11:58
Filebeat 6.0.0-beta2 fatal error log
sh-4.2# e ./filebeat
fatal error: concurrent map read and map write
goroutine 392 [running]:
runtime.throw(0x160e97d, 0x21)
/usr/local/go/src/runtime/panic.go:596 +0x95 fp=0xc4206f88f0 sp=0xc4206f88d0
runtime.mapaccess1_faststr(0x14ad120, 0xc42013fc50, 0xc4202866fb, 0x40, 0x0)
/usr/local/go/src/runtime/hashmap_fast.go:217 +0x4cf fp=0xc4206f8950 sp=0xc4206f88f0
github.com/elastic/beats/libbeat/processors/add_docker_metadata.(*watcher).Container(0xc42013fc80, 0xc4202866fb, 0x40, 0x1460d60)
/go/src/github.com/elastic/beats/libbeat/processors/add_docker_metadata/watcher.go:88 +0x4f fp=0xc4206f8988 sp=0xc4206f8950
@Shemeikka
Shemeikka / quota.yaml
Created March 10, 2017 16:33
Kubernetes resource quota
apiVersion: v1
kind: ResourceQuota
metadata:
name: khightower-compute-resources
namespace: khightower
spec:
hard:
services: "5"
pods: "5"
requests.cpu: "2"
@Shemeikka
Shemeikka / sns.py
Last active February 25, 2017 14:05
Example on how to work with AWS SNS with Boto3. This requires that you have set AWS credentials to your ~/.aws/credentials and the default region in ~/.aws/config
import boto3
client = boto3.client('sns')
response = client.publish(
TopicArn='<your topic arn>',
Message='<your message>'
)
print("Response: {}".format(response))
@Shemeikka
Shemeikka / links.txt
Last active February 18, 2017 15:02
Youtube channels - Dev stuff
@Shemeikka
Shemeikka / gist:7d6f37bc704b04cbbc5c6e33e39c748b
Created January 25, 2017 17:21
Description of how to use data volumes and stuff..
# https://github.com/docker/docker/issues/30441#issuecomment-275124802
You can still use the same volume for two services. If I understand correctly, you have a separate image holding the data, purely for propagating the volume? Say that that image is named mydataimage, you can do something like this;
version: "3.0"
services:
init:
image: mydataimage
volumes:
@Shemeikka
Shemeikka / gist:11f196884212dc650e828c2f71c4bddf
Created November 8, 2016 18:36
Elixir Genserver callbacks and return values
# GenServer callbacks and return values
## init(args)
{:ok, state}
{:ok, state, timeout}
:ignore
{:stop, reason}
## handle_call(msg, {from, ref}, state)
@Shemeikka
Shemeikka / bmi.elm
Last active September 25, 2016 09:43
Simple BMI calculator written in Elm
import Html exposing (..)
import Html.App exposing (beginnerProgram)
import Html.Attributes as HA exposing (..)
import Html.Events exposing (onClick, onInput)
import String
main =
beginnerProgram { model = model, view = view, update = update }