Archive

Archive for the ‘General’ Category

Easy, Simple, Wrong

December 17th, 2009

<rant>
Hey everyone, you can’t simplify indefinitely so stop trying so square the circle!

I’m not saying stop trying to simplify things, just stop once there’s a minimal and acceptable level of complexity. If you dumb it down too much, it’s plain wrong.

Once you’ve reached that point, either you leave well enough alone, or add to it by organizing things. More often than not organizing will actually degrade runtime performance but will decrease development time. If you’re not happy with that, maybe development isn’t for you. You’re likely going to prefer messes and will spend too much time shifting crap around instead than dealing with it.
</rant>

Sorry about that. :)

General, Ideas, Programming, Rants ,

Week 2 Recording – Imagine

November 14th, 2009

Here’s this week’s recording. I chose “Imagine” by John Lennon primarily because it’s a good campfire song. Not knowing the words to this one was an especially embarassing position to be in since I’ve been playing this song since I’ve been 17.

Without further ado: Here’s a link to this week’s recording.

I hope you like it.

General, Music ,

Week 1 Recording – I Don’t Want to Grow Up

November 4th, 2009

It’s early. Last week I said I would post a recording before midnight on Nov 5th and it’s the fourth, but I had no choice. I’ve got a pretty bad chest cold and am losing my voice (I sound like a pubescent kid at some parts of the recording :) ). If I’d waited till tomorrow to record it, there’s a good chance it couldn’t have happened.

That being said, I’m happy with the way things turned out. I played the song from beginning to end without any lyric sheets or other visual aids infront of me! The day I posted my intention to learn the song my friend Bill Love sent me the following collage he’d made as a joke. Thing is, it worked! Very well too. Within a couple hours, I could play the song without even needing visual aids. Thanks a lot Bill!

So, anyway, without further ado, here’s a link to the recording: http://www.machete.ca/wp-content/uploads/2009/11/I don’t want to grow up.mp3.

So to keep myself honest, again I declare that the next recording will be out by the stroke of midnight on November 14th EST.

I haven’t decided what song to do you yet, so suggestions would be welcome. I’ll decide by this Saturday what I’m doing and edit this post accordingly.

Thanks for tuning in :)

General, Music , ,

Becoming a Better Musician…

October 30th, 2009

Next blog entry in this series can be found here.

I don’t typically post personal blog entries on my blog, as evidenced by the fact that I didn’t have a category by that title until now, so I hope you’ll forgive me for posting this one.

For the last 4 years or so I’ve been keeping busy with work and family. So much so that I haven’t made time to play the guitar and was too wise to try while the kids slept (anyone who’s ever seen a 3am child induced evil eye will understand what I mean). Now that my kids are sleeping better, it’s time to break out the 6 string again.

I have an admission to make though: I don’t remember lyrics. Ever. Not popular camp fire songs, not even Oh Canada. To make it even more embarrassing, I don’t remember the words to songs that I’ve written myself, including my wedding song (though to be fair, I can make my way through more than half of it from memory).

So, how can I fix this? Practice of course, but how can I make sure that I follow through with the practice? This blog, and the subsequent ones are my attempt. If it doesn’t work, this is going to be, gulp, awkward.

As a disclaimer, I have played before. It’s just been a while since I’ve done so at a level I’m happy with. I play guitar and I sing. Since I was paid 50 bucks once to play at a bar, I guess you can say that I’ve even done so professionally. But even then I was never able to do it without my idiot sheets in front of me.

So, here goes…

I pledge to post a recording of myself playing a song from memory once a week for the next 5 weeks.

First song will be posted by midnight on November 5th, 2009 and will be “I don’t want to grow up” by Tom Waits. I chose that one because I like it and I’d really like to know the words by heart.

If you don’t know the song have a look, and you’re welcome in advance:

So, tune in next week for this weeks exciting conclusion…


Edit: My friend Bill Love just sent me the following picture as a joke, but it might just be the perfect mnemonic for me! I can “see” the picture in my mind and follow along with it! Thanks Bill! It’s my desktop background for the rest of the week.



General, Music, Personal , ,

Social Networks: A boon for business, but not for users.

August 17th, 2009

Forgive the rambling nature of this post, but there are few things that make me spout more jibberish that a strong opinion.

Except for a couple of sites which exist solely because they are social networks and always have been, I’d say that most sites out there are trying to grow social networks for all the wrong reasons.

