Skip to content

Instantly share code, notes, and snippets.

View wedesoft's full-sized avatar

Jan Wedekind wedesoft

View GitHub Profile
@wedesoft
wedesoft / heisttest.rb
Last active December 29, 2015 13:08
Playing around with the Heist Ruby Gem.
#!/usr/bin/env ruby
require 'heist'
# true
scheme = Heist::Runtime.new
# #<runtime: call/cc disabled, hygienic, eager>
def test x
puts "\# #{x.class}: #{x}"
x
end
# nil
@wedesoft
wedesoft / .gitignore
Last active December 30, 2015 03:28
Bounded Hough Transform
*.png
*.avi
.*.un~
.*.swp
@wedesoft
wedesoft / .gitignore
Last active December 31, 2015 13:09
Python Scheme integration (libguile)
*.so
*.o
*.html
.*.un~
.*.swp
@wedesoft
wedesoft / image-types.rb
Last active June 16, 2016 19:59
HornetsEye, OpenCV, RMagick conversions
require 'multiarray'
require 'hornetseye_opencv'
require 'hornetseye_rmagick'
require 'hornetseye_narray'
include Hornetseye
img = MultiArray[[2, 3, 5, 7], [11, 13, 17, 19]]
# MultiArray(UBYTE,2):
# [ [ 2, 3, 5, 7 ],
# [ 11, 13, 17, 19 ] ]
cvmat = img.to_cvmat
@wedesoft
wedesoft / graph-coloring.scm
Last active June 20, 2016 20:19
Graph coloring using Chaitin's algorithm
(use-modules (srfi srfi-1) (srfi srfi-26) (ice-9 curried-definitions))
(define (dot graph colors)
(apply string-append
(append (list "graph g {")
(map (lambda (color) (format #f " ~a [style=filled, fillcolor=~a];" (car color) (cdr color))) colors)
(map (lambda (edge) (format #f " ~a -- ~a;" (car edge) (cdr edge))) graph)
(list " }"))))
(define (graphviz graph colors) (system (format #f "echo '~a' | dot -Tpng | display -" (dot graph colors))))
(define (nodes graph) (delete-duplicates (append (map car graph) (map cdr graph))))
(define ((has-node? node) edge) (or (eq? (car edge) node) (eq? (cdr edge) node)))
@wedesoft
wedesoft / artanis-user-session.scm
Last active June 23, 2016 21:29
Guile Artanis user session
(use-modules (artanis artanis) (artanis cookie) (artanis utils))
(init-server)
(get "/" #:session 'spawn
(lambda (rc)
(let [(sid (or (cookie-ref (rc-cookie rc) "sid") (:session rc 'spawn)))
(time (strftime "%c" (localtime (current-time))))]
(tpl->response `(html (body (p ,sid) (p ,time)))))))
(run)
@wedesoft
wedesoft / Dockerfile
Last active June 26, 2016 20:18
Get session key in Guile Artanis
# sudo docker build -t wedesoft/aiscm
# sudo docker run --rm -t -i wedesoft/aiscm /bin/bash
# sudo docker run --rm -p 80:80 wedesoft/aiscm
FROM debian:jessie
MAINTAINER Jan Wedekind <jan@wedesoft.de>
ENV ARTANIS_VERSION 0.1.2.1-be890-dirty
ENV SERVER_HOME /srv/artanis-repl
RUN apt-get update && \
@wedesoft
wedesoft / hello-qt.lisp
Last active February 5, 2017 12:37
Small GUI example using Steel Bank Common Lisp, Quicklisp, CommonQt, and Qt4.
#!/usr/bin/sbcl --script
; Also see http://pleasegodno.wordpress.com/common-lisp-tutorials/common-lisp-gui-programming-with-commonqt/introduction-to-commonqt/
; or see http://kvardek-du.kerno.org/2011/12/setting-up-commonqt-on-osx.html if you're still using Mac OS
(let ((quicklisp-init (merge-pathnames "quicklisp/setup.lisp"
(user-homedir-pathname))))
(when (probe-file quicklisp-init)
(load quicklisp-init)))
@wedesoft
wedesoft / grid.pov
Created April 7, 2017 13:21
grid.pov
// calibration grid
@wedesoft
wedesoft / lstm-predict.py
Last active November 6, 2017 10:11
Long short-term memory (LSTM) Tensorflow implementation training on Shakespeare's work
#!/usr/bin/env python3
import sys
import numpy as np
import tensorflow as tf
class CharVec:
def __init__(self, text):
self.chars = np.array([ord(c) for c in sorted(set(text))])