Skip to content

Instantly share code, notes, and snippets.

@jakobii
jakobii / DockerMinecraftServerSetup.md
Last active December 22, 2024 16:23
Minecraft Server with Docker

Running a Minecraft Server with Docker on Ubuntu

Managing your Mincraft server with docker is a little bit nicer than just using the old "screen -r Mincraft" trick. docker can do snaphoting and auto restarting, and will allow you to think of the Mincraft server as a service, not just a java file that is being executed. Heres how I built mine. You should not have to edit the docker files. Just make sure you replace minecraft jar file version inside the code blocks when specified.

obviosly the only difference if your not using Ubuntu is the installation of java and the installation of docker

how to build it

Install all the things

@jakobii
jakobii / HTTPServer.ps1
Last active May 4, 2024 14:02
A Basic Powershell Webserver
# You Should be able to Copy and Paste this into a powershell terminal and it should just work.
# To end the loop you have to kill the powershell terminal. ctrl-c wont work :/
# Http Server
$http = [System.Net.HttpListener]::new()
# Hostname and port to listen on
$http.Prefixes.Add("http://localhost:8080/")

On MS SQL Server

to Accurately calcutalte the age of something this works for most situations

SELECT
  FLOOR( --floor function returns age in years
    CAST( DATEDIFF( DAY, /*StartDate*/ , /*EndDate*/ ) AS DEC(38,16) ) / CAST(365.2425 AS DEC(38,16)) 
  ) As AgeInYears

FROM SomeTable
@jakobii
jakobii / opts.proto
Created May 28, 2021 16:05
Proto3 Optional Scalar Values
message Double {
oneof value {
None none = 1;
double some = 2;
}
}
message Float {
oneof value {
None none = 1;
float some = 2;
@jakobii
jakobii / certs.sh
Last active April 1, 2021 17:36 — forked from mrw34/postgres.sh
Enabling SSL for PostgreSQL in Docker
#!/bin/bash
set -e
sudo rm -f server.req privkey.pem server.key server.crt
# https://www.postgresql.org/docs/11/ssl-tcp.html
openssl req -new -text -passout pass:abcd -subj /CN=localhost -out server.req -keyout privkey.pem
openssl rsa -in privkey.pem -passin pass:abcd -out server.key
openssl req -x509 -in server.req -text -key server.key -out server.crt
chmod og-rwx server.key
@jakobii
jakobii / postgres_ssl.md
Last active March 10, 2020 23:46
Enable ssl connections on postgres 12 on ubuntu 18.04

uuid regex in golang

the straght forward answer

[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}

https://www.cockroachlabs.com/docs/stable/start-a-local-cluster-in-docker-linux.html

create cluster

sudo docker network create -d bridge roachnet
sudo docker run -d --name=roach1 --hostname=roach1 --net=roachnet -p 26257:26257 -p 8080:8080  -v "${PWD}/cockroach-data/roach1:/cockroach/cockroach-data" cockroachdb/cockroach:v19.2.2 start --insecure --join=roach1,roach2,roach3
sudo docker run -d --name=roach2 --hostname=roach2 --net=roachnet -v "${PWD}/cockroach-data/roach2:/cockroach/cockroach-data" cockroachdb/cockroach:v19.2.2 start --insecure --join=roach1,roach2,roach3
sudo docker run -d --name=roach3 --hostname=roach3 --net=roachnet -v "${PWD}/cockroach-data/roach3:/cockroach/cockroach-data" cockroachdb/cockroach:v19.2.2 start --insecure --join=roach1,roach2,roach3
@jakobii
jakobii / run_task_on_remote_servers_in_parallel.ps1
Last active January 7, 2020 20:07
Remote PSSession Tasks
# This is a scriptblock that will be invoked on the remote computer. This is
# just dummy code that gets the computers hostname from the global built in
# eniorment variable $env.
$RemoteTask = {
param(
[datetime]$Start
)
# pause remote script execition until the specified start time.
# you can use this to loosely sync jobs execution.
@jakobii
jakobii / gzip_http_response.go
Last active November 14, 2019 21:15
gzip golang http responses
//https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Encoding
func writeOptimizedHttpResponse(w http.ResponseWriter, r *http.Request, b []byte, contentType string) {
w.Header().Set("Content-Type", contentType)
encodings := r.Header.Get("Accept-Encoding")
switch {
case strings.Contains(encodings, "gzip"):
w.Header().Set("Content-Encoding", "gzip")