Skip to content

Instantly share code, notes, and snippets.

View anatoly-scherbakov's full-sized avatar

Anatoly Scherbakov anatoly-scherbakov

View GitHub Profile
@anatoly-scherbakov
anatoly-scherbakov / test_n3_base_iri_without_a_slash.py
Created December 19, 2020 07:38
RDFLib: import N3 data with @base IRI which does not include a slash
import rdflib
DOCUMENT = """
@base <local:> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
<class_to_class>
a
rdfs:Class ,
<Category> ;
"""
Question about importing JSON-LD @included contents.
Published at:
https://gist.github.com/anatoly-scherbakov/d5ddeb6a0a8651ba5d148aa36a752699
This is supplementary material for this GitHub issue:
https://github.com/RDFLib/rdflib-jsonld/issues/98
"""
Question about importing JSON-LD @graph contents into a named graph with
specifically provided IRI instead of an IRI taken from the @id.
Published at:
https://gist.github.com/anatoly-scherbakov/e1c75db34a262f7aa107d82399c50c52
This is supplementary material for this StackOverflow question:
"""
Import JSON-LD document into RDFLib graph.
The schema of @base IRI can lead RDFLib to silently refuse the import.
This is supplementary code for: https://github.com/RDFLib/rdflib-jsonld/issues/97
"""
import json
import textwrap
"""
Test JSON-LD expand operation in PyLD.
Supplementary code for https://github.com/digitalbazaar/pyld/issues/143
"""
import json
from pyld import jsonld
from typing import Generic, TypeVar
from pydantic import ValidationError
from pydantic.fields import ModelField
T = TypeVar('T')
class CommaSeparatedList(Generic[T]):
"""Parse and validate a list of comma separated values."""
@anatoly-scherbakov
anatoly-scherbakov / reserved-concurrency.sh
Created May 11, 2020 07:15
Reserved concurrency per AWS Lambda function
#!/usr/bin/env bash
get_concurrency="aws lambda get-function-concurrency --function-name {} | jq -r '\"{.},\( .ReservedConcurrentExecutions )\"'"
tmpfile=$(tempfile) || exit
aws lambda list-functions \
| jq -r '.Functions[] .FunctionName' \
| parallel "$get_concurrency" > ${tmpfile}
import dataclasses
from datetime import datetime
from typing import Optional, Dict, Iterable
@dataclasses.dataclass(frozen=True)
class Memento:
original_url: str
time: datetime
archived_headers_cid: str
import itertools
import functools
from typing import Iterator
import datetime
from dateutil.relativedelta import relativedelta
def month_range(
start: datetime.date,
@anatoly-scherbakov
anatoly-scherbakov / data.gql
Created March 30, 2020 20:02
Star Wars expressed in grakn.ai
insert
$jedi isa order, has name "Jedi";
$sith isa order, has name "Sith";
# Okay, let's start with some Jedi masters we know of.
$obi-wan isa human, has name "Obi-Wan Kenobi", has gender "male";
$obi-wan-is-jedi (member: $obi-wan, member-of: $jedi) isa membership;
# What do we know about Anakin?