Skip to content

Instantly share code, notes, and snippets.

View epoz's full-sized avatar

Etienne Posthumus epoz

View GitHub Profile
from nfdi4culture import cto
from lidolator import from_file
item = cto.Item()
item.datafeed = "https://nfdi4culture.de/id/E5320"
# Or should we have cto.DataFeed("https://nfdi4culture.de/id/E5320") and the rest happens from there?
# either of the above will set things like .publisher on the Item too.
# and create the relevant schema.DataFeedItem and schema.DataFeed triples?
@epoz
epoz / Dockerfile
Created November 19, 2021 15:34
Demo of running a REACT SPA using Starlette/FASTAPI in a Dockerfile
FROM node:10 as build
WORKDIR /usr/src
COPY package*.json ./
RUN npm install
COPY . ./
RUN npm run build
FROM python:3.7.9-alpine
COPY requirements.txt requirements.txt
RUN pip install -r requirements.txt
@epoz
epoz / gooier.py
Created December 10, 2023 20:14
Falcon script to server contents of multiple directories on single root path over HTTP for X-Accel-Redirect headers
import falcon
import falcon.asgi
import os
async def diefolt(req, resp, **kwargs):
_, filename = os.path.split(req.path)
resp.status = falcon.HTTP_404
resp.text = f'{filename} Not Found'
SOURCES = ['/data/ap/beeldbank_images/', '/data/blm/images/']
for s in SOURCES:
@epoz
epoz / beeldbank_marc_to_rdf.py
Created December 8, 2023 14:15
Test converting the UVA Library Beeldbank MARC XML data to simple RDF
from xml.etree import ElementTree as ET
import marcalyx
import pyoxigraph as px
import os
from rich.progress import track
MARCXML_FILENAME = os.environ.get("MARCXML_FILENAME", "uva_alma_beeldbank_marc_new.xml")
def main():
@epoz
epoz / oai.py
Last active August 10, 2023 05:47
OAI Downloader
import httpx, os
import xml.etree.ElementTree as ET
OUTPATH = "./harvest"
def parse(result:str):
doc = ET.fromstring(result)
buf = doc.findall('.//{http://www.openarchives.org/OAI/2.0/}record')
token = doc.find('.//{http://www.openarchives.org/OAI/2.0/}resumptionToken')
if token is not None:
@epoz
epoz / README.md
Last active April 4, 2023 13:51
Compiling a directory of scss files, from TYPO3

Compiling SCSS files

From the files stored in the portal repo at https://gitlab.rlp.net/adwmainz/nfdi4culture/portal/culture_portal/-/tree/main/Resources/Private/Assets/Sass I would like to compile a seprate bundled .css file so that I can include it in the NFDI4Culture KG for some sample queries and documentation.

The index.js file is placed in ./src/index.js And all the scss files are places in ./src/scss

In the sample file js file I am only including the header.scss file for now as a test, to get things working.

from rdflib import *
from rich.progress import track
hydra_graph = Graph()
hydra_graph.parse(
"https://nfdi4culture.de/resource.ttl?tx_lod_api[limit]=999&tx_lod_api[page]=1"
)
output_graph = Graph()
resources = [
@epoz
epoz / spellfix.c
Created June 14, 2022 14:07
Spellfix1 extension for sqlite3
/*
** 2012 April 10
**
** The author disclaims copyright to this source code. In place of
** a legal notice, here is a blessing:
**
** May you do good and not evil.
** May you find forgiveness for yourself and forgive others.
** May you share freely, never taking more than you give.
**
@epoz
epoz / Dockerfile
Created April 5, 2022 16:48
Running transcrypt in Docker
FROM ubuntu:focal
ARG DEBIAN_FRONTEND=noninteractive
RUN apt-get update -y && apt-get upgrade -y
RUN apt-get -y install python3 python3-pip default-jre-headless
RUN pip3 install transcrypt==3.9.0 htmltree==0.7.6
RUN mkdir /out
WORKDIR /out
@epoz
epoz / Dockerfile
Created November 7, 2021 14:17
Running Prometheus on Ubuntu 20.04 via docker
FROM prom/prometheus
ADD prometheus.yml /etc/prometheus/