Skip to content

Instantly share code, notes, and snippets.

@djeikyb
djeikyb / ef.sh
Last active June 21, 2022 19:42
Wrapper around dotnet-ef cli
#!/bin/sh
SELF=${0##*/}
die() {
log "$@"
exit 1
}
log() {
@djeikyb
djeikyb / projvars
Last active January 14, 2020 20:56
transmute env vars; from asp core launchSettings.json to real env vars
#!/bin/sh
SELF=${0##*/}
die() {
log "$@"
exit 1
}
log() {
@djeikyb
djeikyb / example_date_formats
Last active October 29, 2019 16:42
how to use the date command (found on stackoverflow ages ago and didn't save a link)
#!/bin/sh
cat << EOD
Format/result | Command | Output
--------------------------------+----------------------------+------------------------------
YYYY-MM-DD_hh:mm:ss | date +%F_%T | $(date +%F_%T)
YYYYMMDD_hhmmss | date +%Y%m%d_%H%M%S | $(date +%Y%m%d_%H%M%S)
YYYYMMDD_hhmmss (UTC version) | date --utc +%Y%m%d_%H%M%SZ | $(date --utc +%Y%m%d_%H%M%SZ)
YYYYMMDD_hhmmss (UTC version) | date -u +%Y%m%d_%H%M%SZ | $(date -u +%Y%m%d_%H%M%SZ)
YYYYMMDD_hhmmss (with local TZ) | date +%Y%m%d_%H%M%S%Z | $(date +%Y%m%d_%H%M%S%Z)
@djeikyb
djeikyb / pgbr
Created October 9, 2019 21:21
backup/dump and restore from and to postgres docker containers
#!/bin/sh
SELF=${0##*/}
CONTAINER="postgres:10-alpine"
die() {
log "$@"
exit 1
}
@djeikyb
djeikyb / clonebulkgitlab.sh
Created October 9, 2019 18:50
clone all repos in a gitlab group
#!/bin/sh
die() {
log "$@"
exit 1
}
log() {
printf "$SELF: %s\n" "$@" >&2
}

How I used two mock libraries to test internal virtual methods

TL;DR

Neither [nsubstitute][1] nor [moq][0] can mock internal virtual methods by default. Help them help you. Add this to the csproj of your main assembly:

<ItemGroup>
@djeikyb
djeikyb / alwaysok.docker-compose.yml
Last active September 12, 2019 23:23
a busy http server that's always ok
version: "3.3"
okayHttpServer:
image: busybox
ports: [ "8080:8080" ]
command: "sh -c \"while true; do echo -n -e 'HTTP/1.1 200 OK\n\n🎉' | nc -p 8080 -l ; done\""
@djeikyb
djeikyb / nodewatch
Last active April 26, 2019 17:41
restarts node process when files change
#!/bin/sh
pid=''
exec node $* &
pid=$!
printf "started $1, $pid\n"
fswatch --one-per-batch --latency 1 --recursive --exclude '.*' --include '\.js$' . | while read event; do
@djeikyb
djeikyb / SrvLookup.cs
Last active April 30, 2019 16:23
dotnetcore dns lookup for srv records
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Threading.Tasks;
using DnsClient;
namespace
{
public class DnsSrvClient
@djeikyb
djeikyb / git-solo
Created November 6, 2018 01:13
for when the build server breaks without a pull request
#!/bin/sh
repo="d3sw/falkor"
token=${GITHUB_TOKEN:?}
localref=${1:-HEAD}
remoteBranch=${2:-jacobstaging}
merge() {
http \