Skip to content

Instantly share code, notes, and snippets.

Heidi Mork heidisu

Block or report user

Report or block heidisu

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@heidisu
heidisu / App.java
Created May 14, 2019
Path dependent types - inner class in java is related to enclosing class, inner class in Scala is related to object it is created from
View App.java
package animal;
class Animal {
class Sound{
final String sound;
public Sound(String sound){
this.sound = sound;
}
@heidisu
heidisu / App.java
Last active Jul 24, 2018
Haar transform
View App.java
package haar;
import javax.imageio.ImageIO;
import javax.swing.*;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.awt.image.FilteredImageSource;
import java.awt.image.ImageFilter;
import java.awt.image.ImageProducer;
import java.io.IOException;
View juletre.rkt
#lang racket
(require pict)
(require pict/tree-layout)
(define star (scale (bitmap .) 0.3))
(define (green-edge child) (tree-edge #:edge-width 3 #:edge-color "green" child))
(define (ball color) (disk #:color color 20))
View snake.rkt
#lang racket
(require 2htdp/universe)
(require 2htdp/image)
(require lang/posn)
(define speed 5)
(define (create-snake-scene snake)
(place-images (create-rectangles (length snake)) (create-positions snake) (rectangle 500 500 "solid" "white")))
@heidisu
heidisu / clustering.cql
Last active Mar 7, 2018
K-mean clustering of seeds of wheat in Neo4j. The code is explained in this blog post: http://heidi.morkland.org/2016/03/k-mean-clustering-in-neo4j/
View clustering.cql
// this script cannot be run at once, each block must be run separately
// relates seed to nearest cluster
MATCH (s:Seed), (c1:Centroid{index: 1, iteration: 1}), (c2:Centroid{index: 2, iteration: 1}), (c3:Centroid{index: 3, iteration: 1})
SET s.distC1 = (s.area - c1.area)^2 + (s.perimeter - c1.perimeter)^2 + (s.compactness - c1.compactness)^2 + (s.kernelLength - c1.kernelLength)^2 + (s.kernelWidth - c1.kernelWidth)^2 + (s.asymmetryCoefficient - c1.asymmetryCoefficient)^2 + (s.kernelGrooveLength - c1.kernelGrooveLength)
SET s.distC2 = (s.area - c2.area)^2 + (s.perimeter - c2.perimeter)^2 + (s.compactness - c2.compactness)^2 + (s.kernelLength - c2.kernelLength)^2 + (s.kernelWidth - c2.kernelWidth)^2 + (s.asymmetryCoefficient - c2.asymmetryCoefficient)^2 + (s.kernelGrooveLength - c2.kernelGrooveLength)
SET s.distC3 = (s.area - c3.area)^2 + (s.perimeter - c3.perimeter)^2 + (s.compactness - c3.compactness)^2 + (s.kernelLength - c3.kernelLength)^2 + (s.kernelWidth - c3.kernelWidth)^2 + (s.asymmetryCoefficient - c
View prover-test.rkt
#lang racket
(require rackunit
"prover.rkt")
(check-equal? (resolve '(or P) '(or Q)) 'no-resolvent)
(check-equal? (resolve '(or P) '(or (not P))) '(or))
(check-equal? (resolve '(or P (not Q)) '(or Q (not R))) '(or P (not R)))
(test-case
@heidisu
heidisu / Zebra.xtext
Created Jun 25, 2015
Language and validator for solving the Zebra Puzzle with Xtext
View Zebra.xtext
grammar org.xtext.example.zebra.Zebra with org.eclipse.xtext.common.Terminals
generate zebra "http://www.xtext.org/example/zebra/Zebra"
Model:
houses+=House*;
enum Color:
Red | Blue | Green | Yellow | Ivory
;
You can’t perform that action at this time.