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]

Sunday, November 23, 2008

Website Images: Clip and Post

I think that it would be really cool if I could "clip" pieces of a web page, or right click on an image, and have it posted to your favorite photo site (e.g. flickr, picassa, etc.).  One of the reasons I would like to be able to do this is when I am blogging and want to embed an image.  Right now you can copy the image link from some image and embed it, or you can upload it to blogger (or whatever blog you have) and it will be embedded for you.

The problem with embedding an image that references the image from some web page is that if the image is moved or deleted, all you'll see is that box with the broken link image.  So why not upload from your PC?  Well, you can, but first you need to capture the image, save it to your hard drive, then go into your blogging app and upload it.  Too many steps.

Too ensure that the picture is always accessible and doesn't require a bunch of steps for uploading, you can upload the image to your flickr, picassa, etc., account.  Yes, this also requires several steps, too, but if I could do this all from a click or two on a web page, then that would make things simpler.

Another thought I had for wanting to do this is to be able to keep "scraps" in a kind of digital scrapbook.  I am always clicking, searching and surfing to find interesting stuff, and of course many things are related, but they are spread out over the place.  I can imagine a plugin that allows one to create a "scrapbook page" and as you surf, all you would need to do is clip part of the screen and have it saved in your book.

The reason  I want images instead of actual text is because it's not modifiable.  And what you are clipping is the exact representation.  But the images will be linked to the page from which they were clipped.

Now, alot of this can be done with a program called Jing.  Jing runs on the Mac (yay!) and Windows (booo) and allows you to capture any portion of the screen as image or live video (for making screen casts).  It allows you to upload video to, a service that offers limited free access (2gig), or if you capture an image you can send it to either or flickr, which, although free, limits you on storage as well.  But you can also save videos and images a via ftp or as a file.  For example, if I capture an image and save it to flickr, I can have it return the embed code so that I can just put it right in my blog. But Jing is limited to the folowing (see, I cliped this):


So okay, it's great for my first requirements.  But Jing is fixed in that these options are your only options.

But what about the clip and ship to a scrapbook?  This is where I thought a plugin could be made for all of the popular web browsers and that would confine you within the browser window, which is perfect, and provide a simple click to snip and save.  Okay, so with some playing I could do this with a word processor or something, but I thought that an integrated solution would be cool.

Of course this idea goes beyong the static scrapbook page.  I want the thing to create a page that would allow tagging and metadata and then present specific semantic relationships and recommendations.  This way I can use the thing in the way I think, the way I need it to be.  I want it all integrated and intelligent.  I don't mind that there are all of these applications out there to do similar things. I just want a way to pull them together to create something new... like a mashup but better.

Reblog this post [with Zemanta]