Skip to content

Instantly share code, notes, and snippets.

View andytill's full-sized avatar

Andy Till andytill

View GitHub Profile
@andytill
andytill / csv.erl
Last active June 10, 2024 19:38
Erlang state machine for parsing a CSV file
%% @author atill
%%
%% @doc
%% CSV parsing module. Parsed CSV will be processed and converted
%% into a list containing the separated values, lines are separated
%% by the newline atom.
-module(csv).
-import(lists, [reverse/1]).
@andytill
andytill / DragResizer.java
Last active May 14, 2024 12:52
DragResizercan be used to add mouse listeners to a Region and make it resizable by the user by clicking and dragging the border in the same way as a window. Only height resizing is currently implemented.
import javafx.event.EventHandler;
import javafx.scene.Cursor;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.Region;
/**
* {@link DragResizer} can be used to add mouse listeners to a {@link Region}
* and make it resizable by the user by clicking and dragging the border in the
* same way as a window.
* <p>
@andytill
andytill / Erlang Project Ideas.md
Last active February 20, 2023 06:00
Erlang Project Ideas

When I started erlang, I had a hard time thinking of ideas for projects to improve my skills. Now I have way too many ideas to possibly implement Myself. Since I actually want these projects to exist so I can use them (everlasting glory coming secondary to some handy tools) I have written them up here. Feel free to try them out. I'm open to questions and suggestions.

swagger for erlang

swagger is a JSON spec for REST APIs. Once you have written a spec in swagger, it can generate documentation (demo) and REST handlers.

An erlang swagger library should take swagger specs and generate cowboy_rest handlers for them.

Difficulty: low

@andytill
andytill / JavaFXThreadingRule.java
Created October 4, 2012 19:42
A Junit @rule for running tests on the JavaFX thread
import java.util.concurrent.CountDownLatch;
import javax.swing.SwingUtilities;
import javafx.application.Platform;
import javafx.embed.swing.JFXPanel;
import org.junit.Rule;
import org.junit.rules.TestRule;
import org.junit.runner.Description;
@andytill
andytill / HierarchyTreeCell.java
Created November 4, 2012 00:44
A JavaFX TreeCell implementation with drag and drop.
package projmon.hierarchical;
import javafx.event.EventHandler;
import javafx.geometry.Point2D;
import javafx.scene.control.TreeCell;
import javafx.scene.control.TreeItem;
import javafx.scene.effect.InnerShadow;
import javafx.scene.input.ClipboardContent;
import javafx.scene.input.DragEvent;
import javafx.scene.input.Dragboard;
@andytill
andytill / FXUtils.java
Last active May 7, 2021 06:59
Utility for for finding a JavaFX node by it's ID
package test;
import javafx.scene.*;
import javafx.scene.control.*;
public class FXUtils {
/**
* Find a {@link Node} within a {@link Parent} by it's ID.
* <p>
@andytill
andytill / TestApp2.java
Created July 15, 2012 10:31
Getting observable collections working with an extractor callback
import javafx.beans.InvalidationListener;
import javafx.beans.Observable;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
import javafx.collections.FXCollections;
import javafx.collections.ListChangeListener;
import javafx.collections.ObservableList;
import javafx.util.Callback;
import java.util.ArrayList;
@andytill
andytill / brume.css
Created August 20, 2012 12:17
JavaFX Light Grey Brume Theme
/**
* JavaFX CSS light grey/white 'brume' theme.
*/
.titled-pane {
-fx-effect: dropshadow(three-pass-box, #9F9F9F, 15, 0, 0, 0);
-fx-animated: true;
-fx-text-fill: #505050;
}
@andytill
andytill / ListViewIndexChangesWhenItemUpdated .java
Created July 15, 2012 13:07
Example application showing how changing an item in a ListView changes its index
import java.io.IOException;
import java.util.Arrays;
import javafx.application.Application;
import javafx.application.Platform;
import javafx.beans.Observable;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
@andytill
andytill / no war on russia motion.md
Last active March 25, 2018 13:39
no war on russia motion

Even before this horrendous chemical attack in Salisbury, this Government has been following a dangerous and aggressive line of rhetoric and action that will inevitably escalate conflict between the UK and Russia. In the context of the Syrian War, where Britain and Russia are supporting opposing sides in a proxy war[1], the majority of the casualties of this escalation will likely be Syrian.

This Constituency Labour Party believes that the line taken by the Labour Leadership, to require evidence of Russian involvement before taking action is correct but we must go further. Escalating conflict MUST be ruled out, regardless of the origin of the attack. The Government and Labour must not fight fire with fire, it must stop and choose a path that leads to peace rather than one that taken to it's conclusion, will end in war[2].

This Constituency Labour Party therefore calls on the Prime Minister, Theresa May, for restraint and de-escalation in words and actions towards Russia, and must stop military drills and ex