tag:blogger.com,1999:blog-30763202459884038352024-02-07T02:18:58.705-08:00ArrayLust - My geek sideGeneral tech stuff that would bore my wife, so I waffle randomly to the web at large instead.ArrayLusthttp://www.blogger.com/profile/08447702133255815841noreply@blogger.comBlogger12125tag:blogger.com,1999:blog-3076320245988403835.post-27905079870559006912013-05-23T08:17:00.001-07:002013-05-23T08:17:09.123-07:00My first Node.js applicationFor a long, long time now, I've been thinking about a personal project to do with weather predictions, using <a href="http://www.metoffice.gov.uk/datapoint">Met Office data</a>. I finally got round to starting it last night, using Node.js.<br />
<br />
I'd originally thought up the concept because my wife is constantly checking the weather. I can understand this; in the UK, the weather seems to be appalling and unpredictable most of the time. It occurred to me that she was always checking the prediction for a point in time (e.g. the weekend), but that the prediction changes as we approach that point in time, as the Met Office revises their data.<br />
<br />
Now, you can get hold of prediction data, but you need to store it and process it. Getting it into a database is the first priority, and since there is a lot of it, the process needs to be quick and scalable. I've been using MongoDB for a couple of years, and I can definitely say I've become a fan. It's not without challenges though. One of these is that it hogs quite a lot of memory and the other is that it requires quite a lot of disk space. I guess this is because the documents are not stored in quite such an optimal manner as in a SQL database. Then I came across <a href="https://www.digitalocean.com/">Digital Ocean</a>, who offer really cheap servers that are easy to scale - much cheaper and easier to scale than Amazon's EC2, I have to say.<br />
<br />
I was originally going to write the app in Java and host it somewhere, but it's given me an opportunity to use Node.js. I've been using Javascript a lot over the past few years, and I'm quite familiar with the MongoDB shell, so I thought I'd give it a go.<br />
<br />
From starting to look at the docs to getting a working app running on the server, downloading, parsing and inserting data into MongoDB? Three hours. I think that's a bit of a result.<br />
<br />
From 5000 or so locations across the UK, I harvested 200,000 predictions for 3-hour markers over the next 5 days. For all subsequent predictions, I'll append the forecast to an array, giving me all the predictions for a point in time and space in a single handy doc. Each doc looks like this for a single prediction:<br />
<br />
<code>
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;">> db.forecasts.findOne();</span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;">{</span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span>"loc" : "3220",</span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span>"fcD" : ISODate("2013-05-27T00:00:00Z"),</span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span>"t" : "360",</span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span>"d" : [</span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span>{</span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span>"D" : "NW",</span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span>"F" : "2",</span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span>"G" : "20",</span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span>"H" : "78",</span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span>"Pp" : "6",</span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span>"S" : "11",</span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span>"T" : "5",</span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span>"V" : "EX",</span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span>"W" : "7",</span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span>"U" : "1",</span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span>"pd" : ISODate("2013-05-23T11:00:00Z")</span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span>}</span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span>],</span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"><span class="Apple-tab-span" style="white-space: pre;"> </span>"_id" : ObjectId("519e077c8bf02215220014f5")</span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;">}</span></code>
<br />
<br />
The loc field is the location ID - location information is stored in a separate collection. fcD is the forecast date - the date that they expect to have this weather. t: 360 means 360 minutes into the day. In the prediction data, 'pd' means 'prediction date' - They predicted at 11am today that the weather would have these characteristics. All other fields are stats like temperature, humidity, etc.<br />
<br />
That's all the app does right now, but the next step once I've harvested some data is to start analysing it. Some things I have in mind:<br />
<br />
<ol>
<li>What is the average delta between first and last predictions for a point in time?</li>
<li>Graph predictions over time for a point in time. i.e. how much do the predictions vary about temperature, humidity etc. from the first to the last prediction?</li>
<li>How do different weather stations compare? Are some more accurate than others? This might be regional or down to equipment or personnel at a particular site.</li>
</ol>
<div>
There is also other data - what actually happened. It'd be nice to compare this across months in a <a href="http://circos.ca/">Circos</a> style graph. Linking each temperature to months that had days with the same max or min temperature.</div>
<div>
<br /></div>
<div>
I plan to use <a href="http://d3js.org/">D3.js </a>for graphing. I've used it a little before. It's the kind of Javascript library that makes you change your way of coding. It certainly helped me pick up Node.js quickly.</div>
ArrayLusthttp://www.blogger.com/profile/08447702133255815841noreply@blogger.com0tag:blogger.com,1999:blog-3076320245988403835.post-55020509860032835682012-05-23T05:34:00.001-07:002012-05-23T05:35:45.484-07:00StackOverflow, meet Raspberry PiLike many people (in the hundreds of thousands, so I understand), I'm waiting for a Raspberry Pi. <br />
<br />
As an avid StackOverflow user, I'm very much interested in promoting a new beta site they're proposing, whcih will be dedicated to the Pi. StackOverflow's model promotes participation and moreover, promotes correct answers, and I find I'm using it more and more, searching for answers, asking questions and trying to help others. <br />
<br />
If you're awaiting a Pi like me, take a look, cast a vote:<br />
<br />
<a href="http://area51.stackexchange.com/proposals/37041/raspberry-pi?referrer=tOZWCbBPmk3dMlwCbl6l_Q2"><img alt="Stack Exchange Q&A site proposal: Raspberry Pi" height="250" src="http://area51.stackexchange.com/ads/proposal/37041.png" width="220" /></a>
<br />
<br />ArrayLusthttp://www.blogger.com/profile/08447702133255815841noreply@blogger.com0tag:blogger.com,1999:blog-3076320245988403835.post-68255211967596196822011-10-14T06:54:00.000-07:002011-10-14T07:00:24.749-07:00Awesome JQuery from Ubuntu<div style="text-align: left;">Ubuntu 11.1 has an online demo, which is made up from a load of Javascript, but looks like a real UI. The virtual Firefox app has history states and lets you open other websites - including the demo site...</div><div><br /></div><div>It's an awesome bit of coding with massive potential. They're not far away from making a web based UI layer that would allow users to manage virtual servers over port 80...</div><div><br /></div><div><a href="http://www.ubuntu.com/tour/#">http://www.ubuntu.com/tour/#</a></div><div><br /></div><div><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiLs2urK2qlI7pT5NeeRJ_jFBy-UN-3HO_2I5GHn-MoydEHn1LmjjH4Bgx3j8NONORLihZkGAPCSAYDgqOJ0l9aHLqb0BYvGTH_sHz5HH_t-C62-8pdjgvIFukjH53V5flYCIogDXhaSGI/s1600/ubuntu11.1.jpg" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}"><img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiLs2urK2qlI7pT5NeeRJ_jFBy-UN-3HO_2I5GHn-MoydEHn1LmjjH4Bgx3j8NONORLihZkGAPCSAYDgqOJ0l9aHLqb0BYvGTH_sHz5HH_t-C62-8pdjgvIFukjH53V5flYCIogDXhaSGI/s400/ubuntu11.1.jpg" border="0" alt="" id="BLOGGER_PHOTO_ID_5663347319362059202" style="display: block; margin-top: 0px; margin-right: auto; margin-bottom: 10px; margin-left: auto; text-align: center; cursor: pointer; width: 400px; height: 235px; " /></a></div><div><br /></div><div><br /></div>ArrayLusthttp://www.blogger.com/profile/08447702133255815841noreply@blogger.com0tag:blogger.com,1999:blog-3076320245988403835.post-62833853549941237152011-08-09T06:45:00.000-07:002011-08-09T09:12:12.172-07:00My experiences with JMeter and PeopleSoftOver the past few months, I've carried out more performance testing than I'd have chosen to, mostly against PeopleSoft in different environments. There are a number of sites that gave me useful tips to get through the process, and I thought I'd share them here.
<br />
<br />It's also useful to know what breaks :)
<br />
<br /><div><b><span class="Apple-style-span" >About JMeter</span></b>
<br /><div>
<br />JMeter is an extensible Java based tool to conduct various different types of testing, including functional, regression, load, soak and stress testing. Tests are controlled either from a graphical user interface or from the command line, and the ‘master’ host can control several ‘injectors’.
<br />
<br />JMeter is an open source package from the Apache Software Foundation. For this project, it carries several advantages:
<br />
<br />1. It carries no license fee
<br />2. It can be extended
<br />3. It has a fairly simple user interface
<br />4. It supports multiple test injectors, required to push the system to its limits
<br />
<br />JMeter is not a perfect tool, and has some disadvantages too, such as a slightly buggy user interface and slightly sparse reporting capabilities. Despite this, it is the best of the crop of open sourced options. Utilizing third party plugins can mitigate the sparse reporting.
<br />
<br />My PeopleSoft test plans generally follow this structure:
<br /></div><div>
<br /></div><div><img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 245px; height: 400px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj7-4rVNYDHMiqWgSczAoRJQdh824ULR_lbBgdBOuEMd_QqpBsbVmA0kLSxByB017sYeLh-pGozkuPGg8G33TSXiGW86PKe2ZlFcLW3WkrijFtuIjToXPIxjqPXtOOOrfcQ9-7aEBH5tbQ/s400/peoplesofttestplan.png" border="0" alt="" id="BLOGGER_PHOTO_ID_5638854183968135298" />
<br />Basically, this test will just perform a login. It includes a bunch of required elements for any PeopleSoft test - it extracts a session variable using a regular expression, ICSID, which you can use in other test elements further down, it includes a cookie manager (set to 'compatibility mode' - default setting will not work), and it includes a sampler to 'grab test data' - this accesses a simple web service I wrote that provides a row of test data in XML format - this adds next to no additional time to the test, but is really useful because when testing using multiple test injectors, it means that I don't need to copy data across to each server.</div><div>
<br /></div><div>Recording the test is reasonably straightforward, but there are some gotchas. Firstly, you want to add an HTTP proxy element to the 'workspace' element, and set that up to use HTTP Client for the HTTP samplers. You also want to add some variables to a config element, including the PeopleSoft environment name, host, port, and protocol. For example:</div><div>
<br /></div><div>1) PsEnv=DMO</div><div>2) host=localhost</div><div>3) port=80</div><div>4) protocol=http</div><div>
<br /></div><div>If you do this, then when the proxy is recording test elements, it'll automatically replace DMO with ${PsEnv}, etc., saving an awful lot of time processing your test afterwards. You'll also find that most processes in PeopleSoft actually entail multiple GET and POST requests to the same URL. When you run your test, these will get grouped in the results. You can tell JMeter to prefix each sampler name with a counter by editing the JMeter.properties file.</div><div>
<br /></div><div>An article on how to configure the ICSID parameter is here: http://www.erpassociates.com/peoplesoft-corner-weblog/utilities/using-jmeter-for-peoplesoft-performance-testing.html</div><div>
<br /></div><div>With the ICStateNum parameter, if you leave it in your tests, you'll get the login page all the time. It seems to be OK to simply remove it from tests.</div><div>
<br /></div><div>When you're looking at results, always add a 'View Results Tree' element while you're developing the test - this will allow you to see individual HTTP requests and responses (rendered as HTML!). This is incredibly useful.</div><div>
<br /></div><div>If you decide to add 'user wait time' to your test, so you can pad out a transaction to take about as long as a real user would take, be aware of the scope of timers in JMeter. If you have a sampler followed by a timer, followed by two more samplers, then each sampler will get the same delay added. This is probably not what you want. Instead, add timers as child nodes for a sampler you want to have a delay after.</div><div>
<br /></div><div>I also found the following useful:</div><div><ul><li>http://javaworks.wordpress.com/2010/06/15/functions-in-jmeter-bean-shell/</li><li>http://www.javaworld.com/javaworld/jw-07-2005/jw-0711-jmeter.html?page=1</li><li>http://code.google.com/p/jmeter-plugins/downloads/detail?name=JMeterPlugins-0.4.1.zip</li></ul><div>Especially the last item - JMeter plugins has some very useful charts, including threads over time - if your test uses many injectors, this is a useful way to see when your test is ramped up, and if there are problems with the injectors failing.</div><div>
<br /></div><div>Finally, it's a good idea to run JConsole against your injector JVMs. This will give you a feel for how much load you can push through from a single host. In our tests, with user wait times, we found we were able to push through 800 to 1000 users (threads), each with user wait time. All this took was to tweak the JVM heap size in the jmeter.bat file, since the servers we were using as injectors each had plenty of CPU power and memory.</div><ul><li>
<br /></li></ul></div> <div>
<br /></div></div>ArrayLusthttp://www.blogger.com/profile/08447702133255815841noreply@blogger.com0tag:blogger.com,1999:blog-3076320245988403835.post-2654509387324625382010-08-26T03:32:00.000-07:002010-08-26T06:02:27.998-07:00Java just isn't being friendly todayIs it just me? Shouldn't Java app servers be more consistent?<br /><br />I'm developing a commercial web application. This app must work in a variety of application servers, on a variety of databases, with minimal configuration of the kind that doesn't require users to understand Java.<br /><br />So, I'm using Hibernate, and after a lot of faffing, have got Hibernate to work using a SequenceStyleGenerator (very nice) so it can handle different id generation schemes (sequences vs auto-increment). <br /><br />I'm also using Spring, for dependency injection, transactions, and a bunch of other things like MVC, annotations and security. Spring is very nice for all of these things, but is a bit of a pain when it comes to changing anything without opening up the WAR / EAR.<br /><br />My datasource, defined in Spring config, gets DB connections from a JNDI lookup. I define that JNDI lookup in the application server, but of course every application server exposes JNDI in a different way, so unless I want to maintain different WAR file builds for different application servers, I need a way to change the properties on startup. <br /><br />Recently, I started using Spring's PropertyPlaceholderConfigurer, which takes a properties file as an argument: in my case 'classpath:my.properties'. This allows me to externalise the properties for the key things that need to be changed, like the datasource. <br /><br /><pre><br /><bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"><br /> <property name="location"><br /> <value>classpath:my.properties</value><br /> </property><br /></bean><br /></pre><br /><br />So now my datasource bean declaration is<br /><br /><pre><br /><jee:jndi-lookup id="dataSource" name="${myDatasource}" /><br /></pre><br /><br />All well and good. In most app servers, you then just drop the properties file on the classpath. In Weblogic (on Windows in this case), however, try as I might, I just couldn't get the thing to recognise the properties file, and since the datasource is pretty central to the app, it just didn't start. It's apparently not enough to just put it in the lib directory that Weblogic happily loads JAR files from.<br /><br />The solution, which was simple, took a long time as I tried different things. It involves editing %WL_HOME%/user_projects/domains/base_domain/bin/setDomainEnv.cmd and adding the following line near the top:<br /><br />set CLASSPATH=.;%CLASSPATH%<br /><br />All this does is add the current directory to the classpath. Then, just drop the properties file into %WL_HOME%/user_projects/domains/base_domain and you're good to go.<br /><br />Next problem! JNDI woes. I'd done this before in Weblogic and thought I had it sussed, so was disappointed when it suddenly stopped. I'd created my datasource with a JNDI name of jdbc/myDS, and I was looking up that same name from my Spring config (no need to prepend java:comp/env/ in Weblogic). But it didn't work. The solution, again simple when you know, is to make sure that you don't click 'Finish' prematurely when creating the datasource, but click 'Next' straight to the final screen, where you choose the 'targets'. If you're using a default install, that target will be 'AdminServer'. Then it will work.ArrayLusthttp://www.blogger.com/profile/08447702133255815841noreply@blogger.com0tag:blogger.com,1999:blog-3076320245988403835.post-19432005786600518172009-12-09T14:37:00.000-08:002009-12-09T14:38:44.575-08:00Nice slides about negative corporate environments<div style="width:425px;text-align:left" id="__ss_2670992"><a style="font:14px Helvetica,Arial,Sans-serif;display:block;margin:12px 0 3px 0;text-decoration:underline;" href="http://www.slideshare.net/akhella/corporate-design-vs-startup-design-a-love-story" title="Corporate Design vs Startup Design - A Love Story">Corporate Design vs Startup Design - A Love Story</a><object style="margin:0px" width="425" height="355"><param name="movie" value="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=corporatedesigntostartupdesign-alovestory-091207215126-phpapp02&stripped_title=corporate-design-vs-startup-design-a-love-story" /><param name="allowFullScreen" value="true"/><param name="allowScriptAccess" value="always"/><embed src="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=corporatedesigntostartupdesign-alovestory-091207215126-phpapp02&stripped_title=corporate-design-vs-startup-design-a-love-story" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="355"></embed></object><div style="font-size:11px;font-family:tahoma,arial;height:26px;padding-top:2px;">View more <a style="text-decoration:underline;" href="http://www.slideshare.net/">presentations</a> from <a style="text-decoration:underline;" href="http://www.slideshare.net/akhella">Amir Khella</a>.</div></div>ArrayLusthttp://www.blogger.com/profile/08447702133255815841noreply@blogger.com0tag:blogger.com,1999:blog-3076320245988403835.post-33228746732552448212009-11-26T08:59:00.001-08:002009-11-26T09:04:53.082-08:00Sequences not allowed hereOK, this was just annoying, but since I couldn't find anything on the web when I looked, here's what my problem was:<br /><br />I was modifying some hibernate code to use the SequenceStyleGenerator annotation, so it will work cross-DB. I'd initially developed using MySQL, and had a MySQL hibernate dialect specified in my config files. I exported the schema to an Oracle XE instance using hbm2ddl in Eclipse, and started using an Oracle driver in my datasource. <br /><br />Every time I tried to insert anything, I got an oracle error - Sequence not allowed here. Ultimately, just removing the dialect entirely from the config files worked, since Hibernate can auto-detect the dialect most of the time.ArrayLusthttp://www.blogger.com/profile/08447702133255815841noreply@blogger.com1tag:blogger.com,1999:blog-3076320245988403835.post-38785439962933246432009-11-26T08:52:00.000-08:002009-11-26T08:58:01.170-08:00Hibernate / Spring WAR issues in Weblogic 10 - antlrI had an issue today deploying a straightforward WAR file to WLS 10. The classloader hierarchy was preventing Hibernate from using the correct version of the antlr jar that was bundled in my webapp.<br /><br />For my particular situation, the solution had to be simple. In the end, I created a new Eclipse project to bundle the WAR into an EAR, and then added a file called weblogic-application.xml in the META-INF folder of that EAR with the following content:<br /><br /><pre><br /><weblogic-application><br /> <prefer-application-packages><br /> <package-name>antlr.*</package-name><br /> </prefer-application-packages><br /></weblogic-application><br /></pre><br /><br />..which solves the problem.ArrayLusthttp://www.blogger.com/profile/08447702133255815841noreply@blogger.com0tag:blogger.com,1999:blog-3076320245988403835.post-16002934909530427302009-11-11T08:06:00.001-08:002009-11-11T08:06:43.918-08:00The future of computing<object width="400" height="265"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=7395079&server=vimeo.com&show_title=1&show_byline=1&show_portrait=0&color=&fullscreen=1" /><embed src="http://vimeo.com/moogaloop.swf?clip_id=7395079&server=vimeo.com&show_title=1&show_byline=1&show_portrait=0&color=&fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="400" height="265"></embed></object><p><a href="http://vimeo.com/7395079">Trillions</a> from <a href="http://vimeo.com/mayanmaya">MAYAnMAYA</a> on <a href="http://vimeo.com">Vimeo</a>.</p>ArrayLusthttp://www.blogger.com/profile/08447702133255815841noreply@blogger.com0tag:blogger.com,1999:blog-3076320245988403835.post-17884885412732254962009-10-28T12:10:00.000-07:002009-10-28T12:33:19.802-07:00UTF-8 hellLocalisation is a common requirement. So why is it so nightmarish to actually get it all working? I'm developing an app with Spring MVC and MySQL via Hibernate. You'd think that this should be quite straightforward, right? Think again. I've not got time to lay this all out nicely (as usual), but here's a quick list of things you need to do:<br /><br /><ol><li>First, make sure your tables are created with UTF-8 encoding. e.g.<br /><pre>CREATE TABLE `aTable` (<br />`id` int(11) NOT NULL AUTO_INCREMENT,<br />`name` varchar(100) DEFAULT NULL,<br />`value` varchar(255) DEFAULT NULL,<br />`category` varchar(45) DEFAULT NULL,<br />`description` text,<br />PRIMARY KEY (`id`),<br />UNIQUE KEY `ind_setting_key` (`name`)<br />) ENGINE=InnoDB DEFAULT CHARSET=utf8</pre></li><li>Ensure your web pages are served as UTF-8<br /><pre id="line1"><<span class="start-tag">meta</span><span class="attribute-name"> http-equiv</span>=<span class="attribute-value">"Content-Type" </span><span class="attribute-name">content</span>=<span class="attribute-value">"text/html;<br />charset=UTF-8" </span><span class="error"><span class="attribute-name">/</span></span>></pre></li><li>Set content type in JSPs:<br /><pre><%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%></pre><br /></li><li>Add servlet filter to web.xml to set character encoding of request:<br /><pre> <filter><br /> <filter-name>charsetFilter</filter-name><br /> <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class><br /> <init-param><br /> <param-name>encoding</param-name><br /> <param-value>UTF-8</param-value><br /> </init-param><br /> </filter><br /><br /> <filter-mapping><br /> <filter-name>charsetFilter</filter-name><br /> <url-pattern>/*</url-pattern><br /> </filter-mapping></pre></li><li>Ensure your forms submit UTF-8:<br /><pre id="line185"><<span class="start-tag">form</span><span class="attribute-name"> action</span>=<span class="attribute-value">"targetpage.html" </span><span class="attribute-name">method</span>=<span class="attribute-value">"post" </span><span class="attribute-name"><br />enctype</span>=<span class="attribute-value">"application/x-www-form-urlencoded" </span><span class="attribute-name">accept-charset</span>=<span class="attribute-value">"UTF-8"</span>></pre></li><li>Set JDBC connection character set:<br />jdbc:mysql://localhost:3306/db?characterEncoding=utf8</li><li>When you read from the DB, issue SET NAMES 'utf8'; or you'll see garbled characters.</li></ol>I think that's it...ArrayLusthttp://www.blogger.com/profile/08447702133255815841noreply@blogger.com0tag:blogger.com,1999:blog-3076320245988403835.post-61922971557786736482009-10-21T03:44:00.000-07:002009-10-21T04:05:41.634-07:00Edited Blogspot templateSome regular blog readers may notice that this blog has a flexible width but still has rounded corners. The template I chose was a fixed width template using images for corners, which I generally dislike, having used them in the past without too much cross-browser success.<br /><br />For this template, I make a 5-minute edit to remove the CSS for any corners and then just added a couple of JQuery includes and a few lines of Javascript:<br /><br /><pre class="textmate-source mac_classic"><span class="source source_js"><span class="keyword keyword_operator keyword_operator_js"><</span>script src<span class="keyword keyword_operator keyword_operator_js">=</span><span class="string string_quoted string_quoted_single string_quoted_single_js"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_js">'</span>http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_js">'</span></span> type<span class="keyword keyword_operator keyword_operator_js">=</span><span class="string string_quoted string_quoted_single string_quoted_single_js"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_js">'</span>text/javascript<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_js">'</span></span><span class="keyword keyword_operator keyword_operator_js">><</span>/script<span class="keyword keyword_operator keyword_operator_js">></span><br /><span class="keyword keyword_operator keyword_operator_js"><</span>script src<span class="keyword keyword_operator keyword_operator_js">=</span><span class="string string_quoted string_quoted_single string_quoted_single_js"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_js">'</span>http://malsup.com/jquery/corner/jquery.corner.js<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_js">'</span></span> type<span class="keyword keyword_operator keyword_operator_js">=</span><span class="string string_quoted string_quoted_single string_quoted_single_js"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_js">'</span>text/javascript<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_js">'</span></span><span class="keyword keyword_operator keyword_operator_js">><</span>/script<span class="keyword keyword_operator keyword_operator_js">></span><br /><span class="keyword keyword_operator keyword_operator_js"><</span>script type<span class="keyword keyword_operator keyword_operator_js">=</span><span class="string string_quoted string_quoted_single string_quoted_single_js"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_js">'</span>text/javascript<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_js">'</span></span><span class="keyword keyword_operator keyword_operator_js">></span><br /> <span class="keyword keyword_operator keyword_operator_js">$</span><span class="meta meta_brace meta_brace_round meta_brace_round_js">(</span><span class="support support_class support_class_js">document</span><span class="meta meta_brace meta_brace_round meta_brace_round_js">)</span><span class="meta meta_delimiter meta_delimiter_method meta_delimiter_method_period meta_delimiter_method_period_js">.</span>ready<span class="meta meta_brace meta_brace_round meta_brace_round_js">(</span><span class="storage storage_type storage_type_js">function</span><span class="meta meta_brace meta_brace_round meta_brace_round_js">()</span> <span class="meta meta_brace meta_brace_curly meta_brace_curly_js">{</span><br /> <span class="keyword keyword_operator keyword_operator_js">$</span><span class="meta meta_brace meta_brace_round meta_brace_round_js">(</span><span class="string string_quoted string_quoted_single string_quoted_single_js"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_js">'</span>#header-wrapper<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_js">'</span></span><span class="meta meta_brace meta_brace_round meta_brace_round_js">)</span><span class="meta meta_delimiter meta_delimiter_method meta_delimiter_method_period meta_delimiter_method_period_js">.</span>corner<span class="meta meta_brace meta_brace_round meta_brace_round_js">()</span><span class="punctuation punctuation_terminator punctuation_terminator_statement punctuation_terminator_statement_js">;</span><br /> <span class="keyword keyword_operator keyword_operator_js">$</span><span class="meta meta_brace meta_brace_round meta_brace_round_js">(</span><span class="string string_quoted string_quoted_single string_quoted_single_js"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_js">'</span>#main-wrap1<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_js">'</span></span><span class="meta meta_brace meta_brace_round meta_brace_round_js">)</span><span class="meta meta_delimiter meta_delimiter_method meta_delimiter_method_period meta_delimiter_method_period_js">.</span>corner<span class="meta meta_brace meta_brace_round meta_brace_round_js">()</span><span class="punctuation punctuation_terminator punctuation_terminator_statement punctuation_terminator_statement_js">;</span><br /> <span class="keyword keyword_operator keyword_operator_js">$</span><span class="meta meta_brace meta_brace_round meta_brace_round_js">(</span><span class="string string_quoted string_quoted_single string_quoted_single_js"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_js">'</span>#sidebartop-wrap<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_js">'</span></span><span class="meta meta_brace meta_brace_round meta_brace_round_js">)</span><span class="meta meta_delimiter meta_delimiter_method meta_delimiter_method_period meta_delimiter_method_period_js">.</span>corner<span class="meta meta_brace meta_brace_round meta_brace_round_js">()</span><span class="punctuation punctuation_terminator punctuation_terminator_statement punctuation_terminator_statement_js">;</span><br /> <span class="keyword keyword_operator keyword_operator_js">$</span><span class="meta meta_brace meta_brace_round meta_brace_round_js">(</span><span class="string string_quoted string_quoted_single string_quoted_single_js"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_js">'</span>#sidebarbottom-wrap1<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_js">'</span></span><span class="meta meta_brace meta_brace_round meta_brace_round_js">)</span><span class="meta meta_delimiter meta_delimiter_method meta_delimiter_method_period meta_delimiter_method_period_js">.</span>corner<span class="meta meta_brace meta_brace_round meta_brace_round_js">()</span><span class="punctuation punctuation_terminator punctuation_terminator_statement punctuation_terminator_statement_js">;</span><br /> <span class="keyword keyword_operator keyword_operator_js">$</span><span class="meta meta_brace meta_brace_round meta_brace_round_js">(</span><span class="string string_quoted string_quoted_single string_quoted_single_js"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_js">'</span>#footer-wrap1<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_js">'</span></span><span class="meta meta_brace meta_brace_round meta_brace_round_js">)</span><span class="meta meta_delimiter meta_delimiter_method meta_delimiter_method_period meta_delimiter_method_period_js">.</span>corner<span class="meta meta_brace meta_brace_round meta_brace_round_js">()</span><span class="punctuation punctuation_terminator punctuation_terminator_statement punctuation_terminator_statement_js">;</span><br /> <span class="meta meta_brace meta_brace_curly meta_brace_curly_js">}</span><span class="meta meta_brace meta_brace_round meta_brace_round_js">)</span><span class="punctuation punctuation_terminator punctuation_terminator_statement punctuation_terminator_statement_js">;</span><br /><span class="keyword keyword_operator keyword_operator_js"><</span>/script<span class="keyword keyword_operator keyword_operator_js">></span></span></pre><br /><br />JQuery is so cool. I could have gone further and simplifed the HTML, but I couldn't be bothered. However, I have to say, I'm a recent convert to JQuery, having tried Dojo as well. JQuery is just brilliant! I may post more on that later, since I recently created a nice little linked list mechanism, to move items from one list to another (useful for multiple item selection).ArrayLusthttp://www.blogger.com/profile/08447702133255815841noreply@blogger.com0tag:blogger.com,1999:blog-3076320245988403835.post-3589499881426743922009-10-21T03:13:00.000-07:002009-10-21T03:18:50.794-07:00TyposOK, so maybe it's just me, but I keep typing new ArrayLust(); instead of ArrayList(). It's an honest mistake, but I thought it was a moderately cool name for a blog, and I fancied blogging again. It's been a while since I last blogged (http://nanoitx.blogspot.com).<br /><br />These days, I generally develop Java apps, although that could change. So, expect to see Spring and Hibernate stuff for a while, and possibly some Google Android notes as I get into that. I've also been having fun with UTF-8 in MySQL recently, so I'll probably dump my thoughts on that here later on as a starter, in case it helps someone out.ArrayLusthttp://www.blogger.com/profile/08447702133255815841noreply@blogger.com0