Most sites that are implementing social networks are doing so because they wish to go viral and grow their user base (which I think is a fundamental misunderstanding since sites don’t go viral, content does). Rarely is it because it provides a significantly better user experience for their customers. There are lots of benefits that could be had with a social graph that don’t require inviting (read pestering) friends as StumbleUpon demonstrates, but since they don’t improve a sites uptake they are rarely executed.

Anyone who’s suffered through Facebook’s latest incarnation will get a feel for what I’m talking about. Facebook apps are almost entirely terrible. I’ve yet to meet anyone who doesn’t wish there was a way of disabling the apps completely. Rare is the application that uses the social graph in a way that makes it better than its old school equivalent. I can’t possibly be the only one who clicks “Skip” when it asks me to notify my friends about my latest victory at some pointless game.

That’s not to say that I don’t like social networks when done right, it’s just that I see a lot of value going untapped because it’s more about virality than providing value to users.

One whole class of social applications that’s completely under represented is one that mines the social graph (relationships between users and their relationships to content) but doesn’t actually force it’s users to interact with other users. StumbleUpon, the site I mentioned earlier, does it perfectly, though recently it seems that they’re pushing the social part of it further. There was a time when you could use it without even being aware that it was a social network. You’d just happily click the button and get your digital pellet.

I think it’ll be a long while before this becomes a dominant approach to improving web apps since it doesn’t lend itself to going viral, but honestly, I think it’s the only one that won’t piss off most people tired of getting bitten by zombies, or getting an invite to yet another social network.

Rant over.

If you read this far… what’s wrong with you? :)

General ,

Neural Networks for Business Analysis

August 5th, 2009

First let me say that this idea isn’t quite flushed out yet, but it’s one that I hope you’ll find interesting.

First off, a little about what neural networks do:

1. They are approximate mappings from a set of inputs to a set of outputs
2. They can be trained with real world data
3. They handle fuzzy inputs pretty well

When you’re applying Neural Networks to a problem, you need to state the problem as a mapping.

For example, if I were trying to predict profitability of a factory, I’d decide on some things to measure about the factory and then relate those to its known profitability.

So for example, I might choose to measure # of employees, avg throughput per month, min throughput per work day, utilization, etc. and relate those things to the profitability of the factory as a measure between 0 and 1.

Now, one interesting thing about this is that some problems with my choices of measurements will become apparent during the training process.

If no matter how many samples I give it to train on or how many neurons the network has, it never seems to be any good at predicting profitability, then it means the things I’ve chosen to measure don’t matter.

