Skip to content

Instantly share code, notes, and snippets.

View tpluscode's full-sized avatar

Tomasz Pluskiewicz tpluscode

View GitHub Profile
@tpluscode
tpluscode / tui-editor.js
Created June 24, 2022 11:44
lit-tui-editor
import { css, html, LitElement, unsafeCSS } from 'lit'
import { customElement, property } from 'lit/decorators.js'
import Editor from '@toast-ui/editor'
import styles from '@toast-ui/editor/dist/toastui-editor.css'
@customElement('tui-markdown')
export class TuiMarkdown extends LitElement {
@property({ type: String })
public value: string | undefined = ''
@tpluscode
tpluscode / package.json
Created May 23, 2022 14:16
ts-node+mocha+esm+@types
{
"name": "mocha-ts-node",
"type": "module",
"scripts": {
"test": "mocha test.ts"
},
"dependencies": {
"@rdfjs/term-set": "2.0.1",
"@types/mocha": "9.1.1",
"@types/rdfjs__term-set": "2.0.0",
@tpluscode
tpluscode / .gitignore
Last active January 13, 2022 11:25
esbuild mirador
node_modules/
js/
@tpluscode
tpluscode / readme.md
Last active December 14, 2021 06:43
Annotating Hydra collection search template with SHACL Advanced Features

This is an idea for how SHACL AF Node Expression can be used to annotate a hydra search template so that values coming from the request query string would be transformed to SPARQL patterns an injeced into the resulting query

The collection resource <shapes> supports a targetNode query string parameter which should be translated to a SPARQL union like below. The $this token will represent each collection member (instance of shape). For example, when requesting shapes?targetNode=foobar, the generated patterns could be:

{
  # query the target node directly
  $this sh:targetNode <foobar>
}
UNION
@tpluscode
tpluscode / data.ttl
Created December 9, 2021 16:34
SHACL Compound properties
<data-file>
a schema:MediaObject ;
schema:identifier "sample-data.csv" ;
schema:encodingFormat "text/csv";
schema:contenUrl <https://s3.link/ugly-guid-link-whatever.csv>
.
@tpluscode
tpluscode / api.ttl
Last active April 14, 2021 10:54
Hydra relative
<api>
a hydra:ApiDocumentation ;
hydra:supportedClass :UserCollection ;
.
:UserCollection
a hydra:Class ;
hydra:supportedProperty [
hydra:property :searchUsers ;
] ;
@tpluscode
tpluscode / readme.md
Last active March 9, 2021 10:41
Managing multiple resources in one graph

The problem

You only have a single graph for multiple related and unrelated resources, which would be accessed over a web api (Hydra/LDP)

How do you handle updates and deletes to remove only the right triples.

Example

Consider the resources, as can be found in tbbt-ld. Let's take the representation of Amy and Sheldon.

Intro

This document presents some possible ideas for how a server request might get matched to the Hydra's API Documentation.

All turtle snippets ignore prefixes and base URI for bervity and only show the relevant subgraph. All requests assume Content-Type: text/turtle

@tpluscode
tpluscode / readme.md
Last active February 5, 2020 16:11
Alcaeus breaking changes

Main export

-import { Hydra } from 'alcaeus'
+import Hydra from 'alcaeus'

Remove Vocab export

@tpluscode
tpluscode / typedClownface.ts
Created December 16, 2019 18:38
Typed clownface
// WARNING
//
// Ugly implementation and not exactly like in the examples. but similar
import { Literal, NamedNode } from 'rdf-js'
import Clownface from 'clownface/lib/Clownface'
import rdf from 'rdf-ext'
import { TypedClownfaceEntity } from './TypedClownfaceEntity'
const trueLiteral: Literal = rdf.literal(true)