Skip to content

Instantly share code, notes, and snippets.

View aanastasiou's full-sized avatar

Athanasios Anastasiou aanastasiou

View GitHub Profile
@aanastasiou
aanastasiou / main.py
Created April 10, 2020 18:26
Graphml to Networkx Conversion
"""
Reads a Graphml file and instantiate the right type Networkx graph.
Notes:
1. This is still work in progress. At its current state, the code will comfortably read "simple" graphml files.
2. The next step is to enable the routine to selectively read in (graph, node, edge) level data based on the
namespace used.
3. This will probably be implemented with named tuples and it should support at least simple reads (if not full
complex writes too).
@aanastasiou
aanastasiou / README.md
Last active November 6, 2020 18:45
Simple expression to parsing tree in graphviz

Expression to parse tree visualisation

Call with something like:

    > echo '11*19 + 3 * 9'|python exp2gviz.py -|dot -Earrowsize=0.4 -Nfixedsize=1 -Grankdir=BT -Tpng>gviz_out.png;feh gviz_out.png

To get something like:

image

@aanastasiou
aanastasiou / main.py
Created November 20, 2022 21:19
Tiny scheme-like language to try out the structural pattern matching features in Python 3.10 onwards
"""
A very small scheme-like language to try out the structural pattern matching
features of python 3.11
Features:
* Mathematical expressions +,-,*,/ involving integers, variables and functions
* Functions are defined via lambda.
* Values (including functions) are assigned to variables via let
For more information regarding the concepts this language depends on, see:
@aanastasiou
aanastasiou / stacklang.rsc
Last active March 12, 2023 21:22
A simple stack language expressed in Rascal
module stacklang_list::stacklang_list
// A very simple stack language
//
// The stack is represented as a list with the top of the stack extending the list from the left.
// For example, to add two numbers: eval([add(), push(1), push(1)])
import IO;
// Symbols
@aanastasiou
aanastasiou / main.py
Created March 9, 2023 11:09
Code to locate the specific "Washington, D.C." entry that causes a constrain validation upon ingesting ROR.
"""
A brief script to indicate the "location" of a possibly misspelled 'Washington'
in the current (v1.20-2023-02-28-ror-data.json) ROR dataset
:author: Athanasios Anastasiou
:date: Mar 2023
"""
import json
@aanastasiou
aanastasiou / automatic_path_inflation_brief_test.py
Created August 11, 2023 14:18
Minor demo for neomodel's #716
from neomodel import (config, StructuredNode, StringProperty, IntegerProperty,
UniqueIdProperty, RelationshipTo, db)
import os
class Country(StructuredNode):
code = StringProperty(unique_index=True, required=True)
class City(StructuredNode):
name = StringProperty(required=True)
country = RelationshipTo(Country, 'FROM_COUNTRY')