Skip to content

Instantly share code, notes, and snippets.

View ubergeek42's full-sized avatar

Keith Johnson ubergeek42

  • Rainforest QA
  • Greenville, SC
View GitHub Profile
{-
- Author: Keith Johnson, kjohns07@my.fit.edu
- Course: CSE5400, Spring 2011
- Project: endo1
-}
module Main where
import Text.Printf
main :: IO()
@ubergeek42
ubergeek42 / gist:939724
Created April 24, 2011 17:27
haskell pinball
{-# OPTIONS_GHC -Wall -O2 #-}
module Main where
main :: IO()
main = interact (solve . readTestCases)
-- This builds a list of lists representing the problem
readTestCases :: String -> [[Int]]
readTestCases = parse 1 . map read . words
@ubergeek42
ubergeek42 / gist:2853099
Created June 1, 2012 15:50
Domjudge buffer overflow
Compiling failed with exitcode 134, compiler output:
/opt/judgehost/bin/runguard: verbose: watchdog using user ID `999'
/opt/judgehost/bin/runguard: verbose: using timelimit of 30.000 seconds
/opt/judgehost/bin/runguard: verbose: setting filesize limit to 67108864 bytes
/opt/judgehost/bin/runguard: verbose: disabling core dumps
/opt/judgehost/bin/runguard: verbose: reset user ID to `999' for command
boolfind-test-correct.c: In function 'main':
boolfind-test-correct.c:23:7: warning: ignoring return value of 'scanf', declared with attribute warn_unused_result [-Wunused-result]
boolfind-test-correct.c:27:8: warning: ignoring return value of 'scanf', declared with attribute warn_unused_result [-Wunused-result]
boolfind-test-correct.c:35:9: warning: ignoring return value of 'scanf', declared with attribute warn_unused_result [-Wunused-result]
@ubergeek42
ubergeek42 / 0001-Use-cgroups-to-provide-memory-limits-in-runguard.patch
Created March 24, 2013 23:58
Patch to domjudge to use cgroups instead of setrlimit for imposing memory restrictions on submitted programs.
From fa9abfec5db30585f8c5f03e19e3448fc7c7a31b Mon Sep 17 00:00:00 2001
From: Keith Johnson <kj@ubergeek42.com>
Date: Sat, 23 Mar 2013 11:24:19 -0400
Subject: [PATCH] Use cgroups to provide memory limits in runguard
---
configure.ac | 5 ++-
judge/Makefile | 2 +-
judge/runguard.c | 124 +++++++++++++++++++++++++++++++++++++++++++++++++++----
paths.mk.in | 3 ++
@ubergeek42
ubergeek42 / judgedaemon.main.php.patch
Created May 16, 2013 18:52
Domjudge: Make judgehosts register themselves
diff --git a/judge/judgedaemon.main.php b/judge/judgedaemon.main.php
index e9fefb4..a65b9a4 100644
--- a/judge/judgedaemon.main.php
+++ b/judge/judgedaemon.main.php
@@ -101,6 +101,8 @@ while( !$exitsignalled )
$row = $DB->q('MAYBETUPLE SELECT * FROM judgehost WHERE hostname = %s'
, $myhost);
if ( ! $row ) {
+ // self register the judgehost
+ $DB->q('INSERT INTO judgehost SET hostname = %s, active = 1', $myhost);
@ubergeek42
ubergeek42 / compile_adb.sh
Last active December 17, 2015 10:19
Domjudge: Compile scripts for fortran, lua, ada, scala. Note: scala requires some additional setup, as it doesn't run with the statically compiled sh included with domjudge. You'll need to add ' Ada,adb Fortran,f95 Scala,scala, Lua,lua' to the LANG_EXTS variable in domserver-config.php.
#!/bin/sh
# ADA compile wrapper-script for 'compile.sh'.
# See that script for syntax and more info.
DEST="$1" ; shift
MEMLIMIT="$1" ; shift
MAINSOURCE="$1"
# -static: Static link with all libraries
@ubergeek42
ubergeek42 / dj_make_chroot.sh
Created May 17, 2013 12:15
dj_make_chroot that uses ubuntu instead of debian
#!/bin/sh
#
# Script to generate a minimal chroot environment with Oracle (Sun) Java
# support to allow for Java programs to run in a chroot.
#
# This script downloads and installs a Ubuntu base system.
# Minimum requirements: a Linux system with glibc >= 2.3, wget, ar and
# a POSIX shell in /bin/sh. About 250 MB disk space is needed. It must
# be run as root and will install the Debian debootstrap package.
#
@ubergeek42
ubergeek42 / 0001-Minor-bugfixes.patch
Created May 28, 2013 18:21
Minor bugfix for domjudge
From 989e3790855bbca25a26dcaca7c0174689d5fd69 Mon Sep 17 00:00:00 2001
From: Keith Johnson <kj@ubergeek42.com>
Date: Fri, 24 May 2013 10:44:21 -0400
Subject: [PATCH] Minor bugfixes
lib.database needs to handle another error code, it changes based on
mysql version.
team_affiliation was changed to use a MAYBETUPLE so that the error
check that occurs on the next line actually works.
@ubergeek42
ubergeek42 / multiple-judgedaemon.diff
Last active December 18, 2015 15:29
DOMjudge: add support for multiple judgedaemons using cpuset cgroups
diff --git a/etc/cgroup-domjudge.conf.in b/etc/cgroup-domjudge.conf.in
index 1d6cb42..b7f3415
--- a/etc/cgroup-domjudge.conf.in
+++ b/etc/cgroup-domjudge.conf.in
@@ -18,4 +18,11 @@ group domjudge {
memory {
# This section is an empty stub: the limits are set by runguard.
}
+# Change the cpuset.cpus line to a range specifying the cores you are
+# going to use. e.g. if you have a quad core machine, set cpuset.cpus = 0-3
From 2622a5aedf455abf1e6cbfffd2d7704065923186 Mon Sep 17 00:00:00 2001
From: Keith Johnson <kj@ubergeek42.com>
Date: Tue, 18 Jun 2013 12:26:42 -0400
Subject: Allow multiple judgedaemons on a single machine
Add support for running multiple judgedaemons at once on a single
machine. This allows for better use of multiple cpu cores. To provide
for better isolation between the judegdaemons, the cpuset cgroup support
is used to limit processes to a single cpu core.
---