Skip to content

Instantly share code, notes, and snippets.

# Usage: $ nix eval "(builtins.attrNames (import (builtins.fetchurl "https://matthewbauer.us/generate-versions.nix") {}).emacs)"
# $ nix run "(import (builtins.fetchurl "https://matthewbauer.us/generate-versions.nix") {}).emacs.\"24.3\"" -u LANG -c emacs
{}:
let
channels = [ "nixos-20.09" "nixos-20.03" "nixos-19.09" "nixpkgs-unstable" ];
getSet = channel: (import (builtins.fetchTarball "channel:${channel}") {inherit (builtins.currentSystem);}).pkgs;
@mausch
mausch / Dockerfile
Created May 27, 2020 08:32
Nix on Jupyter on Docker
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
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
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 14:34
Run DBeaver in docker
#!/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 14:46
JetBrains Rider 2020.1 crash
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 February 26, 2024 14:22
Run AWS WorkSpaces client on any Linux distro supporting Docker
#!/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 April 25, 2020 22:40
newtypes in C#
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);
@mausch
mausch / configuration.nix
Created January 25, 2020 16:52
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 January 10, 2020 17:53
Get current EC2 spot prices in your region
# 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