If instead of wisely choosing things to measure, I’ve just measured every possible aspect of the factory, I’ll likely get something that predicts profitability, but that takes eons to train. Given that situation, I could start culling measurements and retraining, if the results don’t get worse and it takes less time to train it, then I can safely say that that particular measurement isn’t essential to the prediction (Think # of vending machines in the cafeteria). Repeating the process should lead to the minimum essential measurements and is essentially an automated form of Occam’s razor.

It is possible that no matter how hard I try, the thing won’t train. There might be no relation between inputs and outputs, though I think that for most problems the human beings chosing what to measure would rarely pick measurements that didn’t matter.

Anyway, like I said, this isn’t a finished thought, but i’m curious to know what other think about this approach.

General , ,

Making iBatis Type-Safe(r)

March 31st, 2009

iBatis recently came up as a near perfect solution to one of my problems. Its level of data abstraction is exactly right for what I’m doing and it provides out of the box caching. I’d previously tried Hibernate in this context but because my objects are long lived, I’d inevitably need to reconnect the objects to the active session anytime I wanted to do something interesting, like lazy loading.

But, and its a biggie, the interface when using iBatis is not type-safe; meaning I found myself with lots of error prone code resembling:

List<Product> products = (List<Product>)sqlMapClient.queryForList("getAllProducts");

When what I really wanted to do was write code like this:

List<Product> products = productDAO.getAllProducts();

Now, there are existing iBatis DAO options, but it seems to me they don’t solve this specific problem. Their approach to DAOs is a coding convention more than a framework, so you end up encapsulating the type-safety problems, but you still write the code.

With that in mind, I’ve written a utility library that very thinly wraps the iBatis library in a (mostly) type-safe way that doesn’t require me to implement all the access code myself.

I’ll start by providing some example code that makes use of it, and then drilling down into the code that makes it possible.

First off I define my model classes:

public class Product {
  private int id;
  private String name;
 
  public void setId(int id) {
    this.id = id;
  }
 
  public int getId() {
    return id;
  }
 
  public String getName() {
    return name;
  }
 
  public void setName(String name) {
    this.name = name;
  }
}

And the DAO’s interface:

public interface ProductDAO {
  public List<Product> getAllProducts();
  public Product getById(int id);
}

And the actual usage would be something like:

DAOFactory daoFactory = new DAOFactory("path/to/ibatis/config.xml");
ProductDAO productDAO = (ProductDAO)daoFactory.buildDAO(ProductDAO.class);
Product product = productDAO.getById(1);
List<Product> products = productDAO.getAllProducts();

You’ll notice that line 2 does involve a Cast, but this is the only one required to work with the DAO, as opposed to normal iBatis usage which requires you to cast on practically every call.

And the magical class that makes it all possible:

public class DAOFactory {
	private SqlMapClient sqlMap;
 
	public DAOFactory(String configPath) throws IOException {
		Reader reader = Resources.getResourceAsReader(configPath);
		sqlMap = SqlMapClientBuilder.buildSqlMapClient(reader);
	}
 
	public Object buildDAO(Class<?> daoInterface) {
		assert (daoInterface.isInterface()) : "buildDAO only works with interfaces";
 
		String namespace = extractNameSpaceFromDaoClass(daoInterface);
 
		InvocationHandler handler = new SqlMapInvocationBridge(sqlMap, namespace);
 
		Object dao = Proxy.newProxyInstance(getClass().getClassLoader(), new Class[] { daoInterface }, handler);
 
		return dao;
	}
 
	private String extractNameSpaceFromDaoClass(Class<?> daoInterface) {
		String[] classNameParts = daoInterface.getName().split("\\.");
		String className = classNameParts[classNameParts.length - 1];
		assert (className.endsWith("DAO")) : "Invalid DAO Interface Provided";
		return className.substring(0, className.length() - 3);
	}
 
	private final class SqlMapInvocationBridge implements InvocationHandler {
		private String namespace;
		private SqlMapClient sqlMap;
 
		public SqlMapInvocationBridge(SqlMapClient sqlMap, String namespace) {
			this.sqlMap = sqlMap;
			this.namespace = namespace;
		}
 
		public Object invoke(final Object proxy, final Method method, final Object[] args) 
                  throws Throwable {
			if (method.getReturnType().isAssignableFrom(List.class)) {
				return sqlMap.queryForList(namespace + "." + method.getName(), args[0]);
			} else if (method.getReturnType().isAssignableFrom(Map.class)) {
				return sqlMap.queryForList(namespace + "." + method.getName(), args[0]);
			} else {
				return sqlMap.queryForObject(namespace + "." + method.getName(), args[0]);
			}
		}
	}
}

Since, at this point it’s only implemented as a thought experiment, it only supports SELECT, but with very little work, it could also allow calls to UPDATE, DELETE, and INSERT.

Suggestions/criticisms are welcome.

General, Java , , ,

The Problem with Mind Mapping Software

March 2nd, 2009

If you give a student a paper and explain the rules of Mind Mapping and let them at it, they run out of room, they create horrible looking diagrams, and they all draw different maps for the same concepts.

One solution to this was to move the process into software. The benefits are “obvious”:

  • Cleaner Maps
  • Easier Undo
  • Auto-Layout

What’s wrong with those… everything!

When you use software to Mind Map you’re deliberately restricting your maps to whatever the developers have gotten around to coding.

Pencil and Paper are far better Mind Mapping tools than all current Mind Mapping Software. Period.

Because…

  • There’s no learning curve, “How do I save again?”
  • You’re limited only by your imagination not the limitations of the software.
  • You can draw truly arbitraty relationships between thoughts in the diagram. You’d have a hard time drawing arrows that snaked themselves between all the branches of a MindMap in most software
  • Each diagram can be completely different than all of the others you’ve drawn

I’m not suggesting that its impossible or even detrimental to write software for Mind Mapping, only that current mind mapping software isn’t inline with the creativity mind mapping is supposed to engender.

I’ll write a follow up blog soon about what I think a Mind Mapping software should look like (Hopefully with an application to boot).

General

Die Facebook Die

February 21st, 2008

I just disabled my Facebook account. It’d been a long time coming, but I now think Facebook is mainly a voluntary spam service.

You sign up. You get spammed (App Invitations). The sleazy thing about it is that rather than being spammed by some faceless salesperson, you’re getting spammed by your friends and family.

Sure, one day they may return to their days of being a glorified global contact and relationship database, but I’m not holding my breath.

Adios and farewell.

Edit: Now I’m red faced. My brother started playing Word Challenge and I can’t refuse the competition, so I’m back on.

Tags: ,

General