Skip to content

Instantly share code, notes, and snippets.

View BruJu's full-sized avatar
🐓

Julian Bruyat BruJu

🐓
View GitHub Profile
@BruJu
BruJu / Unary.cpp
Last active January 15, 2023 09:24
Unary.cpp
#include <iostream>
#include <string>
#include <optional>
class MessageEncoder {
std::optional<int> current_digit = std::nullopt;
std::string output;
public:
@BruJu
BruJu / idk.cpp
Created December 21, 2022 11:38
idk
#include "../advent_of_code.hpp"
#include <algorithm>
#include <vector>
#include <array>
void print_line(const std::vector<bool> & values) {
for (const auto b : values) {
std::cout << (b ? 'X' : ' ');
}
@BruJu
BruJu / CppLisilibyTips.md
Last active July 12, 2022 19:03
C++ Lisibility Tips

Comment avoir 8/6 à la partie programmation du projet de Génie Log

(quand c'est moi qui note)

Ne pas utiliser de variables globales

Les variables globales nuisent à la lisibilité du code. S'il y a des variables globales, les entrées de vos fonctions peuvent être n'importe quoi : on ne sait pas si des valeurs issues de variables globales seront utilisées en entrées ou pas.

@BruJu
BruJu / InJava.java
Last active April 21, 2022 16:12
TypeScript strange downcast rules
// ==== Basic Elements
class Elem {
public String id;
}
class NamedElem extends Elem {
public String name;
}
@BruJu
BruJu / SyntaxTreeToXML.ts
Created April 5, 2022 09:12
SyntaxTreeToXML
/** Convert a CodeMirror Syntax Tree to an XML-like string */
function treeToXML(tree: Tree): string {
let t = "";
tree.iterate({
enter(type) { t += "<" + type.name + ">"; },
leave(type) { t += "</" + type.name + ">"; }
});
return t;
}
@BruJu
BruJu / bad_object_suggestion.diff
Created March 29, 2022 14:41
Bad Object suggestion
diff --git a/shacled-turtle/src/schema/MetaDataState.ts b/shacled-turtle/src/schema/MetaDataState.ts
index 3b5b47b..b24af9d 100644
--- a/shacled-turtle/src/schema/MetaDataState.ts
+++ b/shacled-turtle/src/schema/MetaDataState.ts
@@ -2,6 +2,7 @@ import TermMap from "@rdfjs/term-map";
import TermSet from "@rdfjs/term-set";
import * as RDF from "@rdfjs/types";
import Schema from ".";
+import { addTermPairInTermMultiMap } from "../util";
import { MetaBaseInterface, MetaBaseInterfaceComponent } from "./MetaDataInterface";
@BruJu
BruJu / shacl.shape.ttl
Created March 29, 2022 10:18
SHACl shapes
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix sh: <http://www.w3.org/ns/shacl#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix shsh: <http://www.w3.org/ns/shacl-shacl#> .
# from https://www.w3.org/TR/shacl/#shacl-shacl
shsh:
@BruJu
BruJu / logicRuleDebug.ts
Created March 28, 2022 14:52
Logic Rule Debug
/* istanbul ignore next */
debugString(): string {
let strRules: string[] = [];
function debugMeta(info: MetaInfo | null): string {
if (info === null) return '.';
return "<< " + termToString(info.target) + " " + info.kind + " " + termToString(info.value) + " >>";
}
@BruJu
BruJu / full.ttl
Last active March 24, 2022 08:34
path06
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix ex: <http://example.org/> .
@prefix sh: <http://www.w3.org/ns/shacl#> .
@prefix schema: <http://schema.org/> .
ex:Target a sh:NodeShape ; sh:property [ sh:path ex:ok ] .
# Predicate Path
sh:Pathed01 a sh:NodeShape ;
@BruJu
BruJu / colornameontology.ttl
Created March 22, 2022 10:19
colornameontology.ttl
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix ex: <http://example.org/> .
@prefix sh: <http://www.w3.org/ns/shacl#> .
ex:firstname rdfs:domain ex:Named .
ex:Colored a rdfs:Class ;
sh:targetSubjectsOf ex:color .