Skip to content

Instantly share code, notes, and snippets.

View r-moeritz's full-sized avatar

Ralph r-moeritz

  • Adelaide SA
View GitHub Profile
@r-moeritz
r-moeritz / app.js
Created July 22, 2014 22:22
TrueSkill examples
var readline = require('readline').createInterface({
input: process.stdin,
output: process.stdout
});
var trueskill = require('com.izaakschroeder.trueskill').create(1000);
console.log('mu: %d, sigma: %d, beta: %d, tau: %d',
trueskill.mu.toFixed(3),
trueskill.sigma.toFixed(3),
@r-moeritz
r-moeritz / game.lisp
Created June 16, 2011 18:08
game related functions
(defun game-from-name (name)
(clsql:locally-enable-sql-reader-syntax)
(car (clsql:select 'game
:where [= [slot-value 'game 'name] name])))
(defun games ()
(sort (clsql:select 'game) #'> :key #'(lambda (g) (apply #'game-votes g))))
(defun add-game (name)
(unless (game-stored? name)
@r-moeritz
r-moeritz / new-game.lisp
Created June 16, 2011 18:05
new-game function
(define-url-fn (new-game)
(standard-page (:title "Add a new game")
(:script :type "text/javascript"
(str (ps
(defun validate ()
(when (= (@ ((@ document get-element-by-id) "name") value) "")
(alert "Please enter a name.")
(return false))))))
(:h1 "Add a new game to the chart")
(:form :action "/game-added.htm" :method "post"
@r-moeritz
r-moeritz / game.lisp
Created June 16, 2011 18:06
game class
(clsql:def-view-class game ()
((id
:db-kind :key
:db-type "int identity(1,1)")
(name
:accessor game-name
:db-constraints (:unique :not-null)
:db-type "nvarchar(50)"
:initarg :name)
(votes
@r-moeritz
r-moeritz / connect.lisp
Created June 16, 2011 18:07
connect to db
;; Turn off caching of select queries
(setf clsql:*default-caching* nil)
;; Connection parameters
(defvar *database-type* :odbc)
(defvar *database-name* "RetroGames")
(defvar *database-user* "sa")
(defvar *database-server* "localhost")
(defvar *database-password* "password")
@r-moeritz
r-moeritz / hello-jwt.java
Created June 16, 2011 19:04
hello jwt in java
/*
* Copyright (C) 2009 Emweb bvba, Leuven, Belgium.
*
* See the LICENSE file for terms of use.
*/
package eu.webtoolkit.jwt.examples.hello;
import eu.webtoolkit.jwt.Side;
import eu.webtoolkit.jwt.Signal;
import eu.webtoolkit.jwt.WApplication;
@r-moeritz
r-moeritz / core.clj
Created June 16, 2011 19:07
hello jwt in clojure : core.clj
(ns jwt-examples.core
(:use [jetty-wrapper.core :only [run-server]])
(:use [jwt-examples.hello :only [make-servlet]]))
(defn -main []
(run-server {:port 4000} "/*" (make-servlet)))
@r-moeritz
r-moeritz / hello.clj
Created June 16, 2011 19:09
hello jwt in clojure : hello.clj
(ns jwt-examples.hello)
(defmacro create-listener [args & body]
(let [argsnum (if (< 0 (count args)) (count args) "") ]
`(proxy [ ~(symbol (str "Signal" argsnum "$Listener")) ] [] (trigger ~args ~@body))))
(import [eu.webtoolkit.jwt WObject Signal WApplication WBreak WtServlet
WEnvironment WLineEdit WPushButton WText Signal$Listener Signal1
EventSignal WWidget Side]
[java.util EnumSet])
@r-moeritz
r-moeritz / project.clj
Created June 16, 2011 19:24
hello jwt in clojure : project.clj
(defproject jwt-examples "0.1.0"
:description "Clojure versions of JWT example programs"
:dependencies [[org.clojure/clojure "1.2.1"]
[jetty-wrapper "0.1.1"]])
@r-moeritz
r-moeritz / core.clj
Created June 16, 2011 21:29
cljdoc - a repl helper to quickly browse Clojure docs
;; Copyright (c) Ralph Moritz. All rights reserved.
;; The use and distribution terms for this software are covered by the Eclipse
;; Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) which
;; can be found in the file epl-v10.html at the root of this distribution. By
;; using this software in any fashion, you are agreeing to be bound by the
;; terms of this license. You must not remove this notice, or any other, from
;; this software.
(ns
^{:author "Ralph Moritz"