Skip to content

Instantly share code, notes, and snippets.

View white-gecko's full-sized avatar

Natanael Arndt white-gecko

View GitHub Profile
@white-gecko
white-gecko / docker-compose
Created March 8, 2024 20:45
A replacement for docker-compose to use podman-compose
#!/bin/sh
if [ $# -eq 1 ] && [ "$1" = "kill" ]; then
podman-compose kill --all
exit 0
fi
if [ "$1" = "rm" ]; then
podman-compose kill --all
if [ "$2" = "-v" ] ; then
podman volume rm --all
fi
for i in $( git log --oneline <path_to_file_in_repo> | awk '{print $1}' ); do git show --raw $i | grep <path_to_file_in_repo> | awk '{print $4}' | xargs git show --raw | diff -w <path_to_my_file> - | grep "^>" | wc -l ; echo $i ; done
@white-gecko
white-gecko / qname.sty
Last active May 3, 2021 15:56
This is a LaTeX package which provides support for prefixes in qnames. It depends on the url- and the hyperref-package
% This package provides support for prefixes in qnames
%
% Defined commands:
% \setprefix{foaf}{http://xmlns.com/foaf/0.1/}
% Define a prefix namespace
% \getprefix{foaf}
% Get a defined prefix namespace
% \prefix{foaf}
% Just output the prefix linked to the namespace
% \qname{foaf:Person} has to contain a colon
#!/usr/bin/env python3
import timeit
REP = 100
def perf_set():
for i in range(REP):
'a' in {'a', 'b', 'c', 'd', 'e'}
'c' in {'a', 'b', 'c', 'd', 'e'}
@white-gecko
white-gecko / kmp_match.php
Created October 20, 2012 22:58
Knuth-Morris-Pratt-Algorithm
<?php
/**
* This is an implementation of the Knuth-Morris-Pratt-Algorithm as in
* Thomas H. Cormen et. al.: "Algorithmen - Eine Einführung"
* (German version by Paul Molitor) 3. Auflage, page 1017
*
* My changes:
* - Indexes starting with 0
* - overlapping matches are recognized
*/
ComparableGraph
-> Menge von AtomicGraph
ConjunctiveGraph
-> Menge von ComparableGraph
-> Menge von AtomicGraph
=> Blank Node Scope beschränkt auf einen Graph
ConjunctiveGraph
-> Menge von AtomicDatasets
@white-gecko
white-gecko / dataset-construct-literal.sparql
Last active November 13, 2019 19:01
If you want to query a complete dataset with a single construct query.
PREFIX ex: <http://example.org/>
CONSTRUCT {
?s ?p ?o .
?g a ex:Graph ;
ex:hasData ?datalit .
} WHERE {
{
?s ?p ?o .
} UNION {
@white-gecko
white-gecko / example.py
Last active November 7, 2019 16:11
sqlite python example
#!/usr/bin/env python3
# starting with https://docs.python.org/3.8/library/sqlite3.html
import sqlite3
conn = sqlite3.connect('example.db')
c = conn.cursor()
c.execute("DROP TABLE IF EXISTS stocks")
c.execute("DROP TABLE IF EXISTS stuff")
@white-gecko
white-gecko / hashcmptest.py
Created October 31, 2019 12:25
Play around with a hashable and comparable object in python
#!/usr/bin/env python3
class mE():
def __init__(self, value):
self.v = value
# we need __hash__ and __eq__ for the set
def __hash__(self):
# the maximum length of hash is restricted by the platform:
# https://docs.python.org/3/reference/datamodel.html#object.__hash__
@white-gecko
white-gecko / statusled
Created November 11, 2012 01:10
Initscript to switch LED1 on Olinuxino A13 on and off
#!/bin/bash
#
# Initscript to switch LED1 on Olinuxino A13 on and off
#
### BEGIN INIT INFO
# Provides: statusled
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6