Skip to content

Instantly share code, notes, and snippets.

@moomoohk
moomoohk / gist:4650110
Created January 27, 2013 19:53
My config class. Uses Java properties instead of XML. Works fine when bundled in a JAR and run in the OS (as opposed to being run in the IDE). I made it a while ago so I don't really remember how everything works, or how efficient it is...
package com.moomoohk.ThreeD;
import java.util.prefs.Preferences;
public class Config
{
public static Preferences prefs = Preferences.userNodeForPackage(Config.class);
public void save(String key, int val)
{
public class OSUtils
{
private static String cachedUserHome;
public static enum OS
{
WINDOWS, UNIX, MACOSX, OTHER,
}
static
package psi;
import java.awt.Color;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
@moomoohk
moomoohk / CircularArrayList.java
Last active December 16, 2015 12:38
Added swap method
package mishael;
import java.util.ArrayList;
import java.util.Random;
public class CircularArrayList<Generic>
{
private ArrayList<Generic> a;
public CircularArrayList()
@moomoohk
moomoohk / ControlPanel.java
Created April 23, 2013 18:30
Control panel for D-Shizzwitt
package dylan;
import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
package networking;
import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.io.BufferedReader;
import java.io.EOFException;
@moomoohk
moomoohk / Grid.java
Last active December 27, 2015 13:39
package gridCheck;
import java.util.Scanner;
public class Grid
{
private boolean[][] grid;
public Grid(int row, int col)
{
public matrix mul(matrix B)
{
// Return a new matrix which is the matrix product of this
// with B.
if((rows()!=B.rows()) || (cols()!=B.cols()))
{
System.out.println("Error, cannot add since the 2 matrices do not have the same dimensions.");
System.exit(0);
}
matrix M = new matrix(rows(), cols());
@moomoohk
moomoohk / Mult.java
Last active December 30, 2015 02:09 — forked from anonymous/gist:7760387
// return C = A * B
public static double[][] multiply(double[][] A, double[][] B)
{
int mA = A.length; //row
int nA = A[0].length; //col
int mB = B.length;
int nB = A[0].length;
if (nA != mB)
throw new RuntimeException("Illegal matrix dimensions.");
double[][] C = new double[mA][nB];
@moomoohk
moomoohk / BrokerTest.java
Created August 4, 2014 04:17
A little demo+docs of how the TradeOrder system will work in Market Maven
/**
*
* @author Meshulam Silk (moomoohk@ymail.com)
* @since Aug 4, 2014
*/
public class BrokerTest
{
public static void main(String[] args)
{
/*