| default: | |
| gcc -O0 -g3 -Wall -Wextra -Wconversion -Wdouble-promotion \ | |
| -Wno-unused-parameter -Wno-unused-function -Wno-sign-conversion \ | |
| main.c | |
| format: | |
| clang-format -i main.c |
| #!/bin/bash | |
| # Copyright 2017 Théo Chamley | |
| # Permission is hereby granted, free of charge, to any person obtaining a copy of | |
| # this software and associated documentation files (the "Software"), to deal in the Software | |
| # without restriction, including without limitation the rights to use, copy, modify, merge, | |
| # publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons | |
| # to whom the Software is furnished to do so, subject to the following conditions: | |
| # | |
| # The above copyright notice and this permission notice shall be included in all copies or |
| FROM golang:1.21.0-bullseye as builder | |
| COPY . /workdir | |
| WORKDIR /workdir | |
| ENV CGO_CPPFLAGS="-D_FORTIFY_SOURCE=2 -fstack-protector-all" | |
| ENV GOFLAGS="-buildmode=pie" | |
| RUN go build -ldflags "-s -w" -trimpath ./cmd/app |
A traditional table-based DFA implementation looks like this:
uint8_t table[NUM_STATES][256]
uint8_t run(const uint8_t *start, const uint8_t *end, uint8_t state) {
for (const uint8_t *s = start; s != end; s++)
state = table[state][*s];
return state;
}
| #!/bin/bash | |
| # http://redsymbol.net/articles/unofficial-bash-strict-mode/ | |
| set -euo pipefail | |
| IFS=$'\n\t' | |
| # inspired by | |
| # https://gist.github.com/codeinthehole/26b37efa67041e1307db | |
| # https://github.com/why-jay/osx-init/blob/master/install.sh | |
| # https://github.com/timsutton/osx-vm-templates/blob/master/scripts/xcode-cli-tools.sh |
Some time has past (three years!) since I last wrote about API specifically about coroutines style APIs so I thought why not write another one about a different API type I encounter relatively often. The builder API.
Now first let me take a step back and put this into 20,000 feet view on where builder APIs are located in the grant scheme. In general everything in computing is separated into input, processing and finally output. In its most basic form I am currently typing on my keyboard. All pressed keys are processed from the OS up to the browser I am writing this in and finally rendered and displayed on the screen as output. Of course this example is very user centric
Information in this Gist originally from this github issue, which is outdated.
As @RomanMinkin mentioned, you can also consider Casbin (https://github.com/casbin/casbin). It is the most starred authorization library in Golang. There are several differences between Casbin and OPA.
| Feature | Casbin | OPA |
|---|---|---|
| Library or service? | Library/Service | Library/Service |
| How to write policy? | Two parts: model and policy. Model is general authorization logic. Policy is concrete policy rule. | A single part: Rego |
| RBAC hierarchy | Casbin supports role hierarchy (a role can have a sub-role) | Role hierarchies can be encoded in data. Also with the new graph.reachable() built-in function queries over those hierarchies are much more feasible now. |
| RBAC separation of duties | Not supported | Supported: two roles cannot be assigned together |
| #include <stdio.h> | |
| #include <stdlib.h> | |
| #include <stdint.h> | |
| #include <assert.h> | |
| #include <string.h> | |
| #include <stdarg.h> | |
| #include <limits.h> | |
| #define cast(t,p) ((t)(p)) | |
| #define szof(a) ((int)sizeof(a)) |
