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 / purlproxy.php
Created March 11, 2014 11:02
Proxy script for rewritng purl redirected URIs to the correct URLs for OntoWiki
<?php
$request = str_replace($_SERVER['SCRIPT_NAME'], '', $_SERVER['REQUEST_URI']);
$purl = 'http://purl.org' . $request;
$proxyTarget = array(
'/voc/ex/' => 'http://example.org/site/schema/?r=',
);
@white-gecko
white-gecko / listingshack.sty
Created November 6, 2014 11:06
LaTeX package for a cooler listing appearance
% This package fixes some issues with listings
% - Set a nice font
% - Add Turtle as langugage
% - Imprive XML style
% - Fix dashs/hyphens
%
% (c) 2013 Natanael Arndt
% LPPL LaTeX Public Project License
%
\NeedsTeXFormat{LaTeX2e}[1994/06/01]
@white-gecko
white-gecko / gecko.zsh-theme
Last active August 29, 2015 14:09
My zsh theme (you have to place it in ~/.oh-my-zsh/themes/ and change ZSH_THEME to gecko in your .zshrc)
# this theme was build be taking some code and impressions from mortalscumbag, intheloop, crcandy and bureau
bureau_git_branch () {
ref=$(command git symbolic-ref HEAD 2> /dev/null) || \
ref=$(command git rev-parse --short HEAD 2> /dev/null) || return
echo "${ref#refs/heads/}"
}
bureau_git_status () {
_INDEX=$(command git status --porcelain -b 2> /dev/null)
@white-gecko
white-gecko / ddict.py
Created July 8, 2015 10:56
Python Default Dictionary of Dictionaries
#! /usr/bin/env python3
from collections import defaultdict
def ddict ():
return defaultdict(ddict)
def ddict2dict(d):
for k, v in d.items():
if isinstance(v, dict):
@white-gecko
white-gecko / docker-env
Created August 7, 2015 13:29
Docker environment management with $DOCKER_ENV
#!/bin/bash
list ()
{
echo "local"
echo "remote1"
}
env_remote1 ()
{
export DOCKER_HOST="remote1.org:2375"
@white-gecko
white-gecko / datei
Last active May 4, 2016 18:38
Git merges
A
B
C
D
"""Untill https://github.com/RDFLib/rdflib/pull/807 is merged and released."""
from rdflib import Graph, BNode, URIRef
from six.moves.urllib.parse import urljoin
"""requirements.txt:
rdflib>=4.2.2
"""
def bNodeSkolemize(self, authority=None, basepath=None):
@white-gecko
white-gecko / makeBackup.sh
Created March 12, 2018 20:51
aksw.org backup script
#!/usr/bin/env bash
cd /home/seebi/backups
echo "dump_one_graph ('http://aksw.org/', '/tmp/akswdump_', 1000000000);" | isql-vt -U dba -P "the_password" >/dev/null
cp /tmp/akswdump_000001.ttl aksw.org.ttl
rapper -q -i turtle -o turtle /tmp/akswdump_000001.ttl >aksw.org.ttl
rapper -q -i turtle -o ntriples aksw.org.ttl | sort >aksw.org.nt
echo "dump_one_graph ('http://localhost/OntoWiki/Config/', '/tmp/owconfigdump_', 1000000000);" | isql-vt -U dba -P "the_password" >/dev/null
rapper -q -i turtle -o turtle /tmp/owconfigdump_000001.ttl >owconfig.ttl
rapper -q -i turtle -o ntriples owconfig.ttl | sort >owconfig.nt
@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 / 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")