Skip to content

Instantly share code, notes, and snippets.

Avatar
🐓

Julian Bruyat BruJu

🐓
View GitHub Profile
View quad-star-multinested-store.js
'use strict';
/*
* This script enables to store multi nested quads in an N3.Store
* Usage:
* Add quads with addQuadsWithoutMultiNesting(store, quads)
* The store will contain the quads, but 2sd level nested quads will be replaced with a blank node
* When you have a quad for which you want the true version, use remakeMultiNesting(store, quads)
*
@BruJu
BruJu / pgoContext.ttl
Last active Jun 30, 2021
Property Graph Ontology Context
View pgoContext.ttl
PREFIX prec: <http://bruy.at/prec#>
PREFIX pvar: <http://bruy.at/prec-trans#>
PREFIX pgo: <http://ii.uwb.edu.pl/pgo#>
PREFIX ex: <http://example.org/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
# A PREC Context to produce RDF graphs similar to the one produced by graphConv
# PREC: https://github.com/BruJu/PREC
# graphConv: https://github.com/domel/graphConv
@BruJu
BruJu / graph-reducer.js
Created May 14, 2021
Leftovers code from PREC
View graph-reducer.js
// === transformProperties
// TODO:
// if (asSet) {
// for (const bind of newB) {
// noList(store, bind.x);
// }
// }
View StoreAlterer.js
"use strict";
//! I was too lazy to learn how to use another Triple Pattern Matching and
//! Replacement library, let alone find one that is not async await heavy,
//! so I built one...
const DataFactory = require('n3').DataFactory;
const variable = DataFactory.variable;
/**
@BruJu
BruJu / printPropertyMapper.js
Created Apr 19, 2021
PropertyMapper::printPropertyMapper
View printPropertyMapper.js
// https://github.com/BruJu/PREC/blob/master/prec3/vocabulary-reader.js
// Developed for debug purpose
function PropertyMapper::printPropertyMapper() {
console.error("PropertyMapper {");
console.error(` iri:`);
console.error(this.iri);
console.error(" description node:");
console.error(this.descriptionNode);
console.error(" src:");
View Unblanknode.js
const N3 = require('n3');
/**
* Return the description of the `term`.
*
* The description is:
* - the term itself if it is not a blank node
* - if it is a blank node, a list of every [predicate, object] for which
* there exists a (term, predicate, object) quad in the default graph of the
* store
@BruJu
BruJu / test.js
Created Apr 8, 2021
One day i'll learn how to write an issue
View test.js
const assert = require('assert');
const N3 = require('n3');
const namespace = require('@rdfjs/namespace');
const ex = namespace("http://example.org/", N3.DataFactory);
const rdf = namespace("http://rdf.org/", N3.DataFactory);
describe('N3 Parser', function() {
it('should parse nested nested quad', function() {
let q = (new N3.Parser()).parse("<< << <sss> <ssp> <sso> >> <sp> <so> >> <p> <o> .")[0];
@BruJu
BruJu / julian.ttl
Last active Apr 1, 2021
julian.ttl
View julian.ttl
<http://bruy.at/julian> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://schema.org/Person> .
@BruJu
BruJu / manual_enum_dispatch.rs
Last active Jan 19, 2021
manual_enum_dispatch.rs
View manual_enum_dispatch.rs
/*
The problematic:
I want enum dispatch for a trait.
I could used
https://docs.rs/enum_dispatch/0.3.5/enum_dispatch/
View simple.cpp
#include "../advent_of_code.hpp"
#include "../util/regex_helper.hpp"
#include <map>
// https://adventofcode.com/2015/day/17
namespace {
size_t to(const std::vector<int> & containers, const std::vector<int> & leftovers, int target, size_t i = 0) {
// Solution