Skip to content

All posts by moore - 59. page

Upgrading WordPress is shockingly easy

I was all set to write a post about my experience with the most recent BDNT, when I got distracted by an excellent post from Josh Fraser about never using captchas–excellent post well worth the read. After reading through the comments, mollom seemed like a great way to avoid captcha and comment moderation, and I decided to give it a try. However, mollom didn’t work on my ancient version of wordpress (2.0). This being a weekend I’m heading out of town, it seemed like the perfect time to upgrade my wordpress site (the backend–I hope you’ll notice that the soothing front end look and feel hasn’t changed).

I browsed through the releases list to find the oldest one with automatic upgrade functionality, and then followed the quite painless upgrade guide. From there, it was a pretty simple matter to automagically upgrade to 3.0. Shockingly easy.

Overall, it looks like there are a few snafus–the home page didn’t have a sidebar because of post content for a bit, my tagging plugin doesn’t appear to be compatible with this version of wordpress–but it looks like all the content is there. If you see any content that looks broken, and you feel charitable, please post a comment on this entry.

More on code splitting and GWT

Code splitting is one of the features of GWT that make it worth your while.  See, using GWT is really a choice–do you want to use one of the lightweight javascript libraries like jquery, with all the agility that implies, or do you want to use GWT which lets you leverage all kinds of java tools and optimizations, but saddles you with a compile cycle?

I’ve talked before about the situations that I think are good fits for GWT.  I just re-read that post and don’t feel that things have changed too much in the past 3 years, though I might argue with point 4 of that post.  Code splitting is an optimization that would be hard to do with a more normal javascript library (dojo has something like it, but it looks like you are responsible for maintaining dependencies).

I talked before about code splitting, and how it is a great fit for the widget based html enhancing GWT development that I’ve done a lot of recently.  I wanted to talk a bit more about my process for finding code to split.

With code splitting, the main goal is “never have the user download javascript that isn’t used”.

The first thing to do is run your GWT compile with the -compileReport option, as outlined here. This will show you your module code, and therefore let you focus your effort where it makes sense.

The second thing to do is to find code dependencies.  The compile report shows you that in a text format if you navigate all the way down to the class level in a class that is downloaded in the inital fragment via the “see why” link.  I had a hard time understanding those dependency lists, so I went looking for a tool to help.  After trying a number of open source dependency analyzers, I stumbled on the Class Dependency Analyzer (CDA) which is free as in beer, not as in speech.  The key difference between this tool and others was its included dependency graphs.  You should set CDA up to ignore all the google code, as well as any third party tools you have.  More documentation on CDA here.  (This is another example of leveraging java’s tool set.)

Using CDA, you can see which packages (since modules are grouped in a java package) have dependencies on others.  Packages that don’t have dependencies on any of your other packages are great candidates for code splitting, as well as packages that depend on other packages that are code split.  However, if your packages depend on utility classes, especially those that share business logic between client and server side code, that’s OK.  (This exercise can also help in general code quality.)

Now you have a number of candidate modules.  The next thing to do is dive into the code and see if these modules execute on every page.  If they do, then doing code splitting is not a win.  All you’ve done is forced GWT to make an extra network call.  If, on the other hand, this code only executes when someone clicks a button or takes some other action, then you have a great candidate for code splitting.  And if the module only executes on certain pages (perhaps using a DOM element to signal whether it should execute or not), you have a good candidate–because with splitting that code will never be download on pages where it is not used.

Now, add the following code around the candidates:

