Skip to content

Instantly share code, notes, and snippets.

View salamander2's full-sized avatar
🏠
Working from home

Salamander2 salamander2

🏠
Working from home
  • Canada
View GitHub Profile
public class SplittingUp {
public static void main(String args[]) {
String str = "this is a long string. With lots of words. And other stuff. It just goes on and on and on";
String[] strArray = str.split(" ");
int slen = 20;
String newStr = "";
for (int i=0; i< strArray.length; i++) {
newStr += strArray[i] + " ";
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.border.*;
public class Layout2 extends JApplet {
// string array for jlist
private String[] receiptList = new String[15];
{
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.border.*;
// Make it a JFrame instead
//public class Layout2 extends JApplet {
public class Layout2 extends JFrame {
public static void main(String args[]){
@salamander2
salamander2 / mahjongg.control.sh
Created March 24, 2013 01:22
Bash script to control execution of a game (time played, etc). It only allows the game to be played between certain hours and also tracks the total time in a day that has been played, killing the game if either condition is surpassed.
#!/bin/bash
#set up constants
TIME1=12 #start hour (24 hour clock)
TIME2=20 #end hour (24 hr clock)
TIMELIMIT=60 #mintues
PGMNAME="mahjongg" #exact name used for killall and for TIMEFILE
PGMPATH="/usr/games/$PGMNAME"
TIMEFILE="$HOME/.local/$PGMNAME.elapsed"
STARTTIME=`date +%s` #seconds since 0000 UTC
@salamander2
salamander2 / hexgame.java
Created December 18, 2012 17:03
Hexagonal Grid in Java
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
/**********************************
This is the main class of a Java program to play a game based on hexagonal tiles.
The mechanism of handling hexes is in the file hexmech.java.
Written by: M.H.
Date: December 2012
@salamander2
salamander2 / AboutDialog.java
Created July 24, 2012 00:58
Science Olympics -- Function Identify program. The main program is Function.java View the JApplet at http://quarkphysics.ca/temp5661 .
package sciOlympics;
import java.awt.*;
import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
/* This class makes a pop-up dialog box. It works as an application or JApplet.
The code for this is based on http://www.jguru.com/faq/view.jsp?EID=27423