Skip to content

Instantly share code, notes, and snippets.

View relistan's full-sized avatar

Karl Matthias relistan

View GitHub Profile
@relistan
relistan / README.md
Last active March 4, 2024 11:35
Cassandra: Golang-migrate wrapper with keyspace creation

Cassandra Migration With Keyspace Creation

The problem this solves: Golang-migrate supports Cassandra migrations but does not support creating the keyspace itself. This is annoying and leads to having to wrap it with other tooling or scripting to actually use it. Additionally, when running locally, Cassandra or ScyllaDB can take a fair bit of time to start. This tool solves that problem as well. It:

  • Creates keyspaces if they are missing before running the migrations
  • Checks and retries for up to a couple of minutes waiting for Cassandra to be available
@relistan
relistan / README.md
Last active February 17, 2024 17:10
Enable CAT control for WSJT-X on the (tr)uSDX on macOS

CAT Control on the (tr)uSDX for WSJT-X on macOS

This will enable CAT control on your Mac running WSJT-X with the (tr)uSDX and possibly other USDX rigs as well. WSJT-X uses Hamlib to connecto to and manage CAT on different radios. The problem (thanks to Guido PE1NNZ for identifying), is that Hamlib resets the port when it connects. This causes the radio to reset and then it's not yet available when Hamlib tries to connect. We can work around that by blocking the ability for Hamlib to reset the port. The simplest way to do that is to have the port already in use when Hamlib starts up.

I was not able to achieve that using the Hamlib built into WSJT-X. However, by installing Hamlib separately,

@relistan
relistan / download-jar.rb
Created January 18, 2024 18:28
Download Maven JARs from XML snippet
#!/usr/bin/env ruby
# This script accepts a blob of XML on ARGF/stdin like the following, and
# downloads the jar to the current directory.
#
# <dependency>
# <groupId>com.datastax.cassandra</groupId>
# <artifactId>cassandra-driver-core</artifactId>
# <version>3.0.8</version>
# <classifier>shaded</classifier>
@relistan
relistan / compress_requests.rb
Last active April 18, 2023 23:54 — forked from subdigital/compress_requests.rb
Rack Middleware to automatically unzip gzipped/deflated POST data
class CompressedRequests
def initialize(app)
@app = app
end
def method_handled?(env)
!!(env['REQUEST_METHOD'] =~ /(POST|PUT)/)
end
def encoding_handled?(env)
@relistan
relistan / connect.rb
Last active February 16, 2022 11:21
Connecting to Cassandra/SSL from JRuby with Datastax driver
def connect(addresses, dc_name)
builder = CqlSession.builder()
.withLocalDatacenter(dc_name)
addresses.each do |a|
(host, port) = a.split(/:/)
port ||= 9042
builder
.addContactPoint(InetSocketAddress.new(host.to_java_string, port.to_i))
.withAuthCredentials('[redacted]', '[redacted]')
@relistan
relistan / blockingreader.go
Last active September 7, 2021 02:56
block-docker-container
package main
import (
"fmt"
"io"
"os"
"github.com/fsouza/go-dockerclient"
)
@relistan
relistan / nitro_logback.lua
Created January 30, 2016 00:01
Logback standard output parser for Heka
-- A Heka Decoder for a semi-standard logback entry
local os = require("os")
local lpeg = require("lpeg")
local dash = lpeg.P("-")
local colon = lpeg.P(":")
local space = lpeg.S(" \t")
local eol = lpeg.P(-1)
@relistan
relistan / env_var.cr
Created September 29, 2019 16:27
Crystal Lang Env Var Mapping
module EnvVar
# Fetch a key from the environment, or set a default if the key
# is missing. If the default is nil, abort and request that the
# required key be set.
def get_env(key : String, default : String?, nilable : Bool) : String?
ENV[key]
rescue KeyError
if default.nil? && !nilable
abort "You must set a value for env var '#{key}'"
else

Keybase proof

I hereby claim:

  • I am relistan on github.
  • I am relistan (https://keybase.io/relistan) on keybase.
  • I have a public key ASAFN-_0eLk8YPjMdYWgLmXs9RxtcSbJmdQLMUXSLcG1fQo

To claim this, I am signing this object:

@relistan
relistan / env_var_provider.ex
Last active December 18, 2018 14:03
Elixir Distillery Env Var Provider
defmodule EnvVar.Provider do
use Mix.Releases.Config.Provider
require Logger
def init(app: app, prefix: prefix, env_map: env_map) do
persist(app, prefix, env_map)
end
# E.g.