Skip to content

Instantly share code, notes, and snippets.

View sebnyberg's full-sized avatar
🇸🇪

Sebastian Nyberg sebnyberg

🇸🇪
View GitHub Profile
@sebnyberg
sebnyberg / example.cs
Created December 7, 2021 20:51
Example Function App with mTLS + GRPC
using System;
using System.IO;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Extensions.Http;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using System.Security.Cryptography.X509Certificates;
@sebnyberg
sebnyberg / settings.json
Created December 6, 2021 14:43
VSCode settings
{
"[markdown]": {
"editor.quickSuggestions": true
},
"[python]": {
"editor.formatOnSave": true
},
"[go]": {
"editor.suggest.snippetsPreventQuickSuggestions": true
},
@sebnyberg
sebnyberg / .vimrc
Created December 6, 2021 14:41
Dotfile
set nocompatible
filetype plugin indent on
set encoding=utf-8
set fileencoding=utf-8
scriptencoding utf-8
set history=256
set timeoutlen=250
set clipboard+=unnamed " copy to clipboard
@sebnyberg
sebnyberg / main.go
Last active October 20, 2021 13:03
Basic http server example
package main
import (
"flag"
"fmt"
"log"
"net/http"
"github.com/gorilla/mux"
)
@sebnyberg
sebnyberg / example.py
Created October 6, 2021 14:34
Doccano API client using Azure KeyVault + basic auth + admin user
import sys
import os
from pprint import pprint
from azure.keyvault.secrets import SecretClient
from azure.identity import DefaultAzureCredential
import requests
api_base_url = os.environ.get("API_BASE_URL", "http://doccano.example.com")
@sebnyberg
sebnyberg / cert.sh
Created September 21, 2021 21:15
Create Kubernetes certs using openssl
#!/local/bin/env bash
#
# Create certs
#
set -eux
# Create Root CA cert
ca="rootca"
cat > $ca.conf << EOM
[ req ]
@sebnyberg
sebnyberg / account_client.go
Last active February 21, 2023 16:44
Some Azure Go SDK auth things
package azurex
import (
"context"
"errors"
"fmt"
"os"
"strings"
"github.com/Azure/azure-sdk-for-go/profiles/2020-09-01/resources/mgmt/subscriptions"
@sebnyberg
sebnyberg / main1.go
Last active March 5, 2021 21:55
Customizing Protobuf serialization in Go
package main
import (
"encoding/json"
"fmt"
"protojsonfmt/todo"
"github.com/google/uuid"
"google.golang.org/protobuf/types/known/timestamppb"
)
@sebnyberg
sebnyberg / predictions.ldjson
Last active November 11, 2022 09:44
Length-delimited Protobuf Streams
{ "image_id": "img13023", "category": "CAT", "probability": 0.9 }
{ "image_id": "img13024", "category": "DOG", "probability": 0.64 }
{ "image_id": "img13025", "category": "DOG", "probability": 0.58 }
@sebnyberg
sebnyberg / archive_1.sh
Last active January 6, 2021 18:43
Bash article
#!/usr/bin/env bash
#
# Make a backup and remove files
#
# Usage:
#
# ./archive $path $backup_path
#