Skip to content

Instantly share code, notes, and snippets.

View AndreSteenveld's full-sized avatar

Andre Steenveld AndreSteenveld

View GitHub Profile
@AndreSteenveld
AndreSteenveld / compose-files
Last active March 21, 2024 05:49
Helper script to gather docker-compose files
#! /usr/bin/env bash
cf__help(){
printf '%s\n' \
'compose-files - Helper script to gather docker-compose files ' \
' ' \
'Usage: ' \
' compose-files [options --] [presets] ' \
' ' \
@AndreSteenveld
AndreSteenveld / TupleAsArray.Test.cs
Created February 2, 2022 04:47
System.Text.Json tuple (de)serializer
// This work is licensed under a Creative Commons Attribution 4.0 International License
// If you find a bug or some issue you can find me (and the orginal of this file) at https://gist.github.com/AndreSteenveld
using System;
using System.Text.Json;
using Json = System.Text.Json;
using Xunit;
using Tuple = System.Tuple;
namespace AndreSteenveld.Test
{
@AndreSteenveld
AndreSteenveld / wait-for-sql-server
Last active November 15, 2021 12:53
Bash script that waits for SQL server to accept logins
#! /usr/bin/env bash
wfss__help() {
printf '%s\n'\
'wait-for-sql-server - Tries to connect to sql server otherwise fails ' \
' ' \
'Usage: ' \
' wait-for-sql-server [options] -- <sqlcmd options> ' \
' wait-for-sql-server <sqlcmd options> ' \
@AndreSteenveld
AndreSteenveld / dump-to-csv
Last active November 24, 2021 08:46
Dumping table from SQL server to SQLite
#! /usr/bin/env bash
set -e
#
# Invoke this script; dump-to-csv <database> <schema> <table> -U sa -P 'P455word!!!' -S localhost
#
# The output will be written to stdout, redirecting to where you need your csv to go. Make sure `bcp`
# is in your path, in the docker images it can be found in /opt/mssql-tools/bin
#
@AndreSteenveld
AndreSteenveld / table-to-tsv.sh
Created November 4, 2021 14:46
Using bcp to dump table to csv
#! /usr/bin/env bash
set -e
#
# Invoke this script; table-to-tsv <database> <schema> <table> -U sa -P 'P455word!!!' -S localhost
#
# The output will be written to stdout, redirecting to where you need your tsv to go. Make sure `bcp`
# is in your path, in the docker images it can be found in /opt/mssql-tools/bin
#
@AndreSteenveld
AndreSteenveld / OptionJsonConverter.cs
Created July 16, 2021 07:42 — forked from gmanny/OptionJsonConverter.cs
JsonConverter for LanguageExt.Option which serializes empty Options as nulls.
using System;
using System.Collections.Concurrent;
using System.Linq;
using System.Reflection;
using LanguageExt;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
public class OptionJsonConverter : JsonConverter
{
@AndreSteenveld
AndreSteenveld / INSTALL.md
Created April 20, 2021 21:08
Installing pacman on git for windows

Why?

I recently made a fresh install of windows and all the tools I needed to develop software including git-for-windows. Unfortunatnly git-for-windows doesn't come with a packagemanager buildt in and going full cygwin seems a little overkill. After some research I ran in to this post on stackoverflow describing a way to install pacman in to git-for-windows. Unfortuntly only "most of it" worked in my case. This document attempts to describe the entire process I went through to install pacman.

Prepare

The packages in the MSYS2 repositoy seem to be packaged using zstd now and not xz as described. Obviously it would be great to use a package manager to install zstd and un-tar the files... Given that this guide is geared towards windows installs you can install 7zip and add the Modern7z plugins to unpack zstd files.

Downloading and unpacking the neccesary packages

@AndreSteenveld
AndreSteenveld / winpty
Created December 10, 2020 15:15
winpty stub for nix
#!/usr/bin/env bash
eval "$@" <(cat)
#
# Every now and then I have to write scripts which will work from git-bash as well as a proper *nix
# system. Adding this on my *nix system helps with the strangeness which is git-bash. All we would
# like to do here is redirect all the stdin, out and err "like winpty does" on a windows system.
#
# Clearly on *nix there is no need to translate between tty and the terminal serivice on windows.
#
@AndreSteenveld
AndreSteenveld / Dockerfile
Last active October 9, 2020 13:24
Self contained docker registry
# syntax = docker/dockerfile:experimental
#
# A self contained docker registry
#
# Why? - I needed a way to transport multiple images and some tooling between different machines
# which would all have a docker daemon running on them. Packaging everything in to a single
# registry gives me a convinent package while also minimising my interactions with the target machine.
#
# How? - In a nutshell what is happening is that we start with a bootstrap registry in which we will
@AndreSteenveld
AndreSteenveld / jsonnet
Last active November 4, 2020 10:56
Using the jsonnet docker image
#! /usr/bin/env bash
# The script wraps around the jsonnet docker image to so it can be run without installing
# python locally. This script is also geared towards a windows setup as it currently is
# environment I'm working in. With the exception of the TTY wrappers I think this should
# generally work for any *nix system as well.
#
# Clearly access to a docker host is required to make this work... For a windows setup
# we will also be assuming that all the relevant drives (C, D, whatever) are mounted on
# the docker host under "/c", "/d", etc.