Thursday, September 23, 2010

Break Time with Web Pics


My latest version of Break Time has contextual Web Pics. You put in a theme for pictures you would like to see, and it pings Yahoo Picture search and grabs a random picture.

In this example, you can see some of the possibilities it came up with when I prompted it with mountain.

It aint perfect yet because you have to modify the config file in the installation directory for it to work, but still, I think it looks rather nice.

Why not download it from here and see what you think? You need to be taking breaks every 15 minutes while you are at the computer, Break Time makes sure that you do!

Tuesday, March 30, 2010

A cooler Easter Break Time....

So, I finished a new version that is kind of fun. instead of a blah window, it has a cute little set of easter bunnies. But if you start it up, in 15 minutes, it will remind you to take a break. I even built an installer for it. You can access it here:

http://www.fishnetgames.net

Another cool thing I like about it is that it gives you the minutes left until the break in the status bar itself.

Give it a try. I promise, no spyware. Then email me to tell me if you think it could be useful to give you much needed breaks!

Thursday, March 18, 2010

Converting My Swing Break Reminder to Groovy: Part 1



I have ergonomic muscle strain issues. Experts recommend that you take breaks every 15 minutes to alleviate that pain, and give your muscles a rest. So, a long time ago, I wrote a small java app that would remind me to take a break every fifteen minutes. Here is the code for it:

import javax.swing.*;
import java.awt.*;
import java.awt.event.WindowStateListener;
import java.awt.event.WindowEvent;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.util.Date;
import java.util.Locale;
import java.util.ArrayList;
import java.text.NumberFormat;
import java.text.DecimalFormat;
import com.ocpsoft.pretty.time.BasicTimeFormat;
import com.ocpsoft.pretty.time.TimeFormat;
import com.ocpsoft.pretty.time.TimeUnit;
import com.ocpsoft.pretty.time.PrettyTime;
import com.ocpsoft.pretty.time.units.Second;
import com.ocpsoft.pretty.time.units.Minute;

/**
* Created by IntelliJ IDEA.
* User: BrentFisher
* Date: Aug 18, 2009
* Time: 2:07:18 PM
* To change this template use File | Settings | File Templates.
*/
public class TimeReminderWindow {

public static void main(String [] args){
TimeReminderWindow trw = new TimeReminderWindow();
trw.start();

}

long timeToWait = 15 * 60 * 1000;// 15 minutes
long lastUpdate = System.currentTimeMillis();

private void start() {
final JFrame frame = new JFrame("Time Reminder");
final JButton button = new JButton("Click here to reset");
final PrettyTime p = new PrettyTime();

frame.getContentPane().add(new JLabel("Take a break",SwingConstants.CENTER), BorderLayout.CENTER);
frame.getContentPane().add(button, BorderLayout.NORTH);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
frame.setBounds(screenSize.width/2 - (640/2),
screenSize.height/2 - (480/2),640,480);
button.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e) {
lastUpdate = System.currentTimeMillis();
frame.setState(JFrame.ICONIFIED);
}
});
Timer timer = new Timer(1000, new ActionListener(){
public void actionPerformed(ActionEvent e) {
long now = System.currentTimeMillis();
if(now - lastUpdate > timeToWait){
frame.setState(JFrame.NORMAL);
frame.toFront();
}
frame.setTitle("Break " + p.format(new Date(lastUpdate + timeToWait)));

}
});
lastUpdate = System.currentTimeMillis();
timer.start();
// frame.pack();
frame.setVisible(true);
}
}


The Book Groovy in Action claims that writing Swing code in Java is three to four times longer. So, I'm gonna put that to the test in this article. Plus, I've always wanted to put in some helpful ergonomic reminders in too, so I'll see if I can do that.

Here is the code, and here is the reminder window:

import javax.swing.*;
import java.awt.*;
import java.util.Date;
import com.ocpsoft.pretty.time.PrettyTime;
import groovy.swing.SwingBuilder;
import java.awt.BorderLayout as BL
import java.awt.event.ActionListener
import java.awt.event.ActionEvent

long timeToWait = 15 * 60 * 1000;// 15 minutes
long lastUpdate = System.currentTimeMillis();
def swing = new SwingBuilder()
final PrettyTime p = new PrettyTime();
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
def button1 = swing.button( 'Click here to reset')

