Archive for category Code
iPhone, Gmail, and Exchange sync nirvana
For the past year or so I’ve been syncing my iPhone exclusively with Gmail for email, calendar, and contacts. I finally decided it would be nice to have a full sync of my work email and calendar from the corporate exchange server, but did not want to lose the ability to access my contacts in Gmail, which also serves as my primary repository for phone numbers on the iPhone and contacts in Google Talk. I also did not want to manage those contacts through Outlook going forward.
After researching a couple of options I finally landed on a great setup using gSyncit, which is $14.99 but well worth the price for the hassle it eliminates. The trial version is fully capable of syncing one entire calendar and up to 20 contacts which is sufficient to verify that it will meet your needs. gSyncit runs as an Outlook plugin, so it will definitely be most useful on a machine that is constantly – or at least frequently – connected to the the internet. Since I have a desktop at work that remains on with Outlook always open, I installed it there.
The number of options you can configure and tweak are impressive, but for my needs I simply set up two profiles, one for syncing calendar (with Outlook as my primary), the other for contacts (with Gmail as my primary), and set it to automatically sync every hour. The default sync range of 365 days in both directions was a little slow for my calendar so I changed it to only grab 30 days prior and 365 days in the future, which easily synced my calendar and several hundred contacts in under a minute.
I did back up my contacts and calendar first in case anything went wrong (and would recommend you do the same!), but surprisingly on first sync it correctly reconciled everything in both places, no duplicates, and most importantly no corruption of the web of recurring meetings, exceptions, live meeting info, etc. that fill my corporate calendar in Outlook. It’s one of the most error-free two-way calendar syncs with Outlook I’ve ever seen. On the contact side, I was also impressed that it brought over all of the fields correctly (even pictures) from Gmail into Outlook.
Finally, with my exchange account and Gmail happily in sync I converted my iPhone to sync exclusively with exchange. This consisted of simply deleting the Gmail exchange account on the iPhone and then configuring one for my corporate exchange server. Afterwards, I did re-add an email-only account for Gmail so that my iPhone can still pull personal email directly.
The final result is that my iPhone is continuously synced in both directions with my corporate exchange server (via push) for work email, calendar, and contacts, and with Gmail for my personal email. In addition, those contacts and calendar are synced periodically (currently every hour) with Gmail so that I can continue using that as my master contact repository. Note that gSyncit allows syncing as often as every 5 minutes but I didn’t find this necessary since I change contact information infrequently, and if it’s an urgent change I’m probably making it directly on my phone anyway rather than through Gmail.
Definitely give gSyncit a shot if you’re looking for a painless way to keep an Outlook calendar and contacts in sync with Gmail so that you can sync your phone exclusively with the exchange account!
Paper storage
It’s good to know that when longevity matters, there’s a paper storage solution still alive and kicking! Thanks to Olly for this hilarious project.
GXT 2.0 final fails
It’s been four months since I first wrote about my experience starting to use GXT and freshly diving into a 2.0-M1 upgrade. Since then my project has upgraded to 2.0-M2, 2.0-M3, RC1, RC2, and finally 2.0 GA, with even a couple svn trunk builds in between for good measure. In fact after M2 I stopped writing about because it was just more of the same messy, things-don’t-work-like-they-used-to-or-at-all-and-worse-are-different-in-every-browser shananegians every time. I kept hoping that our experience was simply an artifact of so many changes in 2.0, their dev team being clearly overwhelmed, and would still converge on some form of synergistic vision by the final release. I was sadly mistaken.
GXT fails, and this will be the last time I bother to comment on it unless it spontaneously improves before I stop using/thinking about it entirely. My project is removing it where possible, minimizing its use when necessary, and hoping to leave it in the dust by way of GWT 2.0 and incubator advancements over time.
Some examples of the types of issues still present (albeit changing flavors regularly) in GXT 2.0 final are:
- Component and/or layouts only render correctly – or at all – when wrapped in a specific type of parent component that otherwise has no bearing on its functionality
- Many components, including the really visible ones like Grid, render differently in each browser, or sometimes not at all (especially in Chrome)
- Components behave in wildy different ways when aspects of their state such as hidden/visible or enabled/disabled are set prior to render, during render, or after render, e.g. calling hide() before something is displayed causes it to appear malformed and non-functional rather than being hidden
- Tooltips – and popups in general – don’t display, display in random locations, refuse to hide, or render incorrectly when re-used; in fact unconstrained use of “new” keyword any time you need to display something has become a necessary anti-pattern on my team to get things to render correctly
- Funny, but sad, breaking API changes like removing Window.close(), with explanations like “because it never worked like you’d expect it to so you never should have used it anyway”
- Arbitrary (accidental?) functionality tweaks like changing which item is selected by default when you open a new combo box or when which actions on a check box (blur, click, etc.) actually fire the change event; these are superb at breaking UI tests
- Heavy-handed style approaches (think programatically setting element.style from a private method) that make customization difficult
- Continued prevalence of heavy BeanModel-based models and stores and expensive run-time massaging of data; someone should really teach them about generators
- No visible effort to take advantage of, or at last synchronize with, up and coming GWT best practices like MVP, dependency injection, command pattern, and compile-time optimization rather than run-time inflation
- Many things… are still… so slow; forcing your user to choose between waiting while a component spins in IE 7 vs. having it load lightning fast but not work correctly in Safari or Chrome is so web 1.0
I’ve heard that GXT 2.0.1 is just around the corner with “many fixes”. Right.
Stacking GWT 1.6 workers with ant parallel for super-fast builds
Having just built a new machine around a Core i7 950 enthusiastically overclocked to 4.2gz, I couldn’t help but explore the possibilities of a lightning-fast GWT compile. I regularly build a project that involves a core services war that’s pure Java along with a GWT 1.6 war consisting of two modules that requires 3 permutations each, all wrapped into an ear at the end.
Historically this took about 3 minutes running serially on a reasonable Core 2 Duo. It would run the core services war build, then the GWT build one module at a time, each using GWT 1.6′s -localWorkers 2 to at least make use of both cores.
The potential of 8 concurrent threads across the i7′s four cores and the presence of two GWT modules plus another build compelled me to resurect some old-school Ant parallelization to stack as much work as possible during the build. With a bit of tweaking it’s easy to have ant running multiple targets – some GWT and some non-GWT – at the same time, so that entire modules, not just permutations, are built in parallel. For example, something like
<target name="gwt"> <java classname="com.google.gwt.dev.Compiler" fork="true" failonerror="false"> <arg value="module1" /> <arg value="-localWorkers" /> <arg value="1" /> </java> <java classname="com.google.gwt.dev.Compiler" fork="true" failonerror="false"> <arg value="module2" /> <arg value="-localWorkers" /> <arg value="1" /> </java> </target>
becomes
<target name="gwt"> <parallel threadsperprocessor="1"> <java classname="com.google.gwt.dev.Compiler" fork="true" failonerror="false"> <arg value="module1" /> <arg value="-localWorkers" /> <arg value="4" /> </java> <java classname="com.google.gwt.dev.Compiler" fork="true" failonerror="false"> <arg value="module2" /> <arg value="-localWorkers" /> <arg value="4" /> </java> </parallel> </target>
The result was phenomenal. My 3 minute build now takes only 40 seconds! If you have lots of cores available be sure to consider stacking ant parallel with GWT workers for a big improvement. Keep in mind that running many modules in parallel may also require ridiculous amounts of memory (around 600mb per module in my case), but on an i7 system you should have at least 6gb anyway right?
Spring4gwt, or Spring’s harmony for GWT
I’ve had an idea itching at me for awhile now, which started shortly after building a complex enterprise application using GWT connected to Spring services on the server. There are countless blogs out there describing various ways to wire up Spring with GWT, and Google’s own Gin is quite adequate for client-only dependency injection. But what I’d really like is something that ties this all together, and in the true spirit of GWT, makes it easy for a seasoned Java developer to apply proven, consistent DI practices in both the client and server using the Spring knowledge they likely already have.
My vision is basically this:
@Component
public class SomeGWTComponent {
// Some other client-side component
@Autowired
private MyWidget widget;
// A remote service proxy to a server-side Spring service
@Autowired
private MyService service;
public void doSomething() {
widget.doClientStuff();
...
service.doServerStuff("data", new AsyncCallback<String>() {
public void onFailure(Throwable caught) {
...
}
public void onSuccess(String result) {
...
}
});
}
}
}
It’s important that MyService is a vanilla Spring service on the server – no extension of RemoteServlet required – and that MyWidget is any other GWT component. Injection should occur when the component is created, potentially with varying scopes just like on the server, and potentially also with @PostConstruct support for code to be executed after injection, leaving the constructor available for any pre-injection initialization. And finally, as much work as possible should be done during GWT compile minimize the run-time cost.
The approaches to GWT lookup/injection I’ve seen out there have at least one the following gaps:
- They’re client-only (Gin)
- They’re largely run-time, and slow (MVC helpers in component libraries like GXT)
- They involve SpringMVC or other unnecessary server-side complexity (most blog guides)
So I’m going to try to bring this altogether in one simple library with the following goals:
- Simplicity: Access Spring services from the client through a generic exporter; no service-specific mappings in web.xml, forced type hierarchy (services should be existing Spring POJO’s), or dependency on SpringMVC. In other words, when a new Spring service is added to the server it should require zero configuration changes to be accessible in the client if desired.
- Consistency: Client-side dependency injection with native Spring look and feel; freedom to inject private members, via constructor, or via getters/setters with same Spring annotations and conventions that are already familiar.
- Performance: Do all the heavy lifting with GWT generators to keep the client lean.
Behold, spring4gwt where I’ll do my best to make this a reality! The initial version captures objective #1, bringing together a generic servlet for exposing Spring services without turning each into its own RemoteServlet mapped in web.xml. Up next: accessing those services with Spring DI in the client!
TDD antipatterns
These TDD antipatterns are hilarious, and all too familar to anyone who’s done test driven development with a wide range of aptitudes on the team!
Reduce game network latency in Windows 7 or Vista
After installing Windows 7 I noticed a slight increase in network latency in several online games. It wasn’t a big deal – I’m talking 200-300ms, but this is on a connection that was reliably < 100ms in the past. Beyond the obvious settings in Windows or on your router, here’s a list of tweaks that may help quite a bit. It involves disabling Nagle’s algorithm, also commonly known as TCP no delay, which is basically an optimization of network traffic that tries to reduce overall packet volume but can cause extra latency in the connection. This should work on Windows 7 or Vista, though the same principle can probably applied to other operating systems as well.
- From a command prompt (usually in All Programs -> Accessories -> Command Prompt) run “regedit”
- Browse to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\Tcpip\Parameters\Interfaces
- Browse the items under interfaces until you find one that has an IPAddress entry matching the network interface you want to affect (typically LAN IP addresses start with 192.168 or 10.0); note that if your IP address is automatically assigned by a DHCP server you may need to look for a matching DhcpIPAddress instead of IPAddress
- Right-click on the interface and select New > DWORD (32-bit) Value, name it “TcpAckFrequency”
- Right-click the new TcpAckFrequency value and select Modify, enter “1″ (Hexadecimal radio button should be selected)
- Right-click on the interface and select New > DWORD (32-bit) Value, name it “TCPNoDelay” (note that TCP is all uppercase this time – that’s intentional)
- Right-click the new TCPNoDelay value and select Modify, enter “1″ (Hexadecimal radio button should be selected)
- Verify that both TcpAckFrequency and TCPNoDelay now show up in the adapter’s property list with types REG_DWORD and values 0×00000001
- Exit regedit and reboot (reboot is necessary for the changes to take effect!)
- Play a game and enjoy your new low ping
This decreased my ping in most games from 200-300ms to 50-60ms, which matches the latency I would see via a tracert to the game’s server.
GXT 2.0-M2 upgrade experience
Recently I shared my GWT 1.6 and GXT 2.0-M1 upgrade experience which was quite underwhelming on the GXT front. In the past week my team went ahead an upgraded to GXT 2.0-M2 to take advantage of some specific changes we’d noticed in svn.
For the most part 2.0-M2 didn’t introduce new breaking changes beyond M1. In our project, the only obvious differences were new parameters to some renderers that were easily converted. Functionally, most things seem to work like M1 as well – just a few minor tweaks here and there. However, on the performance front there seem to be some incremental improvements: one example is TreeTable, where we’ve had problems with render time growing linearly with the number of children (over 100ms/item in IE7 – that’s over a minute for a 100 item tree!). It’s still based on the legacy Table paradigm rather than their newer Grid (see some GXT notes on the difference here), but has improved to the point where we can use it for a moderately sized TreeTable and re-build/render a new TreeTable in under 10 seconds. The existence of Table vs. Grid is a good example of 2.0-M2 still exposing several different architectural approaches to components, but at least the ones being actively pursued seem to be headed in the right direction.
Other than that M2 has been a worthy upgrade from M1. I’d fully expect anyone upgrading from 1.2.x to 2.0-M2 to still experience a lot of pain, but if you’re already on M1 then it makes sense to go ahead and get all these fixes. Our M1 build was actually an svn checkout that already had a couple weeks’ worth included, and M2 is certainly a much higher quality preview than either that or the original M1 release. Moving from M1 to M2 will give you a bunch of fixes and keep you in sync with the API for a very minimal amount of effort.
The ecomony killed the SOAsaurus?!
I’ve seen a bunch of “SOA is dead” articles floating around, but you’ve gotta love the helpful diagram on this one!
However, I do agree that it would be great to never have another “what’s the best ESB?” or “WS-* vs. REST” debate again; they’re right up there with vi vs. emacs, where to put my curly braces, where we should go for lunch, and should-I-listen-to-you-or-just-shoot-myself-now?
Seriously though, why do people see things in such absolutes? There is always a new thought advancement just around the corner, and in this case I think it’s absolutely SaaS, cloud computing, and in general leveraging “the grid” to get powerful, aggregate functionality from a bunch of different (and cheaper) sources instead of building it all on one mega-architecture somewhere. Big changes in software thinking don’t come out of geek think tanks, they evolve organically out of lots of lots of little pieces. A component of this will always be Big Coporation’s IT strategy, but add to that today’s tight budgets and the abundance (and acceptance) of using the internet for “everything” and you get a clear trend towards life in the cloud.
Instead of worrying about whether [insert your favorite acronym here] is deprecated you might as well get used to change, because it isn’t going anywhere.
GXT 2.0-M1 dynamic sizing issue
Recently I commented on a rather severe change in GXT 2.0-M1 with regard to dynamic sizing via percentages not being converted to final HTML as expected with some components. For anyone else experiencing this issue, here’s my support thread which also includes a very simple example app illustrating the problem.
So far our workarounds have been:
- Explicit fixed sizes, ugly but easiest in some tricky spots (not resize-proof)
- Fixed sizes derived from parent, e.g. parent passes in its height/width minus any margins and borders (resize-proof only if parent size changes are manually propagated down)
- Add additional wrappers/children so that the problematic components delegate to, or inherit from, one that works (resize-proof only if parent size changes are manually propagated down)
- Implement “smart” post-render sizing based on actual height/width of parent (resize-proof as long as sizing methods are called on resize, most robust, probably the most invasive)
Recent Comments