Skip to content

Instantly share code, notes, and snippets.

View VictorioBerra's full-sized avatar

Victorio Berra VictorioBerra

View GitHub Profile
@VictorioBerra
VictorioBerra / pocketbase.instructions.md
Created April 24, 2026 15:24
Pocetbase and Pocketpages Instructions File

This project uses PocketBase, and a lesser known UI project called PocketPages.

Pocketbase has a way to extend it with the JSVM which runs inside GoJA. This lets us register endpoints, event hooks, cron jobs all in JS running inside Pocketbase managed GoJA (JSVM).

PocketPages builds on this by having a folder/file based routing system, and allows us to run JS in the JSVM in server-side html blocks in the pocketpages pages.

For example, PB lets you create JSVM scripts in pb_hooks, just name it whatever.pb.js. PP lets us create a page like index.ejs, gives us a <script server> block, and that code will run in the JSVM when the page is rendered. We have full access to the PB API, and a set of PP helpers.

IE for PB you can do $app.findRecordsByFilter where $app is the main interface to interact with your database.

{
"#info": {
"title": "Hello World 2!!!",
"updated": "Nov 24 2020"
},
"img": "this is the ![logo](img/ok.png) and this is the [link](#)",
"menu": ["[Home](#section-1) [Section 1](#section-1) [Section 2](#section-2) [Page 1](/about)"],
"title": "# Hello World 2!!!",
"subtitle": [
"_It is a long **established fact** that a reader will be distracted by the readable content of a page when looking at its layout._"
@VictorioBerra
VictorioBerra / ForwardedForKnownNetworkOptions.cs
Created January 21, 2020 20:51
ForwardedHeadersOptions from appsettings.json
public class ForwardedForKnownNetworkOptions
{
public string Prefix { get; set; }
public int PrefixLength { get; set; }
}
@VictorioBerra
VictorioBerra / MyAppAuithorizationPolicyprovider.cs
Created May 3, 2019 22:19
Custom DefaultAuthorizationPolicyProvider which can distinguish between a token with and without a subject, and then handle requirements accordingly.
//
// This is a combination of two things:
//
// A slight alteration of the implementation of DefaultAuthorizationPolicyProvider that creates a new PermissionRequirement similar to the PolicyServer's for later use with IPolicyServerRuntimeClient in a requirement handler.
// But only if theres a subject claim.
//
// A slight alteration of the ClaimsAuthorizationRequirement.
// Works identically to the default implemenation, but only if theres no subject claim.
//