def frame = swing.frame(title: 'Time Reminder',
defaultCloseOperation: JFrame.EXIT_ON_CLOSE,
bounds: new Rectangle((int) screenSize.width / 2 - (640 / 2),
(int) screenSize.height / 2 - (480 / 2), 640, 480)) {
panel(layout: new BL()) {
widget(button1,constraints: BL.NORTH)
label constraints: BL.CENTER, horizontalAlignment: SwingConstants.CENTER, 'Take a break'
}
}
button1.actionPerformed = {
lastUpdate = System.currentTimeMillis();
frame.setState(JFrame.ICONIFIED);
}

Timer timer = new Timer(1000, {ActionEvent e ->
long now = System.currentTimeMillis();
if (now - lastUpdate > timeToWait) {
frame.setState(JFrame.NORMAL);
frame.toFront();
}
frame.setTitle("Break ${p.format(new Date(lastUpdate + timeToWait))}");
} as ActionListener);

lastUpdate = System.currentTimeMillis();
timer.start();
// frame.pack();
frame.setVisible(true);



But I have to say, the whole part of getting the button registered for action performed was pretty tricky and I spent more than half an hour doing it. The code was reduced to 43 lines from 71, but the builder part was actually trickier than I thought it would be, and both use 15 lines of code. So, I'm not completely sold on its usefulness.

Part II will be to query Google for some ergonomic images, and automatically put those on the screen. Stay tuned...

Monday, January 18, 2010

Giving Aid to Haiti

OK, OK, I know that only believers are supposed to be charitable, and I've tried to resist the temptation to give in to my humanity. As much as I have struggled to resist the temptation, I could no longer resist. I have donated to the international Red Cross and Doctors without borders.

Won't you take a minute to help the Red Cross or Doctors without borders too?

Follow the link on this page, or choose a different route. There are so many ways to get your money there.

Cheers!

in reference to: Skeptic » eSkeptic » Sunday, January 17th, 2010 (view on Google Sidewiki)

Wednesday, January 13, 2010

Groovy business rules

I love this way to make the DSL presented here. I just wish I could find more ways to put it into a sandbox, besides the heavy hand of the java security sand box.

in reference to: Practical Groovy DSL (view on Google Sidewiki)

Great post on showing code in blogger

Thanks Vivian for showing me how to post code on blogspot. As a burgeoning code blogger, this really helps out!

in reference to: Vivian's Tech Blog: How to post source code in blogspot.com (view on Google Sidewiki)

Creating a Groovy DSL for Financial Product Fee Schedules


I'm currently working on a project that requires a variable fee schedule.
E.g.

Product Name Category Feature Value Date Range Functional Setting Applicability
General ACH Generation






ACH Generation Fees ACH Transaction Fee 1.00 Account Open Date Account Closed Date 0 to 10 transactions


ACH Transaction Fee .50 Account Open Date Account Closed Date 10 or more transactions

Credit Card Generation Fees CC Transaction Fee 1.00 Account Open Date Account Closed Date 0 to 10 transactions


CC Transaction Fee .50 Account Open Date Account Closed Date 10 or more transactions

I need a way to specify the date range that would include things such as account open date and plus 3 months and transaction ranges. Groovy DSL seems like the perfect fit. See Guillame Laforge's example here.

I came up with the following:

package com.aps.utils

import com.aps.util.DateUtil
import org.codehaus.groovy.runtime.TimeCategory


