Skip to content

Instantly share code, notes, and snippets.

View erikkaplun's full-sized avatar

Erik Kaplun erikkaplun

  • UXO
  • Tallinn, Estonia
View GitHub Profile
@davidar
davidar / prolog.md
Last active March 11, 2022 10:01
Prolog relative clauses

Pointless Prolog

This document proposes relative clauses as syntactic sugar for Prolog, which allow us to write more concisely by avoiding repetitively naming variables. Relative clauses are written as a list of predicates surrounded by curly braces. They introduce a new variable, which is constrained by applying all of the included predicates to it. For example:

{red, block}

is equivalent to the query

@daveray
daveray / seesaw-repl-tutorial.clj
Created December 7, 2011 04:55
Seesaw REPL Tutorial
; A REPL-based, annotated Seesaw tutorial
; Please visit https://github.com/daveray/seesaw for more info
;
; This is a very basic intro to Seesaw, a Clojure UI toolkit. It covers
; Seesaw's basic features and philosophy, but only scratches the surface
; of what's available. It only assumes knowledge of Clojure. No Swing or
; Java experience is needed.
;
; This material was first presented in a talk at @CraftsmanGuild in
; Ann Arbor, MI.
@erikkaplun
erikkaplun / index.html
Created April 21, 2011 12:20
Ideelabor pildirakendus
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>img</title>
<link rel="stylesheet" href="css/supersized.css" type="text/css" media="screen" />
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<title>Täheaabits</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
@erikkaplun
erikkaplun / foo.py
Created January 26, 2011 19:47
Maagiline muutuja __name__
print('Inside file foo.py; and __name__ is %s' % __name__)
# ekraanile ilmub tekst:
# Inside file foo.py; and __name__ is foo
# kui foo.py käivitatakse otse, ilmub foo asemel:
# Inside file foo.py; and __name__ is __main__
def do_something_cool():
print('Doing something cool...')
@erikkaplun
erikkaplun / foo.py
Created January 26, 2011 19:29
Moodulite importimine
def hello():
print('Hello!')
def say_greetings(name):
print('Greetings, %s!' % name)
# Python 3:
# print('Greetings, {0}!'.format(name))
def attach_foreignkey(objects, field, select_related=None):
"""
Shortcut method which handles a pythonic LEFT OUTER JOIN.
``attach_foreignkey(posts, Post.thread)``
"""
field = field.field
qs = field.rel.to.objects.filter(pk__in=distinct(getattr(o, field.column) for o in objects))
if select_related:
qs = qs.select_related(*select_related)