Tuesday, March 8, 2011
Thursday, January 13, 2011
Favorite Music of 2010
8) Genuine Negro Jig by Carolina Chocolate Drops
7) Broken Bells by Broken Bells
6) A Badly Broken Code by Dessa
5) Congratulations by MGMT
4) The Reluctant Graveyard by Jeremy Messersmith
3) High Violet by The National
2) Fantasies by Metric
1) Brothers by The Black Keys
None of them released new albums, but I also spent many, many hours listening to The Avett Brothers, Elliott Smith and Ben Folds this year.
My biggest disappointment of the year is Lonely Avenue by Ben Folds and Nick Hornby. I love them both, but man, that's a bad album.
I'd also like to point out that this year sucked if you're a hip hop fan. I know everyone will call 2010 the year of Kanye, but My Beautiful Dark Twisted Fantasy was just good. Maybe I haven't spent enough time with it, but I don't think it's as groundbreaking as every critic says it is.
Thoughts?
Monday, August 30, 2010
Closet Project
One of our least-favorite things about our room is the closet. It's a decent size for two people - a normal depth and at least 8 feet long. The flaw has always been that the only access to it was two tiny doors.
Not only was it hard to reach things not directly in front of the doors, but it was really dark in there, and there were no lights at all.
In the long term we'll be having all the walls removed and replaced with normal drywall. But for now we had a few hours to blow so we decided to see what we could do about this closet.
Since all we wanted was better access, we decided to just cut the wall out from between the doors and then extend that whole another foot or so on both sides. First we tore off all the trim and then used a circular saw to cut the new giant hole in the wall. Then, we took the trim pieces we had demo'd and used them to trim up the new hole.
Overall the final result looks much better then I'd hoped. Suprisingly, it took less than four hours total, including cleanup!
Thursday, August 5, 2010
Globally Trimming Strings in Struts2
An application I'm working on has a lot of data being passed from the client to the server. In past applications, we've always been cleaning up this data manually, one property at a time - sometimes in the save method, but more likely in the setter:
public void setFirstName(String firstName)
{
this.firstName = (firstName != null ? firstName.trim() : null);
}
Of course you could globalize this a touch:
public void setFirstName(String firstName)
{
this.firstName = StringUtils.nullSafeTrim(firstName);
}
Well, with the volume of properties in the system we didn't want to handle this every time. So, I found a neat little thing you can do with Struts2. There are classes in Struts2 which convert the request parameters into the type of the property on the bean.
Of course, everything except files come over the wire as text, so in reality converting to a String is as simple as unpacking it out of the array that is handed to you from the servlet container. But, in our case, we want to do a quick trim on the value before Struts2 hands it to the action. To do this you need to:
- Create a new class to do the conversion.
- Tell Struts2 to use this class to do the conversion.
Pretty simple, right?
Your new type conversion class needs to extend org.apache.struts2.util.DefaultTypeConverter, which is an abstract class. Here's what I came up with (I omitted a lot of unimportant code):
public class TrimmingStringConverter extends StrutsTypeConverter
{
@Override
public Object convertFromString(Map context, String[] values, Class toClass)
{
if (values != null && values.length > 0)
{
return values[0].trim();
}
return null;
}
@Override
public String convertToString(Map context, Object o)
{
if (o != null)
{
return o.toString();
}
else
{
return null;
}
}
@Override
public Object convertValue(Map context, Object o, Class toClass)
{
if (o == null)
{
return null;
}
else if (toClass == java.lang.String.class)
{
if (o instanceof String[])
{
String[] os = (String[]) o;
if (os.length > 0)
{
return os[0].trim();
}
}
return o.toString().trim();
}
return super.convertValue(context, o, toClass);
}
}
The convertValue() method is implemented in the parent, so you don't have to override it. However, this seems to be the method called when I was testing, so it's important that you do.
Next up, you need to tell Struts2 about your shiny new code. It's as simple as adding a new properties file to your classpath called xwork-conversion.properties. In that file you should add:
java.lang.String = path.to.your.TrimmingStringConverter
My quick testing showed that every single String that came in from user input was trimmed up.
If anyone knows of a better way, or improvements I can make, leave a comment.
Tuesday, May 11, 2010
Google Apps Engine
Very interesting stuff. It looks like they give you a somewhat crippled Servlet container, plus access to their database called Big Table, an asynchronous task list, cron, and a bunch of admin tools. Of course, there's an Eclipse plugin for the SDK.
I'm not sure I'd want to build a really big system on it, but if you want to get an app out the door, boy this would be a nice solution.
There's an Android app I've always wanted to write which would require a server-side to sync data, and this would be the perfect solution.
I'll post more on it, when I get around to trying it out a little.
Monday, May 3, 2010
Twins Game
Wow, what a huge improvement over watching the Twins in the Metrodome.
We had pretty decent seats, fourth row, left field.
My initial thoughts? First, the stadium itself is really beautiful. It felt surprisingly intimate considering how many people were there. My main complaints involve the concessions. They were out of a lot of things, which seemed weird to me. Plus - personal gripe here - they didn't have onions for my hotdog, which is criminal! Rachel's hotdog was cold - a slightly more forgivable gaff.
Anyway, we'll probably see a couple more games this year since it's so close to home. I'm looking forward to seeing a game when it's sunny and warm out.
Sunday, May 2, 2010
Sunday Project: Herb Garden
But not this year. This year I have my own house, which means my own little plot of land I can till under and grow things for real. Unfortunately for this little project, I have a perfectly manicured back yard which was designed by some backyard designer and has everything in it's right place. Seriously, there's barely a few feet of unused space. Also, I really want to keep this project cheep. I'm putting a $100 ceiling on it, just because it's a round number.
After staring at every corner of my backyard and purposely not asking the wife, I found my spot. Four feet by four feet, mostly sunny but with a shady corner. Right now it's in the middle of a wood chipped area, so I'll have to do a raised garden.
Apparently Home Depot has a couple 4x4 raised garden kits, so I went there to take a look. I ended up buying the cheapest one, because I'm on a budget and I figured this was a two-year experiment, so I don't need something that will last forever. The kit was $40. It's 4'x4'x6", which means I'll need 8 cubic feet to fill it. I have a ton of old pots full of dirt in my shed, and a half-bag of potting soil from years ago. So, I bought 3 cubic feet of top soil ($8) and 2 cubic feet of garden soil ($6). I also bought 3 cilantro plants, 1 basil plant, 1 hot pepper plant, 1 thyme plant, 1 dill plant, 1 parsley plant, and 1 rosemary plant ($33).
Step 1: put together the raised garden kit. This was a piece of cake. 24 screws into pre-drilled holes and bam, done!
I raked the wood chips back from the spot I was putting the garden, and used a level to get the frame set up.
Then, add the "good" dirt, and all the crappy dirt I had laying around. Fifteen minutes of tilling it, and I'm ready to plant.
I arranged the plants by how often I expect to use them, and how much sun each area should get.
And, once planted, it looks pretty good.
All in all, it took me about three hours (including the shopping) and $93 to put a herb garden in my back yard. Of course, I still have $7 left in my budget, and room for at least 7 more plants, so I'm sure I'll add to this before too long.
