Skip to content

Instantly share code, notes, and snippets.

View klaeufer's full-sized avatar
:octocat:

Konstantin Läufer klaeufer

:octocat:
View GitHub Profile
@klaeufer
klaeufer / unfiltered-simple-caching.scala
Created March 19, 2011 23:25
Simple Unfiltered example for providing OPTIONS, HEAD, and conditional GET
class RootPlan extends Plan {
val logger = Logger(classOf[RootPlan])
val creationDate = new java.util.Date
val eTag = hashCode.toString
val Head = Ok ~> Vary("Accept-Charset", "Accept-Encoding", "Accept-Language", "Accept")
val Caching =
CacheControl("max-age=3600") ~>
LastModified(DateUtils.formatDate(creationDate)) ~>
@klaeufer
klaeufer / test3.txt
Created October 20, 2011 18:05
Loyola University Chicago Comp 373/473 Project 2a Sample Test Case 3
struct ListNode { value, next };
var n;
var h;
var s;
n = new ListNode;
h = n;
n.value = 2;
n.next = new ListNode;
n = n.next;
n.value = 3;
@klaeufer
klaeufer / test2.txt
Created October 20, 2011 18:13
Loyola University Chicago Comp 373/473 Project 2a Sample Test Case 2
struct StudentCourseRecord { firstExamScore, secondExamScore, totalScore };
struct StudentSemesterRecord { course1, course2 };
var q;
var r;
r = new StudentSemesterRecord;
r.course1 = new StudentCourseRecord;
r.course1.firstExamScore = 25;
r.course1.secondExamScore = 35;
r.course1.totalScore = r.course1.firstExamScore + r.course1.secondExamScore;
r.course2 = r.course1;
@klaeufer
klaeufer / test1.txt
Created October 20, 2011 18:16
Loyola University Chicago Comp 373/473 Project 2a Sample Test Case 1
var x;
var y;
var r;
x = 2;
y = 3;
while (y) {
r = r + x,
y = y - 1
};
@klaeufer
klaeufer / test4.txt
Created October 20, 2011 21:13
Loyola University Chicago Comp 373/473 Project 2a Sample Test Case 4
struct ListNode { value, next };
n = new ListNode;
n.value = 5;
n.next = 0;
{ n.value = 7, n }.next = 12;
@klaeufer
klaeufer / .gitignore
Created January 30, 2012 19:00
Sample .gitignore for Play Framework applications
# general
*~
*.log
tmp
dump
# Eclipse
.settings
.cache
.project
@klaeufer
klaeufer / Makefile
Created April 2, 2012 17:57
Makefile for F# lexing and parsing example from F# Programming Wikibook
# Makefile for F# lexing and parsing example from
# http://en.wikibooks.org/wiki/F_Sharp_Programming/Lexing_and_Parsing
# Sources available at https://github.com/obeleh/FsYacc-Example
#
# http://laufer.cs.luc.edu/teaching/372
#
# Prerequisites
# make
# http://fsharppowerpack.codeplex.com/ for fslex, fsyacc
# http://fsxplat.codeplex.com/ for fsharpc (and fsharpi)
@klaeufer
klaeufer / LexerOnly.fs
Created April 3, 2012 01:15
Lexer-only example for F# lexing and parsing example from F# Programming Wikibook
open System
open Sql
let x = "
SELECT x, y, z
FROM t1
LEFT JOIN t2
INNER JOIN t3 ON t3.ID = t2.ID
WHERE x = 50 AND y = 20
ORDER BY x ASC, y DESC, z
@klaeufer
klaeufer / CPUboundTasks.scala
Last active December 1, 2021 01:25
CPU-bound tasks for experimenting in the Scala REPL
// a CPU-intensive task
def isPrime(i: Long): Boolean = {
if (i == 2) return true
if (i < 2 || i % 2 == 0) return false
var k = 3L
val half = i / 2
while (k <= half) {
if (i % k == 0) return false
k += 2
}
@klaeufer
klaeufer / IOboundTasks.scala
Last active November 29, 2022 22:57
I/O-bound tasks for experimenting in the Scala REPL
def p(s: String) =
for (i <- 1 to 10) {
Thread.sleep(500)
println(i + ": " + s)
}
// running two tasks sequentially
// about 20 seconds by design
val t0 = System.currentTimeMillis
p("a")