class ProductCatalogDSLTests extends GroovyTestCase {


def account

void setUp() {
account = new Account(from: DateUtil.sdf.parse("01-01-2010"))
}

void testAccountOpenedDate() {
def rule = 'transactionDate > account.from'
def binding = new Binding()
binding.account = account
def shell = new GroovyShell(binding)
def date = DateUtil.sdf.parse('01-10-2010')
binding.transactionDate = date
assert shell.evaluate(rule)
binding.transactionDate = DateUtil.sdf.parse('05-10-2009')
assertFalse shell.evaluate(rule)

}

void testAccountOpenedDate_plus3() {
def rule = 'transactionDate < account.from+6.months'
def binding = new Binding()
binding.account = account
def shell = new GroovyShell(binding)
def date = DateUtil.sdf.parse('01-10-2010')
binding.transactionDate = date
use(TimeCategory) {
assert shell.evaluate(rule)
binding.transactionDate = DateUtil.sdf.parse('05-10-2010')
assert shell.evaluate(rule)
}
}

void testTransactionMinimum() {
def rule1 = 'account.transactions.size < 10'
def rule2 = 'account.transactions.size >= 10'
def date = DateUtil.sdf.parse('01-10-2010')
0..5.each {
account.transactions << new AccountTransaction(amount: 15.00, postDate: date)
}
def binding = new Binding()
binding.account = account
def shell = new GroovyShell(binding)
binding.transactionDate = date
use(TimeCategory) {
assert shell.evaluate(rule1)
assertFalse shell.evaluate(rule2)
}
}

void testTransactionMinimumThisMonth() {
def rule1 = 'account.transactions.collect{it.postDate.month == transactionDate.month}.size < 10'
def rule2 = 'account.transactions.collect{it.postDate.month == transactionDate.month}.size >= 10'
def date = DateUtil.sdf.parse('01-10-2010')
use(TimeCategory) {
assertEquals 0 , date.month
assertEquals 10 , date.date
assertEquals 2010 - 1900 , date.year
0..5.each {
account.transactions << new AccountTransaction(amount: 15.00, postDate: date)
}
def binding = new Binding()
binding.account = account
def shell = new GroovyShell(binding)
binding.transactionDate = date
assert shell.evaluate(rule1)
assertFalse shell.evaluate(rule2)
}
}
}
class Account {
Date from
Date to
def transactions = []
}
class AccountTransaction {
BigDecimal amount
Date postDate
}

It ended up working well for dynamic business rule selectors.

Monday, January 4, 2010

A reason for Death

My friend Mike studies Evolution, Biology and Bioinformatics at UVU. He and I often engage in wonderful thought provoking discussions on life, and our part in it.

I appreciate Mike's thoughts here on the evolution of death. Death was developed through evolution. It reminds me of the gentlemen from Canada who continuously talks about developing gene therapy to continuously delay death. But none of that will happen while researchers continue on the assumption of death as a requirement of part of life.

in reference to: Evolution and Bioinformatics: Life Ascending and the evolution of death (view on Google Sidewiki)

Monday, December 21, 2009

Stop the Obfuscation~!

Once again, I have to agree with you Brandon. There is another point to this as well. In the build that I run, with so many thousands of classes, each with hundreds (if not thousands) of lines of code, this obfuscation process takes quite a bit longer to run in the build. Anything that takes longer in the build, but doesn't offer clear developer benefit can deter developers from running the build (and tests) before check-in because it just takes too long.

Thanks for the great post Brandon.

in reference to: Java Programming Tip: Why Not to Obfuscate - mechanicalSPIRIT (view on Google Sidewiki)

Friday, December 18, 2009

Spanky's closed down?


After my wonderful experience at Spanky's following my 7 year old daughter's driver's ed course, I fell in love with Spanky's. So did she. Their environment was comfortable, clean and friendly, and their food tastes great.

I was really sad though that for her birthday, they were unexpectedly closed. I visited yesterday in hopes for delicious lunch. Again they were closed. Called today too. But they appear to be closed.

What is going on Spanky's? I am in need of your Fresh Delicious Guacamole Burger!

in reference to: SPANKY'S EXPRESS (view on Google Sidewiki)

Friday, December 11, 2009

Sketchy designs

Many of you may be looking for a comparison of a lot of the mockup / sketchy design tools. While I haven't tried all of these tools out, and I really do love Balsamiq, this may be a nice place to start! Now if I could just find that cool data graphing design tool I saw yesterday...

in reference to:

"Comparison of Computer Based Sketchy ToolsSoftware developers are starting to recognize the importance of computer-based sketchy wireframes, and there is a growing assortment of tools to create them. This is a quick breakdown of how each of the major tools matches our criteria for a complete computer-based sketchy tool:"
- Sketchy Wireframes - Boxes and Arrows: The design behind the design (view on Google Sidewiki)

Thursday, December 10, 2009

your mockup prototype as a PDF

OK, so this feature is super awesome. Providing a way to export a mockup, with clickable interaction. This is awesome. Today in fact, I sent off a screen full of mockups to some stakeholders, wishing I could demonstrate the flow better than just a bunch of mockup screenshots lined up in a row.

in reference to: Balsamiq Exports Multi-Canvas Mockups to Single PDF | Konigi (view on Google Sidewiki)

SketchFlow vs Balsamiq

Sketch flow looks very neat, and I do really wish that Balsamiq would add the ability to sketch out some of the workflows, and I wish that it would provide stakeholders a player in which to view my mockups, and make their own sketches and marks and comments on it for a bit of historical marking.