GWT.runAsync(new RunAsyncCallback() {
public void onFailure(Throwable caught) {
// handle error
}

public void onSuccess() {
// do something
}
}

I actually added this code block to my eclipse templates ( more on templates here) so it is super easy to set up a split point.  Note that I haven’t found a generic good action to take on failure.  For most widgets providing enhanced functionality, a safe fallback might be to just let the HTML execute.  A custom message display might be ignored, and using Window.alert can confuse your users (and lock up a browser for a time if all of your code or the network suddenly becomes unavailable).

The next step is to run the compile report again and see if the GWT compiler agrees with you that your candidate code is not reachable by any other path.  If it does, you should see split points show up underneath the permutations menu.  (BTW, the -compileReport flag easily doubles or triples the time it takes to compile GWT–I’d recommend focusing on one user-agent and doing other things to speed up your compile, as outlined here.)  You can also test this by just compiling your GWT without the -compileReport switch and looking under the deferredjs directory; it is quicker but doesn’t help you determine which modules are being downloaded.  Firebug also lets you see the files downloaded on demand.

I was able to decrease the initial download size of a project I’m working on by 20%.

I’ve mentioned the caveats before but they are worth mentioning again.

  • The XS linker is not supported, so if any of your XS modules depend on a module which has code splitting, you’ll find out when your GWT does not compile.  However, there is hope–code splitting support for the XS linker is apparently coming with GWT 2.1.  If you need this functionality, vote for the bug.  There are some work arounds in the meantime, but they involve a fair bit of hoop jumping so I’m going to avoid documenting them.
  • Events that happen before code is asynchronously downloaded are not propagated to that code.

Given the second issue, it’s important to test your code and make sure that the behavior is unchanged.  That’s the final step.

I hope this was a useful tour of the GWT code splitting process.

When is a Boolean != to a boolean

Among other times, when you’re passing it into a JSNI method in GWT.  From the docs, only a java boolean is translated into “JavaScript boolean value, as in var b = true;”  A Boolean is, like any other Java object, an “opaque value accessible through special syntax”.

Piwik now has goals

About a year ago, I wrote about piwik, a replacement for javascript based analytics tools like Google Analytics.  I installed it on a couple of my sites, and have been watching it progress with regular updates.  As of the latest version (0.6.3), they now have goals!  To me, that is one of the key features of any analytics tool.  Now you can have the analysis and not have to share it with anyone else (though you do have to update and maintain the software yourself, unless you use a site like My Free Web Stats).

After enabling the goal plugin, I set up a quick goal to track commenting on my blog (or at least if someone clicks the submit button on the comment form).  The basic documentation on goal tracking doesn’t discuss how to do this, though it does cover url based tracking pretty well.  A quick search turned up this page, which explains how to write the javascript to track a goal manually (which I then placed in an onclick handler).  This bug post on goal tracking via links may be useful too.

I’m happy to see a well done open source alternative to analytics tools that lets you control your data.  Piwik probably won’t be of interest to many people (most will just drop in Google Analytics and call it good), but for a few may be indispensible.  And support for goals is a key part of the maturation of this project.

[tags]piwik,goals,opensource,analytics[/tags]

Using JSP as a templating language for GWT

I wanted to share a solution to a problem a client of mine had–needing the same (or very similar) content in two places–in a lightbox, managed by GWT, and in an HTML page.  The content itself had GWT widgets inside it (that would need to be functional in both places).

The solution was to expose the HTML content as a JSONP file for GWT consumption (and just have the HTML displayed for the HTML page).  To do this,

  • we build the HTML page (in this case, using JSTL and JSP, but any other HTML view technology would work).
  • then we build code that retrieves the page (I used HttpClient)
  • and encodes the entire HTML content as an attribute of a json object (I used json-simple)
  • and exposes it to the world via a URL

Now that we have the content as JSON encoded HTML, we need to consume it:

  • first, create a JSONP consumer, as outlined here
  • then, when you get the content, pull it into an HTMLPanel, not just a HTML widget
  • create new instances of your GWT widgets and attach them to your known span ids using the HTMLPanel.add() method.
  • if your content depends on external css files, you’ll need to add and remove them via JSNI when the lightbox is shown (if you can’t integrate the CSS into the existing site)
  • if your lightbox and html content differ slightly, you can hide or show spans via your server side presentation layer to configure your in lightbox widgets

Benefits

  • One location for display–one place to make changes
  • No layout in GWT–everything happens in HTML
  • Cross domain–since the content is exposed via JSONP, it can be consumed by javascript on any domain.

Detriments

  • Security–you’re exposing yourself to some possible security issues, though since you control both the endpoints, they shouldn’t be too bad.  Read this excellent document carefully to understand the implications.
  • Complexity–lots of moving pieces
  • Caching–JSONP calls are cached by the browser, and a control refresh doesn’t seem to refresh them.  I end up clearing my cache a lot when debugging.
  • Two calls to the server for every lightbox shown.
  • Not sure if it would work in developer mode–possibly with an external server.  Haven’t tried this.

I haven’t played around with any of the GWT templating solutions, but I don’t believe they would work in this case, because of the need for a plain, crawlable HTML page.

Two books of interest to freelancers

I recently read two finance books that might be of interest to freelancers.

The first is The Money Book For Freelancers, Part-Timers, and the Self-Employed by Joseph D’Agnese and Denise Kiernan.  I was pleasantly surprised to see a finance book aimed directly at people with sporadic income.  This book is written in an easy going style, with examples drawn from the author’s lives, as well as those of their friends.

The major takeaway is that you should pay yourself first–when a check comes in, allocate a percentage for taxes, a percentage for retirement, and a percentage for an emergency fund.  Do that first, so you aren’t even tempted to spend it.  I do this because of my corporate structure and SIMPLE IRA, but if you’re a new freelancer, or someone who is a schedule C worker, then it’s great advice.

Then, after a while, when you’re comfortable with the system, you can start to save for other goals.  One of the strongest parts of the book was when they encouraged you to sit down and write out your particular financial goals.  It’s tough to do, because when you do so, then you’re confronted with the hard work of trying to achieve them, but it’s great advice.

While this book was full of tips for dealing with the income side, I felt like the outgo side was covered as well.  They had advice about breaking up your expenses into required (taxes, retirement, emergency), overhead (rent/mortgage, food, insurance), and variable (eating out, classes).  Once you know your overhead and required expenses, if you get a windfall (that big client finally paid!) you can siphon that off into a separate account and use that for future months of expenses.  The authors also did a good job talking nuts and bolts, going down to the details of what type of bank accounts you need.

They didn’t really cover some things that are on the periphery of financial concerns–corporate structure, handling employees and contractors and types of insurance, for instance.  But doing so would probably have distracted from the main point of the book, so I understand.

If you’re a freelancer, and this strategy doesn’t work for you, you probably want to check this book out.

I also read Are you a Stock or a Bond by Moshe A. Milevsky.  This book is a fascinating look at the best way for modern savers with 401(k)s and IRAs to replicate what the WWII generation had–a pension.

The hook of the book is that savers should consider their lifetime earning potential and job prospects when planning a retirement asset allocation strategy.  Those who are in a more stable job (the author uses himself as an example–a tenured professor) should consider their earnings more bond-like and thus invest more in stocks (to the point of borrowing to buy stocks).  Those in a more tenuous job (farmer? I don’t remember his example) should do the opposite.

The hook, while thought provoking, is not really the focus of the book.  In fact, I was a bit disappointed that he didn’t spend more time telling you how to determine if your income stream was more stock like or more bond like.  Instead, he charges off into what you should do with your accumulated savings when you retire.

The short answer–buy an annuity.  The reason for this is that the guaranteed income from an annuity is impossible to replicate from the same amount of capital invested individually.  Why?  Because an annuity spreads payments across a population in which some will die before others.  Annuities essentially transfer wealth from those who die early to those who die later.  This asset class reduces your greatest financial risk at retirement–running out of money.  Just like a pension.

Definitely a thought provoking book, and one that would be especially useful to people approaching retirement.

Boulder Startup Week

Come find a job in Boulder May 4 – 8, or at least enjoy the startup scene.

The startups in town are rolling out the red carpet (not really, I don’t think there is one in town) but figuratively, for you, talented developer, designer, UI, manager or startup enthusiast, to come for a visit.  There are a ton of jobs for developers, marketers, designers and managers (and we need more talent in town!).

Could be the best event highlighting the tech + fun sides of Boulder since BocoPositive press here.
[tags]startups, boulder, events[/tags]

Malware Removal Guide

I had an issue last week with my Windows PC, which is currently running Windows XPSP3.  Mac users, you can stop reading right now.

Midafternoon one day, I started receiving errors when I would try to open certain executables by clicking on their icons (on the desktop, the start menu, in explorer).  The error message was “The specified path does not exist” followed by the pathname of the executable.  When I opened the file manager and browsed to that path, sure enough, the file was there.  In addition, when I shut my computer down, I was seeing the 0xc000012 error message.
There were some really weird things about this behavior.  First of all, it affected some executables (like notepad and all my browsers) but not others (like yahoo messenger).  Second, starting up the executables from the command line worked, as did starting them up by another program (as in, one of the programs which started up fine had a ‘check for updates’ option, which started FireFox just fine).  Also, I could start any program by right clicking on it and ‘running as’ a different user.  Finally, in safe mode, everything worked fine, which indicated, thankfully, that I didn’t have a hardware problem, and also gave me a chance to do a backup of everything, Just In Case.
I won’t walk you through all the links I found via google, or explain my frustration, or talk about the tools I used to try to fix the issue.  I’m just going to tell you what worked for me.  I finally stumbled on this fantastic malware and spyware removal guide from Geeks To Go.  I printed it out, downloaded all the tools, and followed the directions faithfully.  And now I’m up and running.

This was my first spyware infection in the 7 years I’ve been running Windows XP.  I hope to go another 7 years, but if I don’t, I now know where to turn to first.

[tags]malware removal,spyware removal[/tags]