Skip to content

Instantly share code, notes, and snippets.

View arademaker's full-sized avatar
🎯
Focusing

Alexandre Rademaker arademaker

🎯
Focusing
View GitHub Profile
@arademaker
arademaker / erc.el
Created November 26, 2015 10:12
erc config in .emacs
;; ERC
(erc-autojoin-mode t)
(setq erc-save-buffer-on-part nil
erc-save-queries-on-quit nil
erc-log-write-after-send t
erc-log-write-after-insert t
erc-echo-notices-in-minibuffer-flag t
erc-log-channels-directory "~/.erc/logs/"
erc-autojoin-channels-alist '(("freenode.net" "#lisp")
("wnpt.brlcloud.com" "#brl")))
@arademaker
arademaker / glossas.lisp
Last active January 19, 2016 21:14
glosas and examples
(defun group-by (alist n &optional res)
(if (null alist)
(reverse res)
(group-by (subseq alist n) n (cons (subseq alist 0 n) res))))
(defun split-gloss (gloss)
(let* ((re "[ ]*;[ ]*\"[^\"]+\"")
(pos (cl-ppcre:all-matches re gloss))
(bw '(#\; #\" #\Space)))
(if pos
(defmacro with-open-files (args &rest body)
(let ((res `(progn ,@body)))
(reduce (lambda (acc e) `(with-open-file (,@e) ,acc)) args
:initial-value res)))
(defmacro with-open-files-1 (args &rest body)
(let ((res `(progn ,@body)))
(dolist (a (reverse args) res)
(setf res `(with-open-file (,@a)
,res)))))
RACER-USER> (signature :atomic-concepts (A C a1 a2)
:roles (h))
; No value
RACER-USER> (equivalent a1 (and (some h A) (all h C)))
A1
RACER-USER> (equivalent a2 (some h C))
A2
RACER-USER> (concept-subsumes? a1 a2)
NIL
RACER-USER> (concept-subsumes? a2 a1)
(setenv "LANG" "en_US.UTF-8")
(setenv "LC_ALL" "en_US.UTF-8")
(prefer-coding-system 'utf-8)
(set-language-environment "UTF-8")
;; slime setup
(use-package slime
:init
(load (expand-file-name "~/quicklisp/slime-helper.el"))
:config
(ql:quickload :snark)
(initialize)
(use-resolution t)
(defun var-complemente (var)
(if (equal var '?x)
'?y
'?x))
(ql:quickload :cxml)
(ql:quickload :cxml-stp)
(defparameter *document* (cxml:parse #P"raw/2010-official-1.xml"
(stp:make-builder)))
(let (res)
(xpath:do-node-set (node (xpath:evaluate "//statement" *document*) res)
(push (xpath-protocol:node-text node) res)))
@arademaker
arademaker / rdf-to-json.py
Created November 28, 2018 02:11
Wilbur vs rdflib
import sys
import jsonlines
import rdflib
from rdflib.namespace import RDFS, SKOS, RDF
from rdflib import Namespace
import json
ont = sys.argv[1]
@arademaker
arademaker / rdf-to-json.lisp
Created November 28, 2018 02:12
Wilbur vs RDFLib
(ql:quickload '(:yason :wilbur :alexandria) :silent t)
(wilbur:add-namespace "du" "http://br.ibm.com/document-understanding/")
(defun get-relations (sent)
(let ((rels (wilbur:all-values sent '!du:hasRelation)))
(mapcar (lambda (rel)
(alexandria:plist-hash-table
(list "origin" (wilbur:value rel '(:seq !du:origin))
"subject" (wilbur:value rel '(:seq !du:subject))
@arademaker
arademaker / powerset.lean
Created October 15, 2019 13:29
powerset in lean
open set
variable {U : Type}
example (A B : set U) : A ∈ powerset (A ∪ B) :=
assume x,
assume : x ∈ A,
show x ∈ A ∪ B, from or.inl ‹x ∈ A›