in reference to: Why SketchFlow Is not a Mockup Software | .NET Zone (view on Google Sidewiki)

The Ponzi Scheme that stole my house in Highland

Some of you may have read earlier in my blog http://www.fishtells.com/2008/04/lure.html concerning the investments that went sour for me. Well, this is where my money ended up finally. Misused and abused by Mr. Rick Koerber. I'm glad he is being indicted and prevented from scamming even more people.

in reference to: Rick Koerber pleads not guilty to new criminal charges (view on Google Sidewiki)

Wednesday, December 9, 2009

drag-select controls inside container

I just wrote up my pet peeve:

The other thing I wish Mockups would do is give me an easy way to select the stuff inside of a dialog box, or other container. I.e. when I want to select the items in a dialog, I often end up selecting the container instead. I think it would be a little nicer to make the insides of the dialog box not so clickable. Maybe just the edges of the dialog box clickable would be well enough, then I could group select the controls inside.

This is meant to solve my problem, but in my latest version of Mockups, this doesn't work. When I shift drag, I don't get a lasso at all. In fact, it just appears to annoy me. Also, I liked the smiley face application icon in my task bar better. the one you got there now doesn't really look like anything.

in reference to:

"holding SHIFT when the mouse is over some controls will ignore them so that you can drag-select other controls. This is a small change but it’s pretty handy, here’s a quick video demonstration:"
- Balsamiq Company Blog (view on Google Sidewiki)

Even More improvements for Mockups

Balsamiq just released their newest version of Mockups, which includes some things that I've wanted, but didn't tell them I wanted. Somebody else told them though:
- Move dock ui library left, right, top
- dock the properties inspector (it gets in the way sometimes)

The one I think is the most useful is
- Stretchable Geometric Shapes

Seems dumb, but when I was making some more general purpose projects for cards night, I wanted some shapes, but I didn't want them to look so blocky. Now my shapes will look more natural. Way to go Balsamiq!

Coming up, they have a feature to fix an annoyance I encountered today... moveable document tabs.

Now, if I could just get them to make a really nice way to do UML. I alway feel like I'm piecing things together.

I realize of course that they made Mockups for screens, but I love to use it for my class diagrams, sequence diagrams and general flow diagrams as well.

in reference to: Balsamiq Company Blog (view on Google Sidewiki)

A DSL for processing Web Service Results

My latest project included the requirement to process web service results in a generic way. I thought to myself... This is a job for Groovy Script!

But it became somewhat troublesome as these scripts would be written by non engineers, and it also opened up some security risks.

So, now the question remains, how would I then secure these results processing scripts, while also making them easier to write from 'services' types of folks?

in reference to: A Domain-Specific Language for unit manipulations | Groovy Zone (view on Google Sidewiki)

Saturday, December 5, 2009

Follow the blog

I just added the follow my blog functionality. Why not follow my blog. I post on lots of stuff to make your development more productive. Just click on the follow link on the side. Then when I post something new, you'll be notified, and maybe you can put something great into your project too.

Design Mockups, realtime, real easy











A few months ago, I introduced Balsamiq mockups into my project because using Excel spreadsheets to design my screens was just stupid. I couldn't really 'communicate' with the rest of the team in India.

I still remember the night when I pulled this out. I remember Amit from Intelligrape in India happily exclaimed, with hope in his timbre, "Oh Brent, this is going to be so much better for us. Thank you."

He was right. It has increased the team velocity tremendously. We are able to work through the screens in realtime over YuuGuu, drilling down to the finest points of the design.

Here are a couple of the screen shots. We even use it for some class diagrams and sequence diagrams.


in reference to: Balsamiq Mockups Home | Balsamiq (view on Google Sidewiki)

Getting a signed in user in Grails tests

I found this to be helpful. I just needed one more piece of information.

def subject = [
isAuthenticated: true,
principal: "admin"
] as Subject

SecurityUtils.metaClass.static.getSubject = {-> return subject }
Subject.metaClass.getPrincipal = {-> return "admin" }

This way, when I needed the user later on in the code, when I called getPrincipal, I got it. E.g.

JsecUser currentUser = JsecUser.findByUsername(SecurityUtils.getSubject()?.getPrincipal());

in reference to:

"void setUp() {       def subject = [           isAuthenticated: false,           ...       ] as Subject       SecurityUtils.metaClass.static.getSubject = {-> return subject }       ...   }"
- Nabble - grails - user - JSecurity-Plugin and Integration-Tests (view on Google Sidewiki)