Skip to content

Instantly share code, notes, and snippets.

View jonathanvdc's full-sized avatar

Jonathan Van der Cruysse jonathanvdc

View GitHub Profile
@jonathanvdc
jonathanvdc / kappa.py
Last active January 30, 2020 17:00
Computes Cohen's Kappa Coefficient
#!/usr/bin/env python3
"""This script computes Cohen's Kappa Coefficient. Invoke with `python3 kappy.py data.csv`,
where `data.csv` is a CSV file that contains three columns and no header. The first column
contains identifiers that are not used for the purpose of computing the Kappa Coefficient.
The second column encodes the first rater's findings. The third column encodes the second rater's findings."""
import csv
import sys
@jonathanvdc
jonathanvdc / advtrains-train-info-controller.lua
Last active March 9, 2022 00:42
A minetest mesecons 'luacontroller' for train station info signs.
-- This is 'luacontroller' code for train station signs.
--
-- It was designed for the 'advtrains' and 'textline' mods,
-- but it does not have any dependencies on them.
--
-- Usage:
--
-- 1. Tweak the 'stops', 'destination', 'train_type',
-- 'at_platform_duration' and 'train_at_platform_pin'
-- constants to suit your needs.
#include <iostream>
#include <vector>
class Alias
{
private:
Alias(const std::vector<int>& data) : data(data) { }
// Delete this to make sure that we don't accidentally make a copy.
Alias(const Alias&) = delete;
@jonathanvdc
jonathanvdc / Fractal.cs
Created March 14, 2017 11:01
A quick fractal benchmark, based on Kevin Frei's fractal benchmark.
// This source file was borrowed from Kevin Frei's Source Code
// (https://kscdg.codeplex.com/SourceControl/latest#JIT-Benchmarks/FractalPerf.cs)
// Licensed under the MIT license.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@jonathanvdc
jonathanvdc / mono-ln.sh
Last active July 29, 2017 08:29
A script that generates a wrapper script to run mono on an executable.
#!/usr/bin/env bash
if [ $# -lt 2 ]; then
echo "Usage: mono-ln filename.exe script-path.sh [readlink|greadlink]"
fi
if [ $# -lt 3 ]; then
readlink_name="readlink"
else
readlink_name=$3
fi
@jonathanvdc
jonathanvdc / Struct.ds
Created March 1, 2016 17:54
Wasm Structs
// Compile with `dsc Struct.ds -platform wasm -Wno-build`
public struct Vector2
{
public int X;
public int Y;
public int LengthSquared()
{
return X * X + Y * Y;
@jonathanvdc
jonathanvdc / Program.cs
Last active August 27, 2015 16:28
call vs newobj in struct initialization
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Test
{
public class Program
@jonathanvdc
jonathanvdc / HighlightRichText.cs
Created May 25, 2015 11:23
Xml Highlighter for WinRT apps
...
var doc = this.CodeBox.Document; // this.CodeBox is a RichEditBox
string text;
doc.GetText(Windows.UI.Text.TextGetOptions.None, out text);
text = text.Replace('\r', '\n'); // Transform this so we don't have to deal with '\r'
var highlighter = new XmlHighlighter(text); // Highlight code
int textLength = text.Length;