Skip to content

Instantly share code, notes, and snippets.

View fversnel's full-sized avatar

Frank Versnel fversnel

View GitHub Profile
using System;
using UnityEngine;
namespace RamjetAnvil.Networking {
public static class Compression {
public static class Rotation {
private const float Minimum = -1.0f / 1.414214f; // note: 1.0f / sqrt(2)
private const float Maximum = +1.0f / 1.414214f;
@fversnel
fversnel / baba.clj
Last active April 2, 2019 08:27
Baba is you spec
(ns babaisyou.spec
(:require [clojure.spec.alpha :as s]))
(s/def ::subject
#{:word/baba :word/wall :word/flag :word/grass})
(s/def ::verb
#{:word/is})
(s/def ::object
#{:word/you :word/push :word/stop :word/win})
(s/def ::sentence
@fversnel
fversnel / extra-database-assignments.md
Last active May 10, 2018 23:25
Extra database assignments

Extra assignments

Here are some extra assignments for everyone who has finished the database homework and couldn't get enough ;).

Indices

Indices are a very important feature to make queries faster.

  1. What is a database index? Explain in your own words.
@fversnel
fversnel / SmartSortable.js
Created December 30, 2014 11:36
React SmartSortable
var cloneWithProps = React.addons.cloneWithProps;
var SmartSortable = React.createClass({
getDefaultProps: function() {
return {component: "ul", childComponent: "li"};
},
render: function() {
var props = jQuery.extend({}, this.props);
@fversnel
fversnel / MachineLearning1.scala
Last active November 9, 2017 15:24
Following along in Scala with the Coursera Machine Learning course
import spire.implicits._
import spire.math._
class MachineLearning1[Number](implicit fractional: Fractional[Number]) {
import fractional.pow
private def number(integer: Int): Number = fractional.fromInt(integer)
type Hypothesis = Number => Number
@fversnel
fversnel / ComplexNumber.cs
Last active February 17, 2017 11:12
My first attempt at implementing lateral (i.e. imaginary) numbers. Currently implemented +, - and *
namespace Lateralus {
public struct ComplexNumber {
public readonly double Direct; // Real part
public readonly Lateral Lateral; // Imaginary part
public ComplexNumber(double direct, Lateral lateral) {
Direct = direct;
Lateral = lateral;
@fversnel
fversnel / BulletThreadingUnity.cs
Last active August 11, 2016 14:44
Bullet physics in a separate thread on Unity
using System.Diagnostics;
using System.Threading;
using BulletSharp;
using BulletSharp.Math;
using BulletUnity;
using UnityEngine;
using Vector3 = BulletSharp.Math.Vector3;
public class MultithreadingTest : MonoBehaviour {
private MotionState _bodyView;
@fversnel
fversnel / QuartzObservable.scala
Last active February 11, 2016 08:56
Creates an Observable from a cron expression using the Quartz scheduler
package org.frankversnel.rxquartz
import java.time.Instant
import java.util.UUID
import scala.concurrent.{ExecutionContext, Promise, Future}
import com.typesafe.scalalogging.Logger
import org.quartz._
import rx.lang.scala.{Observer, Subscription, Observable}
@fversnel
fversnel / UnitySingleton.cs
Created October 15, 2013 14:13
Singleton implementation from the 'Unite 2013 - Internal Unity Tips and Tricks' talk (http://www.youtube.com/watch?v=Ozc_hXzp_KU)
using UnityEngine;
public class Example : MonoBehaviour
{
public static Example Singleton;
void OnEnable()
{
if (Singleton == null)
Singleton = this;
@fversnel
fversnel / AnonymousMonobehaviours.cs
Last active December 25, 2015 07:49
Creates an anonymous MonoBehaviour instance from a given update Action.
public static class AnonymousMonoBehaviours
{
private static readonly Action EmptyAction = () => { };
/// <summary>
/// Creates an anonymous MonoBehaviour instance from a given update Action.
/// The instance can be destroyed by calling Dispose on the returned IDisposable.
/// </summary>
/// <param name="updateFn">Called whenever AnonymousMonobehaviour.Update() is called.</param>
/// <param name="startFn">Called whenever AnonymousMonobehaviour.Start() is called.</param>