Code
Stop ACTA
by Jason on Jan.22, 2012, under .NET, Alcohol, C#, C++, Code, Code, Code, Code, Games, HTML5, IDEs, Java, Let's Code, Let's Play, Life, Movies, Music, Programming, Technology, TheMotleyBrit, Uncategorized, VB, Video Games, Vlog
No to Internet Censorship. Stop this bullshit.
Quote of the Day
“The current draft of ACTA would profoundly restrict the fundamental rights and freedoms of European citizens, most notably the freedom of expression and communication privacy.”
An open letter signed by many organizations, including Consumers International, EDRi (27 European civil rights and privacy NGOs), the Free Software Foundation (FSF), the Electronic Frontier Foundation (EFF), ASIC (French trade association for web 2.0 companies), and the Free Knowledge Institute (FKI)
Java Event Maps
by Jason on Oct.18, 2010, under Code, Java, Programming
I openly admit to not being fond of coding in Java. It’s just not got the elegance C# has. However, I will use Java if only to remind myself why I don’t like using it.
I recently did just this. Largely so I could see whether the event queue system I made in C++ could easily port to Java and C#. Guess what? It does. This pleases me.
Here’s a code example of how to use the event queue:
package eventtesting;
import JpmEvents.CEventMap;
import JpmEvents.IEvent;
import JpmEvents.IEventHandler;
import JpmEvents.BEvent;
/**
*
* @author Jason
*/
public class Main
{
private class TestEvent1 extends BEvent { public TestEvent1() { super("TestEvent1"); } }
private class TestEvent2 implements IEvent
{
public Integer Hash() { return Name().hashCode(); }
public String Name() { return "TestEvent2" }
public TestEvent2() { }
}
private boolean OnEvent(TestEvent1 e)
{
System.out.println("Event One Called!!!");
return false;
}
private boolean OnEvent(TestEvent2 e)
{
System.out.println("Event Two Called!!!");
return false;
}
protected void Run()
{
CEventMap emMap = new CEventMap();
emMap.Bind(new IEventHandler<TestEvent1>(){public boolean HandleEvent(TestEvent1 event){return OnEvent(event);}}, "TestEvent1");
emMap.Bind(new IEventHandler<TestEvent2>(){public boolean HandleEvent(TestEvent2 event){return OnEvent(event);}}, "TestEvent2");
System.out.println("Triggering events...");
emMap.Trigger(new TestEvent2());
System.out.println("Queueing events...");
emMap.Queue(new TestEvent1());
emMap.Queue(new TestEvent2());
emMap.Queue(new TestEvent1());
System.out.println("Flushing events...");
emMap.Flush();
}
/**
* @param args the command line arguments
*/
public static void main(String[] args)
{
Main m = new Main();
m.Run();
}
}
And here is the link to the Project Kenai page I’m making the library and it’s source available on, under the MIT Licence
.
Quote of the Day
“I account for morality as an accidental capability produced,
in its boundless stupidity, by a biological process that is normally
opposed to the expression of such a capability”
George C. Williams (May 12, 1926 – September 8, 2010)