Skip to content

Instantly share code, notes, and snippets.

@danielskovli
danielskovli / Maskinporten.md
Last active June 14, 2024 08:42
Altinn IMaskinportenClient service implementation

Basic Maskinporten implementation

Prerequisites

  1. A Maskinporten client registered with a JWK pubkey for your target environment. Business certificates are not supported by this implementation.
  2. An Altinn Studio host application
  3. A local copy of the app-lib-dotnet branch containing the IMaskinportenClient service implementation

Usage

  1. App.csproj: Point to the local version of Altinn.App.Api and Altinn.App.Core packages with ProjectReference instead of PackageReference
  2. appsettings.json:
@danielskovli
danielskovli / gist:a137836ce688a0c275ce819327e7eaf5
Created May 15, 2024 12:10
Action delegates as configuration objects
using System;
var configuredWhatever = ConfigurationTest(x =>
{
x.Option1 = "Overwritten by caller";
x.Option2 = "Provided by caller";
});
Console.WriteLine(configuredWhatever);
Whatever ConfigurationTest(Action<Whatever> configureWhatever)
@danielskovli
danielskovli / shotgunThreadSafeTest.py
Last active May 5, 2022 04:02
Simple demo of a thread-safe implementation of Shotgun Python API via pool storage and a pool (context) manager
# -*- coding: utf-8 -*-
'''
Shotgun thread-safe API call demo for Python 3.x
Requires Shotgun Python API: https://github.com/shotgunsoftware/python-api
Context manager implementation based on concept from ArjanCodes: https://www.youtube.com/watch?v=Rm4JP7JfsKY
All code provided as a single file for ease of testing/demo. Should most definitely be split into
# -*- coding: utf-8 -*-
'''Simple ffmpeg demo
Presented as a single file here, but realistically needs to be split
in to various modules as it best fits within the host project
'''
from __future__ import annotations
import subprocess
from pyfbsdk import *
def getSelectedObjects():
'''Grab scene selection here and update UI/whatever'''
pass
def OnConnectionStateNotify(control, event):
'''Callback for all scene `ConnectionState` changes. Capture (un)select and process'''
if not event.Action in (FBConnectionAction.kFBSelect, FBConnectionAction.kFBUnselect):
return