I'm thinking about writing a tool that will extract information from User-Agent strings.
In the mean time, here is a quite comprehensive list of tools I've been able to find around the net that can assist me in this task
Tone of links for known User Agent strings
DB:
http://www.useragentstring.com/
http://www.user-agents.org/index.shtml?moz
http://www.icehousedesigns.com/useragents/spiderlist.php
http://www.botsvsbrowsers.com/
http://useragentstring.com/pages/useragentstring.php
Auto detection tools:
http://nerds.palmdrive.net/useragent/code.html
http://stackoverflow.com/questions/1005153/auto-detect-mobile-browser-via-user-agent
http://mdbf.codeplex.com/
http://detectmobilebrowser.com/
http://stackoverflow.com/questions/2508214/regexp-that-matches-user-agents-of-end-user-browsers-but-not-crawlers-with-90
http://stackoverflow.com/questions/927552/parsing-http-user-agent-string
http://www.djangosnippets.org/snippets/267/
http://browsers.garykeith.com/downloads.asp
http://user-agent-string.info/
http://pypi.python.org/pypi/httpagentparser
http://www.handsetdetection.com/
http://www.tnl.net/ua/OS/Cross-Platform
http://stackoverflow.com/questions/1005153/auto-detect-mobile-browser-via-user-agent
http://api.jquery.com/jQuery.browser/#jQuery.browser.version2
http://www.quirksmode.org/js/detect.html
INFO:
http://www.nczonline.net/blog/2010/01/12/history-of-the-user-agent-string/
If you know any other resources that can help please post in comments.
I will update this post as soon as I have some news on the subject.
Thank you,
Maxim.
Java Bytecode Assembly, Interesting concepts in the art of Computer Science/Software Development, maybe from time to time other pesky corp. related development issues.
Thursday, April 1, 2010
Wednesday, January 20, 2010
Resetting cached password of Subclipse
I was asked to document a FAQ about Subclipse and cached passwords (my turn to play with the IT hat!). Here is the email (kept here for future reference).
Hello Friends,
Eclipse subversion plugin (Subclipse) will cache the username & password of the last user that did a successful commit with your eclipse installation.
This can be problematic if this user is not you, it turns out that until further notice all your svn commits will be under different username.
To resolve this issue, delete the following 2 folders:
rm -rf /opt/eclipse3.3/configuration/org.eclipse.core.runtime/.keyring
rm -rf ~/.subversion/
Then restart eclipse.
An alternative solution would be to kindly ask the busy IT department to change the svn password of the user under which your commits are being executed, then on first commit attempt Eclipse should prompt your for username & password, which will allow you to input your information.
Reference: http://nlp.cs.byu.edu/~rah67/wordpress/?p=4
Maxim.
Hello Friends,
Eclipse subversion plugin (Subclipse) will cache the username & password of the last user that did a successful commit with your eclipse installation.
This can be problematic if this user is not you, it turns out that until further notice all your svn commits will be under different username.
To resolve this issue, delete the following 2 folders:
rm -rf /opt/eclipse3.3/configuration/org.eclipse.core.runtime/.keyring
rm -rf ~/.subversion/
Then restart eclipse.
An alternative solution would be to kindly ask the busy IT department to change the svn password of the user under which your commits are being executed, then on first commit attempt Eclipse should prompt your for username & password, which will allow you to input your information.
Reference: http://nlp.cs.byu.edu/~rah67/wordpress/?p=4
Maxim.
Sunday, January 17, 2010
Running Average calculation implementation in Java
Quick blog and store note:
Here is a code to calculate average series of length N without the problem of overflow that naive average calculation could face.
Here is a code to calculate average series of length N without the problem of overflow that naive average calculation could face.
/** * Copyright (c) 2010, Maxim Veksler* All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright notice, this list * of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. Neither the name * of the http://bytecoded.blogspot.com/ nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. */ /** * Calculate average of arbitrary length series of doubles, running average ensures * result won't overflow. * * Algorithm: CELLCOUNT represents number of cells calculated so far. * For each : cell * avg = ((CELLCOUNT-1) * avg) + ((1/CELLCOUNT) * avg) * * @param series vararg list of parameters (array of doubles). * @return Average calculated from supplied series. */ public static double movingAverage(double... series) { if(series.length < 1) { return 0; } double avg = series[0]; for(int i = 1; i < series.length; i++) { avg = (avg * ((double)i/(i+1))) + (series[i] * ((double)1/(i+1))); } return avg; }
Tuesday, December 15, 2009
Jasper Reports - Subreport usage demonstration
This post is part of Jasper Reports demo documentation project, please read that post for information on downloading the discussed demo files
jasperreports-3.7.0/demo/samples/subreport
This demonstration will teach you how to reuse sub-reports for enhancing report visual layout. Subreports among other things allow you to achieve high level of data presentation complexity with relatively small overhead.a Subreport in Jasper terminology is single jrxml report file which is designed to be included in a master report, the master report should pass parameters to the subreport (For ex. rowId or street address) which are accessed by the subreport using $P{"parameterName"} notation. Optional feature for subreport is return parameters which allow passing information from calculations done within the subreport back to the master report, under the hood these are variables which are defined in the master report and passed to the subreport element (we will see an example of this later in the post).
Lets start with the basics setup required to get the report demo running:
First you will need to start the hsqldb database.
Next open all 3 reports in iReports.
- MasterReport.jrxml
- ProductReport.jrxml
- AddressReport.jrxml
Test the report is working:
- In iReports, assuming you followed the hsqlsdb setup guide you should select "jdbc:hsqldb:hsql://localhost" as your datasource.
- Make sure you have focus on the MasterReport tab
- Now click "Preview"
- In the popup windows select "Use Default"
To configure a fully functional we will need to do some adjustment steps, as we are operating the report from iReport instead from Java code.
MasterReport has has a parameter called ProductsSubreport of type net.sf.jasperreports.engine.JasperReport this parameter can be used in production environment to dynamically supply the subreport Class Instance that will be used by one of this subreport elements (more on this later). For now, lets change this to supply a fixed sub report element so that we can preview the full report in iReports as Jasper team designed it.
Locate in iReports the element's:
- MasterReport -> Details 1 -> $P{ProductsSubreport} then set the following fields:
- Subreport Expression = "ProductReport.jasper"
- Expression Class = java.lang.String
- MasterReport -> Parameters -> ProductsSubreport then set the following fields:
- Use as a prompt = [ ] (unselected)
Now if you try to preview the report again the following will be shown:
Good! The report is fully operation. Lets start analyzing.
Understanding Report logical Structure
This report prints product orders grouped by city. The report layout is as following:== Report Title =
Heading + Total number of orders
== Page Title ==
Page Heading
== Details ==
= First page =
City name COUNTER: Number of address ordered in this city
= Next n pages =
City name cont
Then 2 lists order side by side displaying:
First list = Products ordered by people in current city
Second list = Address that made orders in current city
== Page Footer ==
Page X out of XXX
Understanding Report JRXML structure
MasterReport.jrxml
Master Report :: QueryThe main report is based on the following SQL query: SELECT City FROM Address GROUP BY City ORDER BY City which should self explentionary.
Master Report -> Title
This section contains static text and a graphical horizontal bar.
Pay attention to the Text Field that as part of his expression uses the dynamically calculated variable $V{ProductTotalPrice} this variable is returned from the sub reports called during report filling phase and the results are summarized by the engine. More on this later.
Master Report -> Page Header
Nothing special here. Static text that will be printed at the start of each page.
Master Report -> Details 1
The heart of the report.
It is important to understand that a details band can grow beyond single page size, Jasper has special treatment for these situation via settings which can be set on each element as we shall see next:
On the first page we want to print "CityName" COUNTER Addresses, on the following pages for the same city OTOH all we want to print is "CityName" cont
The idea is that if a city band grows to several pages we will reprint the "CityName" and the text "Cont"
TextField $F{City} has the setting Print Repeated Values and Print When Details Overflows which causes it repeat on each page, even when the band for current city grows beyond 1 page size.
TextField $V{CityAddressCount} + " addresses" has the setting Print Repeated Values which will allow this field to be printed even if 2 cities have the same number of addresses but note this Print When Details Overflows is turned off which causes this text to be printed only on the first page of the band !
Label (continued) has the setting Print Repeated Values turned off and Print When Details Overflows enabled. This cause this label to be printed only on overflowed bands (meaning only on 2nd pages and following...).
Subreport $P{ProductsSubreport} is the embedding of the ProductReport subreport. Note this report gets the Database connection from the MasterReport, we also pass a parameter to this report City = $F{City}. This report returns a variable, the way this is implement in Jasper Reports is as following: We define a variable in the master report ProductTotalPrice, then we pass this variable to the subreport which sets values into this variable. Then, after the subreport evaluation has ended in the MasterReport we can use this variables value. In the present context we use this method to calculate a summary (TOTAL) of the price of all the products being evaluated by the subreport. Note that as part of the definition of the variable on the subreport element we configure Calculation Type = Sum this allows the engine to do the summary of this variable (which is passed to many subreport's - A subreport is evaluated for each city). See Variables section for another note on the ProductTotalPrice variable.
Master Report -> Variables
ProductTotalPrice this variable is used by the MasterReport to display the sum of the price of all products that have been evaluated by the subreport ProductReport note this variable has the property Calculation = System meaning that it is being manipulated separately (not by the engine). This is actually a little hack (IMHO) because we do sum it using the engine only we do it on the Subreport $P{ProductsSubreport} variable configuration properties. Just in case you wondered: Yes! it works.
ProductReport.jrxml
To be continued...AddressReport.jrxml
To be continued...Monday, December 14, 2009
Jasper Reports hsqldb database setup
This post is part of Jasper Reports demo documentation project, please read that post for information on downloading the discussed demo files
Jasper Report distribution comes with a sample database populated with data which proves to be as useful as it can be for running the supplied demo reports / testing concepts before implementing in production environments.To use this database you will need to
- Have it up and running
- Configure the connection in iReports
On a linux box this is straight forward as explained below (Win/OSX and others should have similar guide lines).
Have HSqlDB it up and running
// Demonstrated for iReports, JasperReports v3.7.0Open up a terminal windows and issue the following commands:
$ cd JasperReports/jasperreports-3.7.0/demo/hsqldb/
$ ant You will see output similar to this
Buildfile: build.xml runServer: [java] [Server@15c7850]: [Thread[main,5,main]]: checkRunning(false) entered [java] [Server@15c7850]: [Thread[main,5,main]]: checkRunning(false) exited [java] [Server@15c7850]: Startup sequence initiated from main() method [java] [Server@15c7850]: Loaded properties from [/home/maximv/Desktop/JasperReports/jasperreports-3.7.0/demo/hsqldb/server.properties] [java] [Server@15c7850]: Initiating startup sequence... [java] [Server@15c7850]: Server socket opened successfully in 4 ms. [java] [Server@15c7850]: Database [index=0, id=0, db=file:test, alias=] opened sucessfully in 607 ms. [java] [Server@15c7850]: Startup sequence completed in 612 ms. [java] [Server@15c7850]: 2009-12-14 18:32:33.542 HSQLDB server 1.8.0 is online [java] [Server@15c7850]: To close normally, connect and execute SHUTDOWN SQL [java] [Server@15c7850]: From command line, use [Ctrl]+[C] to abort abruptly
That's it. Keep the terminal window open otherwise the DB will shutdown. The database can be accessed locally using the
Path:
jdbc:hsqldb:hsql://localhost Username: sa
Password: "" (blank, no password).
Configure the HSqlDB connection in iReports
In iReports the setup is as follows:
- Click the new data source connection button:

- Click the new connection

- Configure connection to the hsqldb datasource

That is
JDBC Driver = HSQLDB (server) (org.hsqldb.jdbcDriver)
JDBC URL = jdbc:hsqldb:hsql://localhost
Username = sa
Password = ([V] Save password)
- Test the connection is working.
After configuring the connection you should click the "Test" button, if everything goes well the following popup windows will confirm this.

Jasper Reports demo documentation project
Jasper Reports is one of several well known and well established open source reporting frameworks.
One thing it lacks badly is good documentation, I believe it's a safe claim that anything beyond the regular most basic report structure will throw you straight into googling, example files and forum posts. iReport will help, documentation will be somewhat helpful as well, but do be prepared for the moment when even these paths fail, that's when you will stand at the face of either commercial support or diving into the code of the engine.
Several more source of information for Jasper Report Developers
One thing it lacks badly is good documentation, I believe it's a safe claim that anything beyond the regular most basic report structure will throw you straight into googling, example files and forum posts. iReport will help, documentation will be somewhat helpful as well, but do be prepared for the moment when even these paths fail, that's when you will stand at the face of either commercial support or diving into the code of the engine.
Downloading the demo jrxml files
To help the community a little bit, I'm starting a little documentation project for the examples supplied with Jasper Reports source distribution which can be obtained by checking out the source code or by downloading the latest dist from here. All this in the hope to lower the learning curve and allow easier adoption by casual report dev folks.Several more source of information for Jasper Report Developers
- JasperReports 3.7.0 - Schema Reference
- Designing reports using JasperReports 3.5
- Generally speaking StackOverflow jasper-reports tag
Jasper Reports Demo files Index
Written guides are hyper-linked - This is work in progress I will be editing this post as more guides are published.[maximv@mldev2 JasperReports]$ find jasperreports-3.7.0/demo/samples/ -maxdepth 1 -mindepth 1 -type d | sort- jasperreports-3.7.0/demo/samples/alterdesign
- jasperreports-3.7.0/demo/samples/antcompile
- jasperreports-3.7.0/demo/samples/barbecue
- jasperreports-3.7.0/demo/samples/barcode4j
- jasperreports-3.7.0/demo/samples/batchexport
- jasperreports-3.7.0/demo/samples/beanshell
- jasperreports-3.7.0/demo/samples/charts
- jasperreports-3.7.0/demo/samples/chartthemes
- jasperreports-3.7.0/demo/samples/crosstabs
- jasperreports-3.7.0/demo/samples/csvdatasource
- jasperreports-3.7.0/demo/samples/datasource
- jasperreports-3.7.0/demo/samples/ejbql
- jasperreports-3.7.0/demo/samples/fonts
- jasperreports-3.7.0/demo/samples/genericelement
- jasperreports-3.7.0/demo/samples/groovy
- jasperreports-3.7.0/demo/samples/hibernate
- jasperreports-3.7.0/demo/samples/horizontal
- jasperreports-3.7.0/demo/samples/hyperlink
- jasperreports-3.7.0/demo/samples/i18n
- jasperreports-3.7.0/demo/samples/images
- jasperreports-3.7.0/demo/samples/jasper
- jasperreports-3.7.0/demo/samples/java1.5
- jasperreports-3.7.0/demo/samples/javascript
- jasperreports-3.7.0/demo/samples/jcharts
- jasperreports-3.7.0/demo/samples/jchartscomponent
- jasperreports-3.7.0/demo/samples/jexcelapi
- jasperreports-3.7.0/demo/samples/jfreechart
- jasperreports-3.7.0/demo/samples/landscape
- jasperreports-3.7.0/demo/samples/list
- jasperreports-3.7.0/demo/samples/markup
- jasperreports-3.7.0/demo/samples/mondrian
- jasperreports-3.7.0/demo/samples/nopagebreak
- jasperreports-3.7.0/demo/samples/noreport
- jasperreports-3.7.0/demo/samples/noxmldesign
- jasperreports-3.7.0/demo/samples/openflashchart
- jasperreports-3.7.0/demo/samples/pdfencrypt
- jasperreports-3.7.0/demo/samples/poi-3.5
- jasperreports-3.7.0/demo/samples/printservice
- jasperreports-3.7.0/demo/samples/query
- jasperreports-3.7.0/demo/samples/rotation
- jasperreports-3.7.0/demo/samples/scriptlet
- jasperreports-3.7.0/demo/samples/shapes
- jasperreports-3.7.0/demo/samples/stretch
- jasperreports-3.7.0/demo/samples/styledtext
- jasperreports-3.7.0/demo/samples/subreport
- jasperreports-3.7.0/demo/samples/table
- jasperreports-3.7.0/demo/samples/tableofcontents
- jasperreports-3.7.0/demo/samples/templates
- jasperreports-3.7.0/demo/samples/text
- jasperreports-3.7.0/demo/samples/unicode
- jasperreports-3.7.0/demo/samples/virtualizer
- jasperreports-3.7.0/demo/samples/webapp
- jasperreports-3.7.0/demo/samples/xlsdatasource
- jasperreports-3.7.0/demo/samples/xlsformula
- jasperreports-3.7.0/demo/samples/xmldatasource
Saturday, January 31, 2009
Blog Template Hacking
I will probably be hacking the blog template from time to time, you can find the source of it hosted at this google code repository.
For those few that are not familiar with concept of Revision Control I will describe briefly why I choose to use it here, which should also explain the general idea behind the concept.
I will be hacking the template of the blog, this means I will be modifying the "code" of my blog, the reason I want to do this is simple: It affects the way you see it. This "code" is parsed by blogger backend server and rendered into HTML which is later parsed by your browser and displayed to your eyes (which by the way goes another parsing and interpretation by your brain before you can actually "see"/ "read" my blog). Parsing is the process of "understanding" a known format.
Now, due to the known fact that there is no software without bugs. Hacking surly means introducing bugs, considering the fact that I've never edited blogger templates before- The bug factor is even higher. Further more, bugs are here forever or as the saying goes "To err is human, to fix it divine" (A remix of Alexander Pope famous quote "To err is human, to forgive divine" by your humble).
To tackle this bug fixing process in a more profound process, one of the best techniques is going back step by step attempting to isolate what exactly caused the wrong behavior (the bug). This is where revision control system comes in- It allows you to retrieve older versions of the file, further more it allows you to display a difference between 2 versions of the same file in an easily accessible interface. This fits into the previously introduced metaphor of bug tackling: start from something that worked, search revision by revision until you find what broke it, understand why it's broken, fix the problem, ensure the fix works. Some folks forgot the import step of Learn from the error and think how to avoid it next time.
You can open your own Google code repository at the following link Google Code, as for document revisioning, you can do the same thing using Google Docs which allows out of the box "History" of your document modifications.
Subscribe to:
Posts (Atom)
Blog Archive
About Me
- Maxim Veksler
- Tel Aviv, Israel
- I work in one of Israel's Hi-Tech company's. I do 5 nines system development with some system administration. This blog will focus on the technical side of things, with some philosophical strings attached.

