Skip to content

Instantly share code, notes, and snippets.

@mausch
mausch / Dockerfile
Created May 27, 2020
Nix on Jupyter on Docker
View Dockerfile
FROM jupyter/minimal-notebook:36bce751008f
USER root
RUN apt-get update && apt-get install -y curl
RUN mkdir /nix
RUN chown jovyan /nix
ENV PATH=/home/jovyan/.nix-profile/bin:$PATH
View gist:b94d8626e440d15b9eb944c6b1deab7c
Kudos to https://matthewbauer.us/blog/static-nix.html
$ docker run --rm -it -w /root alpine
$ apk add curl
$ curl https://matthewbauer.us/nix -o nix && chmod +x nix
$ ./nix run -f channel:nixpkgs-unstable awscli -c aws --version
aws-cli/1.17.13 Python/3.7.7 Linux/4.19.116 botocore/1.14.13
View awscli2.nix
let
pkgs = import <nixpkgs> {};
awscli = with pkgs; stdenv.mkDerivation {
name = "awscli";
src = fetchzip {
url = https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip;
sha256 = "1pqvqhxbikqnji7nazvaqnk2czlmr3kvs1zyl13w96ym4if3np1v";
};
propagatedBuildInputs = with pkgs; [
];
@mausch
mausch / dbeaver.sh
Created May 13, 2020
Run DBeaver in docker
View dbeaver.sh
#!/bin/bash
set -eu
cat << 'EOF' > ~/dbeaver.dockerfile
FROM openjdk:14-slim
RUN apt-get update && apt-get install -y wget libgtk-3-dev
ENV VERSION 6.2.1
RUN wget https://dbeaver.io/files/${VERSION}/dbeaver-ce-${VERSION}-linux.gtk.x86_64.tar.gz
RUN tar xvzf dbeaver-ce-${VERSION}-linux.gtk.x86_64.tar.gz
RUN rm dbeaver-ce-${VERSION}-linux.gtk.x86_64.tar.gz
@mausch
mausch / crash.log
Created May 3, 2020
JetBrains Rider 2020.1 crash
View crash.log
Internal error. Please refer to http://jb.gg/ide/critical-startup-errors
java.util.concurrent.CompletionException: com.intellij.ide.plugins.StartupAbortedException: Fatal error initializing 'com.jetbrains.rider.protocol.ProtocolManagerInitializer'
at java.base/java.util.concurrent.CompletableFuture.encodeThrowable(CompletableFuture.java:314)
at java.base/java.util.concurrent.CompletableFuture.completeThrowable(CompletableFuture.java:319)
at java.base/java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java:1739)
at com.intellij.openapi.application.TransactionGuardImpl$2.run(TransactionGuardImpl.java:201)
at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:831)
at com.intellij.openapi.application.impl.ApplicationImpl.lambda$invokeLater$4(ApplicationImpl.java:310)
at com.intellij.openapi.application.impl.FlushQueue.doRun(FlushQueue.java:80)
@mausch
mausch / aws-workspaces.sh
Last active Apr 27, 2020
Run AWS WorkSpaces client on any Linux distro supporting Docker
View aws-workspaces.sh
#!/usr/bin/env bash
set -eu
dockerfile=$(mktemp)
trap "rm $dockerfile" EXIT
cat << EOF > $dockerfile
FROM ubuntu:bionic
RUN apt-get update && apt-get install -y wget gnupg2
@mausch
mausch / newtypes.cs
Created Apr 25, 2020
newtypes in C#
View newtypes.cs
interface IValue<out T>
{
T Value { get; }
}
interface INewTypeEq<TSelf, TValue> : IValue<TValue>, IEquatable<TSelf>
where TValue : IEquatable<TValue>
where TSelf : INewTypeEq<TSelf, TValue>
{
TSelf New(TValue value);
View configuration.nix
# Edit this configuration file to define what should be installed on
# your system. Help is available in the configuration.nix(5) man page
# and in the NixOS manual (accessible by running ‘nixos-help’).
{ config, pkgs, ... }:
{
imports =
[ # Include the results of the hardware scan.
./hardware-configuration.nix
@mausch
mausch / gist:7834888398af8bac39277fcecb394389
Created Jan 10, 2020
Get current EC2 spot prices in your region
View gist:7834888398af8bac39277fcecb394389
# thanks to https://stackoverflow.com/a/32967407 for the CSV output
aws ec2 describe-spot-price-history --product-description "Linux/UNIX (Amazon VPC)" --start-time "$(date +%s)" | jq '.SpotPriceHistory | group_by(.InstanceType) | [.[] | min | {InstanceType, SpotPrice}]' | jq -r '(.[0] | keys_unsorted) as $keys | $keys, map([.[ $keys[] ]])[] | @csv' | less
@mausch
mausch / avro-registry-check.sh
Last active Oct 21, 2019
Checks Avro compatibility between a schema stored in a Confluent schema registry and a schema stored in a local file
View avro-registry-check.sh
#!/bin/bash
set -eu
tmpfile="current-schema.avro"
SCHEMA_REGISTRY_URL="${SCHEMA_REGISTRY_URL:-http://elevate.kafka.local:8081}"
curl -s $SCHEMA_REGISTRY_URL/subjects/${2}-value/versions/latest | jq '.schema' -r | jq '' > $tmpfile
trap "rm $tmpfile" INT TERM HUP EXIT
~/avro-check.sh check --old-schema /work/$tmpfile --new-schema /work/$1
You can’t perform that action at this time.