Skip to content

Instantly share code, notes, and snippets.

View Alxandr's full-sized avatar
⁉️
⁉️

Aleksander Heintz Alxandr

⁉️
⁉️
View GitHub Profile
pub struct Envelope<M: Message> {
message: M,
context: SpanContext,
}
impl<M: Message> Envelope<M> {
pub fn new(message: M) -> Self {
let context = Span::current().context().span().span_context().clone();
Self { message, context }
}
@Alxandr
Alxandr / Yuniql test blabla.cs
Created December 6, 2023 12:50
Yuniql test blabla.cs
using Altinn.ResourceRegistry.Persistence.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Testcontainers.PostgreSql;
using Yuniql.Core;
namespace Altinn.ResourceRegistry.Persistence.Tests;
public abstract class DbTests : IAsyncLifetime
{
[Node]
public class Foo
{
private readonly FooDto _dto;
public Foo(FooDto dto)
=> _dto = dto;
// Optional attribute - this is as an alternative to use `[Node(IdField = "Id")]` - and not needed when the field is called "Id".
// I just think this is a better discovery mechanism than Setting an `IdField`. It's also more similar to thinks like `[Key]` etc.
index = (ulid[0] & 224) >> 5;
output[0] = alphabet[index];
index = ulid[0] & 31;
output[1] = alphabet[index];
index = (ulid[1] & 248) >> 3;
output[2] = alphabet[index];
index = ((ulid[1] & 7) << 2) | ((ulid[2] & 192) >> 6);
@Alxandr
Alxandr / Dockerfile
Created January 16, 2021 00:32
appartment-heater
############################################################
## BASE IMAGE
############################################################
FROM ubuntu:latest as base
ARG DEBIAN_FRONTEND=noninteractive
RUN apt-get update && \
apt-get install -y software-properties-common && \
apt-add-repository universe && \
public static class FooBar
{
public static string Foo { get; } = "Foo";
public static string Bar { get; } = "Bar";
public static IEnumerable<string> All { get; } = GetAll().ToImmutableList();
static IEnumerable<string> GetAll()
{
foreach (var prop in typeof(FooBar).GetProperties(BindingFlags.Static | BindingFlags.Public | BindingFlags.DeclaredOnly))
k3os-17054 [~]$ k3s check-config
Verifying binaries in /var/lib/rancher/k3s/data/688c8ca42a6cd0c042322efea271d6f3849d3de17c850739b0da2461f6c69ee8/bin:
- sha256sum: good
- links: good
System:
- /usr/sbin iptables v1.8.3 (legacy): ok
- swap: disabled
- routes: ok
@Alxandr
Alxandr / safeish.rs
Last active December 15, 2020 19:02
use crate::tag::TagLookup;
use git2::Repository;
pub struct Context {
// NOTE: This lifetime is fake
tags: TagLookup<'static>,
// IMPORTANT: this has to be last to be dropped last
repo: Box<Repository>,
}
trait ValueCaster {
unsafe fn cast_to_any(&self, b: Box<dyn Value>) -> Box<dyn Any>;
}
struct BoxCaster<V: Value>(PhantomData<V>);
impl<V: Value> BoxCaster<V> {
const INSTANCE: BoxCaster<V> = BoxCaster(PhantomData);
}
public static class Extensions
{
// Temporary workaround until https://github.com/ChilliCream/hotchocolate/issues/2522 is resolved
public static LocaleDirective ToLocaleDirective(this IDirectiveContext context)
{
var node = context.Directive.ToNode(removeNullArguments: false);
CultureInfo culture;
var cultureArgument = node.Arguments.FirstOrDefault(t => t.Name.Value == "culture");
switch (cultureArgument)