Skip to content

Instantly share code, notes, and snippets.

View qdm12's full-sized avatar

Quentin McGaw qdm12

View GitHub Profile
@qdm12
qdm12 / README.md
Created March 3, 2022 16:57
Go: mocks and subtests

Contents

  1. Presenting the potato code, part 1
  2. Using mockgen from golang/mock
  3. //go:generate commands for mocks generation
  4. CI check for updated mocks, see mocks.yml
  5. Testing CutAndFry with golang/mock, see potato_test.go part 1
  6. Mock calls order, see previousCall *gomock.Call
  7. Comparing with golang/mock with mockery, see potato_mockery_test.go
  8. Presenting the potato code, part 2
@qdm12
qdm12 / bench_test.go
Last active October 29, 2022 07:42
Fast thread-safe uniformly distributed numbers generation in Go
package main
import (
"crypto/rand"
"encoding/binary"
"fmt"
"hash/maphash"
mathrand "math/rand"
"runtime"
"sync"
@qdm12
qdm12 / main.go
Created May 11, 2021 14:39
Fetch API and send email (@clemone210)
package main
import (
"context"
"fmt"
"io"
"log"
"net"
"net/http"
"net/smtp"
@qdm12
qdm12 / main.go
Last active February 12, 2024 01:17
DNS over HTTPS server resolver under 300 lines of clean Go code
package main
import (
"bytes"
"context"
"crypto/tls"
"errors"
"fmt"
"io/ioutil"
"log"
@qdm12
qdm12 / Dockerfile
Created October 15, 2020 23:54
Domoticz docker image dockerfile
FROM debian:buster-slim
WORKDIR /domoticz
EXPOSE 8080/tcp 443/tcp 6144
ENTRYPOINT [ "/domoticz/domoticz" ]
RUN apt-get update -y && \
apt-get install -y wget libusb-0.1-4 libcurl3-gnutls && \
wget -q -O domoticz.tgz https://releases.domoticz.com/releases/release/domoticz_linux_x86_64.tgz && \
tar -xf domoticz.tgz && \
rm domoticz.tgz *.txt
@qdm12
qdm12 / README.md
Last active November 28, 2024 19:24
Wireguard and iptables restrictions for multiple users

Wireguard and iptables restrictions for multiple users

If you don't know what Wireguard is, well, you should. It's fast, easy to setup and highly configurable. We will configure Wireguard for multiple users with various restrictions using iptables.

Assumptions

This should fit most setups (not mine though 😉)

@qdm12
qdm12 / buildx-release.yml
Last active May 14, 2020 01:42
Buildx Release with Github Actions
name: Buildx release
on:
release:
types: [published]
paths-ignore:
- .github/workflows/buildx-latest.yml
- README.md
jobs:
buildx:
@qdm12
qdm12 / buildx-latest.yml
Created May 14, 2020 01:34
Buildx Latest with Github Actions
name: Buildx latest
on:
push:
branches: [master]
paths-ignore:
- .github/workflows/buildx-release.yml
- README.md
jobs:
buildx:
runs-on: ubuntu-latest
@qdm12
qdm12 / buildx-latest.yml
Created May 14, 2020 01:34
Buildx Latest with Github Actions
name: Buildx latest
on:
push:
branches: [master]
paths-ignore:
- .github/workflows/buildx-release.yml
- README.md
jobs:
buildx:
runs-on: ubuntu-latest
@qdm12
qdm12 / karabiner.json
Created February 11, 2020 17:37
Karabiner Elements configuration file for Mac OS
{
"global": {
"check_for_updates_on_startup": true,
"show_in_menu_bar": true,
"show_profile_name_in_menu_bar": false
},
"profiles": [
{
"name": "Default profile",
"selected": true,