Skip to content

Instantly share code, notes, and snippets.

View mommi84's full-sized avatar
🔮
AI-Driven Strategic Foresight

Tom Soru mommi84

🔮
AI-Driven Strategic Foresight
View GitHub Profile
@mommi84
mommi84 / extend.sh
Created September 10, 2019 14:27
Extend Ubuntu SSD in AWS
# After having extended the SSD size via AWS console:
ubuntu@ip-172-31-46-157:~$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
loop1 7:1 0 18M 1 loop /snap/amazon-ssm-agent/1455
loop2 7:2 0 88.7M 1 loop /snap/core/7396
loop3 7:3 0 89M 1 loop /snap/core/7713
xvda 202:0 0 100G 0 disk
└─xvda1 202:1 0 50G 0 part /
@mommi84
mommi84 / dbpedia_file_urls.sparql
Last active July 10, 2020 23:57
Get DBpedia file URLs by version and language.
#
# Endpoint: https://databus.dbpedia.org/repo/sparql
# Credits: @JJ-Author, @mommi84
#
PREFIX dataid: <http://dataid.dbpedia.org/ns/core#>
PREFIX dc: <http://purl.org/dc/terms/>
PREFIX dcat: <http://www.w3.org/ns/dcat#>
PREFIX dcv: <http://dataid.dbpedia.org/ns/cv#>
SELECT DISTINCT ?url WHERE {
@mommi84
mommi84 / sparql.py
Created October 31, 2018 14:23
SPARQL Query Execution in Python 2.7
import urllib2, urllib, httplib, json
import sys
MAX_RESULTS = 10000
graph = ""
endpoint = ""
# Execute a SPARQL query.
def sparql_query(query):
@mommi84
mommi84 / bib4rash.py
Created February 1, 2018 15:41
Script to convert BibTeX files into RASH bibliography.
#!/usr/bin/env python
import sys
import bibtexparser
reload(sys)
sys.setdefaultencoding("utf-8")
def fd(s):
if s[-1] != '.':
s += '.'
@mommi84
mommi84 / similarity_search.sparql
Last active January 20, 2018 16:17
SPARQL-based similarity search – Top entities of type X which share characteristics with Y
SELECT ?s (count(?o) AS ?c) {
{
<Y> ?p ?o .
?s ?p ?o ; a <X>
} UNION {
?o ?p <Y> , ?s .
?s a <X>
}
} GROUP BY ?s ORDER BY DESC(?c) LIMIT 11
@mommi84
mommi84 / prodimem.py
Last active December 24, 2017 18:07
ProDiMem – Processor, disk, memory monitor for computations.
#!/usr/bin/env python
"""
ProDiMem - Processor, disk, memory monitor for computations.
Usage:
python prodimem.py [PID] [SECONDS]
Author:
Tommaso Soru <[email protected]>
@mommi84
mommi84 / numbers_words.py
Created November 7, 2017 11:25
Conversion from integer numbers to English words.
#!/usr/bin/env python
"""
Conversion from integer numbers to English words.
Author: Tommaso Soru <[email protected]>
Example:
$ python numbers_words.py 3213213000312
threetrillionstwohundredsthirteenbillionstwohundredsthirteenmillionsthreehundredstwelve
@mommi84
mommi84 / foreachlod.py
Created September 27, 2017 19:12
For each (indexed) LOD dataset
#!/usr/bin/env python
import sys
import urllib2, urllib, httplib, json
reload(sys)
sys.setdefaultencoding("utf-8")
ENDPOINT = "http://stats.lod2.eu/sparql"
GRAPH = ""
BUFFER = 10000
@mommi84
mommi84 / most-spec-types.sparql
Created April 2, 2017 13:19
Most specific types in SPARQL
PREFIX rdfs:<http://www.w3.org/2000/01/rdf-schema#>
SELECT DISTINCT ?s ?t2 WHERE {
?s a ?t2
MINUS {
?s a ?t1, ?t2 .
?t1 rdfs:subClassOf ?t2 .
}
}
@mommi84
mommi84 / awesome-kge.md
Last active March 15, 2025 19:08
Awesome Knowledge Graph Embedding Approaches