Saturday, October 4, 2014

Scala Snob

Although I hate to admit it, especially because I like to learn new programming languages, I think I've become a Scala snob.  For example, I wanted to learn Groovy so I could mess around with Grails and I simply cannot help but compare Groovy to Scala.  I keep thinking, why didn't they do it like Scala did, or its only one line in Scala, etc.

Sunday, November 11, 2012

Creating A Calculator for My Mac

I've been attempting to learn how to program in objective-c and cocoa so I can write some useful apps. One of the simplest things you can do to get familiar with a new GUI environment and framework is to write a simple calculator application.  I've yet to write code, but here is what it will look like when completed.

Nothing really too exciting here, but Xcode (Apple's IDE for mac, iPhone and iPad apps) makes it pretty simple to drag-and-drop visual components to make what I did here.
Enhanced by Zemanta

Monday, September 10, 2012

A Simple Stopwatch Class in Scala

I'm learning to program in Scala and one easy way I found to learn it is to start by creating unit tests for my java code in Scala using ScalaTest.  Part of what I like to do in testing portions of code is to get some simple performance statistics and traditionally I usually create or find a Stopwatch class library so that I can surround the code under test with it, which lets me see how long in milliseconds something takes to execute.  And so for the fun of it I wrote my own, very small, toy Stopwatch class in Scala.

class Stopwatch {
  var startTime = System.currentTimeMillis
  var elapsedTime: Long = 0

  def start = { startTime = System.currentTimeMillis; elapsedTime = 0 }
  def stop = { elapsedTime = System.currentTimeMillis - startTime }
  override def toString = "elapsed time: " + elapsedTime + " milliseconds"

object Stopwatch {

  def apply(): Stopwatch = new Stopwatch

  def time(tag: String)(f: => Unit): Stopwatch = {
    val sw = Stopwatch()

One nice thing about Scala is the ability to create your own control structures so I did that in the Stopwatch singleton object that I created which lets me do something like the following

class StopwatchUnitTest extends FunSuite {
  import Stopwatch._
  test("smoke") {
    val sw = time("timing 'Thread.sleep(1000)'") {

Well that's that.  More next time.

Wednesday, June 29, 2011

Using CDI in Java SE 6

What I really like about Weld which is the CDI (Context and Dependency Injection) reference implementation used in servers such as Glassfish and JBoss, is that they provide an extension where you can use most of the CDI features within a simple java application.

One of the main benefits for me is that i can test ideas I have for my web and Java EE work in a quick java app without having to wait for long builds and server deployment.  Of course it's also just a great way to write software, and any old java app could benefit from it, and it saves you writing a lot of needless code.

Here is a simple java program that prints out "Hello, Weld!"

public class WeldSeTest {

 public void sayHello(@Observes ContainerInitialized event) {
  System.out.println("Hello, Weld!");

Thursday, June 23, 2011

Syntax Highlighting Test

 Event<IncSessionCount> incSessionCount;

 Event<DecSessionCount> decSessionCount;

 private ReviewDocumentTracker tracker;

  * Default constructor.
 public SessionManagerBean() {

Friday, December 5, 2008

Netbeans 6.5 Subversion Woes

I have been trying to understand how Netbeans 6.5 (or any version) works with Subversion. There is a menu under Versioning called Subversion. In that there are a number of options, but the one I need, Import into Repository, is inactive. So how then am I supposed to import my local source into my remote svn repository?

I usually prefer Eclipse. It has been my IDE for a number of years. In Eclipse, versioning using Subversion is so simple. You add a repository location. The when you want to share your code by placing it into the repository, it just takes a few clicks to have it importing your source. So when I decided to use Netbeans to work on my PHP code, I found it easy to do because the .svn folders were already created when I was using eclipse. But when it comes to putting a new project into svn, I see nowhere how to configure a remote repository. So I am lost.

So why netbeans over exclipse? Netbeans has a much better IDE for PHP, especially with its code completion stuff. Eclipse PDT seems to be lacking. A collegue of mine hates eclipse so he decided to try Netbeans for our project. He kept talking about how cool it is, so I thought I'd give it a try. What made me hesitant to try it is with my experience using the beta version of netbeans 6.5. The php ide at that time just sucked, and even cause the ide to crash. It appears now that all the bugs were fixed. So I'll continue playing around with it. No doubt I am doing something wrong. We'll see.

Sunday, November 30, 2008

CritterCrawler: A Hypothetical Twitter App

I'm not sure if there is anything like this out there for the Twitter community, but I think it might be useful to have.

Every time I log into to my mac, I find an email in my inbox describing some new *itter app, which is a web app that adds some sort of functionality to twitter that twitter itself lacks.  For example, today I got a notification that new app called Mr. Tweet that finds "looks through your extended network to help you build effective relationships on Twitter."  I like it and I am now following a few more tweeters whose tweets seemed interesting.

Next is Qwitter which "e-mails you when someone stops following you on Twitter."  Not sure if I really want to know who has stopped following me.  I just can't take that kind of rejection.

So I thought to myself, maybe I should create an app that uses Twitter, and I am calling it CritterCrawler (or critterc or ccritter), which is a what I term the Creepy Twitter Crawler.  What does it do?  Well, I'm not sure.  But I imagine that it will be a kind of thing that crawls about and collects the tweets (is this the correct term?) of those that you follow and those that follow you in order to find matches to the things that interest you.  If the tweet points to a url then that will be crawled, but probably only to one level deep, and, as with finding tweets, it will bring to your attention any information that matches your bio, tags, interests, etc.

I can also imagine that it could also crawl, very similar to mr. tweeter, to find people and/or pages of interest.  If someon's tweets and links match your info (interests, etc), you would be notified and you could then choose whether you want to follow that person.

Although I have been a software developer for more than fifteen years and no doubt I could attempt with some measure of success to do it myself, I'd rather some young, eager person take it on because I seem to no longer have the stamina or motivations.  These days I'd rather think than do--you might say that I am an "open 'source' thinker," who lets others capitalize on the ideas.  

Reblog this post [with Zemanta]