Skip to content

Instantly share code, notes, and snippets.

@snarkbait
snarkbait / FileIO.java
Created November 30, 2017 07:15
FileIO
package util;
import java.io.*;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.ProtocolException;
import java.net.URL;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
@snarkbait
snarkbait / Direction.java
Created November 29, 2017 08:07
Direction enum class - Advent of Code helper
package util;
/**
* @author /u/Philboyd_Studge on 12/26/2016.
*
* This enum set is for simplifying movement on a 2d integer grid
* Assuming the Y axis is -up(north) and +down(south),
* and X axis is -right(west) and +left(east)
*/
public enum Direction {
@snarkbait
snarkbait / CSVField.java
Created April 3, 2017 19:06
Annotations and Reflection: CSV-to-Object Reader
package csv;
import java.lang.annotation.*;
/**
* @author /u/Philboyd_Studge on 4/1/2017.
*/
@Inherited
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME)
@snarkbait
snarkbait / FVController.java
Created March 27, 2017 21:46
JavaFX Example - Future Value
package fvcalc;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.scene.control.ComboBox;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import logic.FVLogic;
import logic.FVLogic.CompoundType;
@snarkbait
snarkbait / Cards.java
Last active July 17, 2017 14:24
Poker Hand Scoring example for /r/javaexamples
package enumexample;
import java.util.*;
/**
* Cards class for playing cards. Uses simple integer-based system
* where the card face value is n mod 13 and the suit is n mod 4
* @author /u/Philboyd_Studge on 3/26/2016.
*/
public class Cards {
@snarkbait
snarkbait / DynamicArray.java
Created March 7, 2016 21:56
Dynamic Array example
import java.util.Arrays;
import java.util.Iterator;
import java.util.RandomAccess;
/**
* Dynamic Array class (based on java.util.ArrayList)
* for /r/JavaExamples - for tutorial purposes -
* @author /u/Philboyd_Studge on 11/18/2015.
*/
@snarkbait
snarkbait / DoublyChainedTrie.java
Last active April 25, 2017 13:13
String-Based Trie Example with Word Suggestion GUI
package trie;
import java.util.ArrayList;
import java.util.List;
/**
* Doubly Chained String/Character based-Trie
* @author /u/Philboyd_Studge on 1/13/2016.
*/
public class DoublyChainedTrie implements STrie {
package enumexample;
import javax.swing.*;
import java.io.IOException;
import java.nio.file.*;
import java.nio.file.attribute.BasicFileAttributes;
/**
* @author /u/Philboyd_Studge on 1/10/2016.
*/
@snarkbait
snarkbait / Coordinate.java
Last active December 28, 2015 05:08
Maze DFS/BFS example file for Coursera : UCSD Advanced Data Structures - Week 2
package util;
public class Coordinate {
private int row;
private int col;
public Coordinate(int row, int col) {
this.row = row;
this.col = col;
}
@snarkbait
snarkbait / Advent14.java
Last active December 14, 2015 07:21
Advent Day 14 AdventOfCode
import java.util.ArrayList;
import java.util.List;
/**
* @author /u/Philboyd_Studge on 12/13/2015.
*/
public class Advent14 {
List<Reindeer> deer = new ArrayList<>();