Skip to content

Instantly share code, notes, and snippets.

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

Aleksander Heintz Alxandr

⁉️
⁉️
View GitHub Profile
const HIGHEST_BIT_MASK: u32 = 1 << 31;
#[repr(C)]
#[derive(Portable)]
pub struct ArchivedHeaderName {
// if the highest bit is unset, this is a known header index
// else this is 10 bits of length followed by 21 bits of relative pointer
inner: u32_le,
}
@Alxandr
Alxandr / serialize.rs
Last active November 2, 2024 23:07
headers
#[repr(C)]
#[derive(Portable)]
struct ArchivedHttpResponse {
/// The body of the response.
body: ArchivedBox<[u8]>,
/// The headers of the response.
headers: ArchivedBox<[(ArchivedHeaderName, ArchivedBox<[u8]>)]>,
/// The status code of the response.
{
// not part of the resource - just here to describe what kind of resource this is about
"_description": "Resurs som delegeres i 'biter'",
"actions": null,
"subResources": {
"create": {
"type": "write", // this is an enum used to determin what kind of icon to show in the UI
"name": {
"nb": "Opprett skjema",
"en": "Create form"
[
{
"id": "order-licence-plate",
"action": "order",
"resource": {
// urn:altinn:resouce er arvet, så den skippes
"urn:svv:area": "license-plates"
},
"name": {
"no": "Bestill skilt",
{
"rights": {
"required": [
{ "...": "..." },
{ "...": "..." }
],
"unwanted": [
{ "...": "..." },
{ "...": "..." }
]
SELECT
p.uuid p_uuid,
p.id p_id,
p.party_type p_party_type,
p.name p_name,
p.person_identifier p_person_identifier,
p.organization_identifier p_organization_identifier,
p.created p_created,
p.updated p_updated,
o.unit_status p_unit_status,
@Alxandr
Alxandr / join.sql
Last active September 2, 2024 09:29
register get-all queries
select
p.uuid p_uuid,
cp."uuid" cp_uuid,
co.unit_type,
p.id p_id,
p.party_type p_party_type,
p.name p_name,
p.person_identifier p_person_identifier,
p.organization_identifier p_organization_identifier,
p.created p_created,
// prereq: schema foo finnes og bruker 1 har lov til aa lage tabeller der, og bruker 2 har ikke men har lov til aa lese
{
await using var db = CreateConnection("connstr1");
db.Exec("CREATE TABLE foo.bar (id INT PRIMARY KEY)");
}
{
await using var db = CreateConnection("connstr2");
db.Exec("SELECT * FROM foo.bar"); // works
@Alxandr
Alxandr / EnumExtensions.cs
Created June 20, 2024 06:37
EnumExtensions
using CommunityToolkit.Diagnostics;
using System.Runtime.CompilerServices;
namespace Namespace;
internal static class EnumExtensions
{
/// <summary>
/// Returns a value indicating whether the specified value has any of the specified flags set.
/// </summary>
/// <summary>
/// Creates a new <see cref="ValidationErrorInstance"/> with the specified <paramref name="descriptor"/>.
/// </summary>
/// <param name="descriptor">The <see cref="ValidationErrorDescriptor"/>.</param>
/// <returns>A <see cref="ValidationErrorInstance"/>.</returns>
public static ValidationErrorInstance Create(ValidationErrorDescriptor descriptor) =>
new ValidationErrorInstance(descriptor, paths: [], extensions: []);
/// <summary>
/// Creates a new <see cref="ValidationErrorInstance"/> with the specified <paramref name="descriptor"/> and <paramref name="path"/>.