Hollywood Security BS

GameDev,Java,Processing — Dillon @ 10:36 pm

I had watched Alicia Silverstone ‘hack’ a system recently and decided to make a mostly functional mock up like they do in the movies. I’m getting pretty comfortable in Processing and even though I really can’t stand Java anymore, I wanted to get this thing done and out of my head. I was just going to skip over this idea but inspiration just started flowing and I was idly solving it while getting coffee etc and I just had to get it on paper/code.

So here are the things it does:

  • Switches between two GameState objects login and success
  • Separate the view and the state (more on this)
  • Has a super cool blinking cursor
  • Handles shift, ctrl and meta (windows key) gracefully
  • Handles backspace
  • When you type muffin, it takes you to the super secret database … or whatever
  • Goes fullscreen (which you can’t see in this shot)

This could get out of hand real quick. First, I reused a ton of code from Tatris. But in Tatris, the game state was tied to a view. I had pictured this project having different views. Like instead of a password prompt, maybe there’d be a keypad with a combo. Same state object (authorized vs unauthorized) so I didn’t need to recreate the wheel. The problem is, I don’t really have a controller so I’m kinda breaking MVC. But I didn’t want this thing to bloat up so I just went with it.

Next, UI layer. Not great. I’m drawing text boxes and blinking cursors. It’s really pretty messy. I’d be better off picking some UI components or something and using those. It’s tough. Even in games, there’s so many UI differences. Different scrollbars, different OK type buttons. What a usability nightmare. But I’m trying to create an old school terminal so all the weirdness is actually good.

Anyway, it was a fun little diversion. There’s more on the github page.

Data Structures Book

Java — Dillon @ 10:29 am

On a slashdot thread I was discussing whether I should roll my own data structure or try to use one of the many, many Sun data structures.

Someone recommended this book.

Spring Framework

Java — Dillon @ 1:09 pm

Researching this Spring Framework. Most interesting so far is it’s touting of being modular. As in, you might only use it for a single feature and it wouldn’t be bloated.

swt, eclipse and OS X problems

Java — Dillon @ 6:37 pm

Following a hello world tutorial, I got stuck on this error:

java.lang.UnsatisfiedLinkError: no swt-carbon-3034

Couldn’t find anything so I thought I’d post the fix for someone like me out there:

Found it from an unusual source. Seems I couldn’t get the VM parameters to work so I have to do SWT’s not recommended suggestion of copying the file to the jre bin path. Although they never gave the file or the path! (I’m going to send them an email.)

Just do this:

cp [path to libswt-carbon-3034.jnilib] \
/System/Library/Frameworks/JavaVM.framework/Versions/1.4.1/Libraries/

Note that libswt-carbon-3034.jnilib is version dependant. It could be named libswt-carbon “anything” .jnilib. I found in [ECLIPSE HOME] /plugins/org.eclipse.swt.carbon_3.0.0/os/macosx/ppc

Validation Action

Java — Dillon @ 7:46 pm

Finished coding a validation action that parses a word followed by an array of words. For example, “ABC” would validate if “Another Bad Creation” was passed with it. This is going to be used in the ever complicated Acronym project that has been taking me forever to finish.

It’s case insensitive, you can see the usage example in the ‘main’ class.
(more…)

Mathematical constant e generator in Java

Java — Dillon @ 11:59 pm

A small class to generate the mathematical constant “e”. Complete with timer and digits per second clock. Unpolished. Here’s a quick benchmark and you can see that it doesn’t scale.

import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.Date;

/**
* calculate mathmatical constant e
*/

