Skip to content

Instantly share code, notes, and snippets.

@cboulanger
cboulanger / 10.1111_1467-6478.00057.xml
Last active August 17, 2024 20:51
TEI file as auto-generated from AnyStyle XML
<?xml version="1.0" ?>
<TEI xmlns="http://www.tei-c.org/ns/1.0">
<teiHeader>
<fileDesc>
<titleStmt>
<title>10.1111_1467-6478.00057</title>
</titleStmt>
<publicationStmt>
<publisher>mpilhlt</publisher>
</publicationStmt>
@cboulanger
cboulanger / download-hedgedoc-presentation.py
Last active May 28, 2024 16:52
Download a pad.gwdg.de presentation for local offline viewing. Script written with the help of ChatGPT4
import os
import re
import requests
from bs4 import BeautifulSoup
from urllib.parse import urljoin, urlparse
import argparse
def download_resource(session, url, base_dir, level=0):
try:
response = session.get(url, stream=True)
@cboulanger
cboulanger / hedgedoc-background.css
Last active May 17, 2024 06:07
Hedgedoc CSS to specify a common background image in CSS instead of manually and set an opacity to the background except for the title page
/* set the background image for all pages which have an (empty) <!-- .slide: data-background="" --> marker */
/* create overlay with background image */
.slide-background-content::before {
content: "";
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-image: url("image-url");
@cboulanger
cboulanger / parse-easychair-program.py
Created November 9, 2023 10:13
Parse an EasyChair conference programme to create a separate track overview. This requires a consistent naming scheme for the sessions. Cannot be used as-is.
import dateparser
import re
import requests
from bs4 import BeautifulSoup
import csv
from collections import defaultdict
url = "https://easychair.org/smart-program/<conference_name>/program.html"
track_url = "https://easychair.org/smart-program/<conference_name>/de_tracks.html"
css_url = "https://easychair.org/smart-program/<conference_name>/program.css"
@cboulanger
cboulanger / textual-schema-visualization.cypher
Created October 18, 2023 15:53
Neo4J Text-only equivalent for CALL db.schema.visualization()
// written with the help of ChatGPT4
MATCH (n)-[r]->(m)
WITH DISTINCT labels(n) AS ln, type(r) AS rt, labels(m) AS lm
WITH "(" + apoc.text.join(ln, ":") + ")-[:" + rt + "]->(" + apoc.text.join(lm, ":") + ")" AS CypherPathExpression
RETURN apoc.text.join(COLLECT(CypherPathExpression), '\n') AS GraphDataModel
@cboulanger
cboulanger / fetch-chrome-url.py
Created August 24, 2023 17:14
Get latest chrome or chromedriver download URLs
# written by GPT4
import requests
import json
import platform
import sys
import argparse
def get_latest_stable_version():
url = "https://googlechromelabs.github.io/chrome-for-testing/last-known-good-versions.json"
response = requests.get(url)
@cboulanger
cboulanger / sessions_by_track.py
Created June 20, 2023 14:08
Create a list of sessions ordered by tracks from an easychair.org conference programme
import dateparser
import re
import requests
from bs4 import BeautifulSoup
import csv
from collections import defaultdict
url = ".../program.html"
track_url = ".../tracks.html"
css_url = "..../program.css"
@cboulanger
cboulanger / install.sh
Last active March 17, 2023 07:26
String similarity with Ruby + Sqlite (Levenshtein distance / edit distance)
# see https://github.com/sparklemotion/sqlite3-ruby/issues/383#issuecomment-1473000796
SQLTITE_EXTENSIONS_DIR=/opt/sqlite-extensions # must exist
cd /tmp
git clone https://github.com/sqlite/sqlite.git
cd sqlite
gcc -g -fPIC -shared ./ext/misc/spellfix.c -o spellfix.o
sudo mv spellfix.o $SQLTITE_EXTENSIONS_DIR
rm -rf sqlite # clean up
@cboulanger
cboulanger / install-rbenv-pyenv.sh
Last active March 30, 2023 14:29
Install ruby 3.2.1 via rbenv on ubuntu and python 3.11 via pyenv - run as root!
#!/usr/bin/env bash
# run as root user
apt install -y git ruby-dev curl
# RUBY
cd ~
git clone https://github.com/rbenv/rbenv.git ~/.rbenv
echo 'eval "$(~/.rbenv/bin/rbenv init - bash)"' >> ~/.bashrc
library(tidyverse)
library(tidytext)
library(xts)
library(tstools)
base_dir = "C:\\Users\\Boulanger\\ownCloud\\Abteilung 3\\Projekte\\Legal Theory Graph"
corpus_dirs = c()
for (dir in list.dirs(base_dir)) {
if (dir != base_dir) {
corpus_dirs = c(corpus_dirs, dir)