public class ECalculator {
private static final int numberOfDigits = 1000;
public static void main(String[] args) {
ECalculator myEClass = new ECalculator();
System.out.println("Calculating e to " + numberOfDigits + " digits ...\n");
Date start = new Date();
BigDecimal e = myEClass.doCalculation();
Date stop = new Date();
long elapsedSeconds = (stop.getTime()-start.getTime()) / 1000;
System.out.println("e is: \n" + e);
if (elapsedSeconds

Made useful build.xml file for use with Ant

Java — Dillon @ 12:30 am

The following build.xml file has a few targets that make compiling a project much simplier. Read on for more details.

I have the following directory structure:

(chris@hobbes)-(BackupLink)$ ls -l
total 20
drwxrwxr-x    3 chris    chris        4096 Apr 21 00:07 bin
-rw-rw-r--    1 chris    chris        2776 Apr 21 00:15 Build.xml
drwxrwxr-x    2 chris    chris        4096 Apr 13 19:07 CVS
drwxrwxr-x    2 chris    chris        4096 Apr 20 14:32 include
drwxrwxr-x    4 chris    chris        4096 Apr 21 00:06 src

In Eclipse, I set the project preference to make [project root]/src the only folder on the source path. Lastly, I set bin to be the output folder. The ant script grabs any jars out of include (mostly useless to me).

When I want to create a jar, I just run the jar target. I removes the java source files before creating the jar archive. You can also increment the version number to create ‘releases’. This is the best I can come up with right now.

<?xml version='1.0'?>

<project name="BackupLink" default="jar" basedir=".">
	<!-- set global properties for this build -->
	<property name="version" value="0.1" />
	<property name="src" value="src"/>
	<property name="build" value="build"/>
	<property name="jarname" value="backUplink.${version}.jar"/>
	<property name="docs" value="docs"/>
	<property name="include" value="include"/>
	<property name="lib"  value="lib"/>
	<property name="runclass" value="com.squarism.backUplink.BackUplink"/>
	<property name="classpath"  value="classes"/>
	<target name="init">
	    <!-- Create the build directory structure used by compile -->
	    <mkdir dir="${build}" />
	    <mkdir dir="${build}/classes" />
		<!-- Create the directory for the jar file -->
	    <mkdir dir="${lib}" />
		<!-- Create the directory for the java docs -->
	    <mkdir dir="${docs}" />
	</target>
	<target name="compile" depends="init">
		<!-- copy all .java files from ${src} to ${build}  -->
		<copy todir="${build}/">
			<fileset dir="${src}" />
			<!-- apply a substitution @version@ with the value of ${version} -->
			<filterset>
				<filter token="version" value="${version}"/>
			</filterset>
		</copy>
		<!-- run javac to compile the source files -->
		<javac srcdir="${build}" destdir="${build}">
			<classpath>
				<!-- use the value of the ${classpath} property in the classpath -->
				<pathelement path="${classpath}"/>
				<!-- include all jar files  -->
				<fileset dir="${include}">
					<include name="**/*.jar"/>
				</fileset>
			</classpath>
		</javac>
	</target>
	<target name="jar" depends="compile">
		<delete>
			<fileset dir="${build}" includes="**/*.java"></fileset>
		</delete>
	    <!-- make a jar file -->
	    <jar jarfile="${lib}/${jarname}" basedir="${build}" manifest="${build}/manifest" />
	</target>
	<target name="run" depends="jar,docs">
		<!-- run the class -->
		<java classname="${runclass}">
			<!-- add a command line arg: <arg value="-h"/> -->
			<classpath>
				<!-- use the value of the ${classpath} property in the classpath -->
				<pathelement path="${classpath}"/>
				<!-- include all jar files  -->
				<fileset dir="${include}">
					<include name="**/*.jar"/>
				</fileset>
				<fileset dir="${lib}">
					<include name="**/*.jar"/>
				</fileset>
			</classpath>
       </java>
	</target>
	<target name="docs" depends="compile">
		<!-- create javadocs -->
		<javadoc packagenames="com.squarism.backUplink.*"
		sourcepath="${build}"
		defaultexcludes="yes"
		destdir="${docs}"
		author="true"
		version="true"
		use="true"
		windowtitle="BackUplink API Documentation Version: ${version}">
		</javadoc>
	</target>
	<target name="clean">
		<delete dir="${build}"/>
		<delete dir="${docs}"/>
		<delete dir="${lib}"/>
	</target>
</project>

Acronym Project – Ant and Eclipse

Java — Dillon @ 12:21 pm

Having some problems getting Ant running the way I want to. It’s another question of whether the IDE (Eclipse) is being too inflexible or if I’m not doing something right. Eclipse doesn’t ship with functionality that allows ant build options. Here’s a log of what I’ve been trying.
(more…)

Acronym Controller – cookies

Java — Dillon @ 11:44 pm

Update on new functionality.
(more…)

Acronym Challenge Demo

Java — Dillon @ 10:15 pm

I’ve deployed the 1st version of the Acronym Challenge webapp to the server at this location.

(more…)

Next Page »
This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License.
(c) 2012 SQUARISM | powered by WordPress with Barecity