Pesquisar neste blogue
terça-feira, 22 de dezembro de 2015
Struts 2 and TLD issues.
According to TLD or attribute directive in tag file, attribute value does not accept any expressions
I have been rather plagued by this error on the last few days when using Struts2 till. By chance i came across https://almeidamike.wordpress.com/2010/03/12/struts-solving-according-to-tld-or-attribute-directive-in-tag-file-attribute-value-does-not-accept-any-expressions/ .
So if you are having some difficulties accessing parameters of the request or other values be sure to enable debug as specified in https://struts.apache.org/docs/debugging-struts.html and find the correct path to your value.
Credits to the owner of https://almeidamike.wordpress.com/author/almeidamike/.
Examples:
${someField} becomes %{#attr.someField}. Acessing request parameters would be for instance %{#parameters.someField}.
quarta-feira, 28 de outubro de 2015
New job new life new projects.
It seems i have left this place a bit scarse on news for a while now. Starting a new job and getting used to new routines made me neglect this place a bit.
That does not mean i have not been busy :) :
On a side topic, are there any UK citizens following this blog? I have received some jobs offers from the U.K and i do have a passion for that country, more than for my own country Portugal sometimes (and god knows how it is decreasing), so moving to the U.K would be a long time project with hopefully citizenship involved. How is it like to be an UK citizen?
That does not mean i have not been busy :) :
- Working on Spring + JPA + AOP and learning how to deal with some strange errors (if you follow this blog and wish some tutorials and/or to get around common errors please let me know)
- A project i have started in between jobs, leveraging odoo to implement tracking of e-procurement contracts (adapted to the Portuguese reality as that is the one i am more familiarized with) . Connecting those with Odoo projects allows for some really nice features ( https://www.odoo.com/page/project-management. ).
- Working with my good friends at https://www.linkedin.com/company/good-omens-webstudio (if you do work in Morocco do check them out, they are great at what they do).
- Uploading "Templo dos Jogos" to the Youtube (https://www.youtube.com/channel/UC3QNejga3cw69-NvmFvjyWA/videos )
On a side topic, are there any UK citizens following this blog? I have received some jobs offers from the U.K and i do have a passion for that country, more than for my own country Portugal sometimes (and god knows how it is decreasing), so moving to the U.K would be a long time project with hopefully citizenship involved. How is it like to be an UK citizen?
Etiquetas:
AOP,
good omens webstudio,
odoo,
procurement,
Spring,
Uk
segunda-feira, 3 de agosto de 2015
Sometimes it is better to have less.
My friends at Good Omens WebStudio shared with me a project that came across them for the Quercus organization. I did a quick analysis of the slow points for them. It didn't take long to do an "oh god".
The worst is not even shown on that picture:- A 1.6 megabytes ttf font used by one of the css files.
To make matters worse the way Apache is configured the font is never cached by the browser, and it can only start working when it has the font.
The worst is not even shown on that picture:- A 1.6 megabytes ttf font used by one of the css files.
To make matters worse the way Apache is configured the font is never cached by the browser, and it can only start working when it has the font.
segunda-feira, 27 de julho de 2015
One of those things
After installing Odoo like said on the link (http://www.theopensourcerer.com/2014/09/how-to-install-openerp-odoo-8-on-ubuntu-server-14-04-lts/ ) i posted a few messages back.
I noticed a strange behaviour, , massive memory comsuption and cpu usage, on accounts-daemon on my ubuntu 15.04 instalation.
You can attach gdb to a running process by using --pid. So by using
I could debug the running process, and then i saw :
(*) File or directory not existent..
Not good not good at all..
I noticed a strange behaviour, , massive memory comsuption and cpu usage, on accounts-daemon on my ubuntu 15.04 instalation.
You can attach gdb to a running process by using --pid. So by using
1 | sudo gdb --pid=597 |
I could debug the running process, and then i saw :
1 2 3 4 5 6 | 0x00007f4ae4dea1e1 in __GI__nss_files_parse_pwent (
line=0x1f00606 ":x:65534:65534:nobody:/nonexistent:/usr/sbin/nologin",
line@entry=0x1f00600 "nobody:x:65534:65534:nobody:/nonexistent:/usr/sbin/nologin", result=result@entry=0x7f4ae50e7060 <resbuf>, data=data@entry=0x1f00600,
datalen=datalen@entry=1024, errnop=errnop@entry=0x7f4ae60747d0)
at fgetpwent_r.c:34
34 fgetpwent_r.c: Ficheiro ou directoria inexistente (*).
|
(*) File or directory not existent..
Not good not good at all..
segunda-feira, 20 de julho de 2015
Pack Javascript and CSS
In some Java web related projects i have worked the number of css and JavaScript files included in the jsp pages where sometime more than desired.At the time i came across Packtag which allows you to minify, combine and pack your resources into a single file therefore reducing the number of requests to your server which is always nice.
sexta-feira, 17 de julho de 2015
Playing with Odoo and Tesseract.
During these lasts days i have been reading things about Odoo and how it had improved since i last worked on it professionally and i came across Basics-developing-simple-module-openerp a great resource for anyone wanting to start working on Odoo.
So work started on document_scanner, a plugin for Odoo, which uses Tesseract to import pictures and convert them to text .
The entry point of a Odoo plugin is the __init__.py file and as my plugin is written on document_scanner.py my __init__.py file looks like
Next lets take a look at the __openerp__.py file where you must include the dependencies, the description and your personal information which will be visible to the user when the plugin is installed. My file looks like:
which visually translates to
On the __openerp__.py file if you notice there is a reference to a xml file "document_scanner_view.xml" which is where the look and feel of the plugin is defined.
On document_scanner the xml file looks like :
To better understand the file i recommend you read it from the menuitem till the top.
After that was done i needed to find a picture to test and i found Factura Vaca
The end result
The text is not quite right yet, still have to look into it. Still thinking on how i can improve this plugin. Any suggestions?
So work started on document_scanner, a plugin for Odoo, which uses Tesseract to import pictures and convert them to text .
The entry point of a Odoo plugin is the __init__.py file and as my plugin is written on document_scanner.py my __init__.py file looks like
1 2 3 | # -*- coding: utf-8 -*- import document_scanner |
Next lets take a look at the __openerp__.py file where you must include the dependencies, the description and your personal information which will be visible to the user when the plugin is installed. My file looks like:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | { 'name': 'Document Scanner', 'version': '1.0', 'category': 'Tools', 'description': """ Module which uses OCR to treat image files in Odoo. ============================================== """, 'author': 'Rui Caridade', 'depends': ['base','document'], 'data': ['document_scanner_view.xml'], 'demo': [], 'installable': True, 'auto_install': False } |
which visually translates to
On the __openerp__.py file if you notice there is a reference to a xml file "document_scanner_view.xml" which is where the look and feel of the plugin is defined.
On document_scanner the xml file looks like :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | <?xml version="1.0" encoding="utf-8"?> <openerp> <data> <record id="document_scanner_wizard_view_form" model="ir.ui.view"> <field name="name">document.scanner.wizard.form</field> <field name="model">document.scanner.wizard</field> <field name="arch" type="xml"> <form string="Document Scanner"> <group col="4"> <field name="data"/> </group> <group col="4"> <field name="textoDaImagem"/> </group> <button name="import_file" string="Import" type="object" /> <button icon="gtk-cancel" special="cancel" string="Cancel"/> </form> </field> </record> <record model="ir.actions.act_window" id="action_document_scanner_form"> <field name="name">Document Scanner</field> <field name="type">ir.actions.act_window</field> <field name="res_model">document.scanner.wizard</field> <field name="view_type">form</field> <field name="view_mode">form</field> <field name="target">new</field> </record> <record id="action_dir_doc_scanner_view" model="ir.actions.act_window.view"> <field name="view_mode">form</field> <field name="view_id" ref="document_scanner_wizard_view_form"/> <field name="act_window_id" ref="action_document_scanner_form"/> </record> <menuitem action="action_document_scanner_form" id="menu_document_scanner" parent="knowledge.menu_document_configuration"/> </data> </openerp> |
To better understand the file i recommend you read it from the menuitem till the top.
After that was done i needed to find a picture to test and i found Factura Vaca
The end result
The text is not quite right yet, still have to look into it. Still thinking on how i can improve this plugin. Any suggestions?
domingo, 5 de julho de 2015
Profiling with gcc and gprof
One of my passions in computing is virtualization.
A friend of mine some decades back showed me a Super Nintendo emulator on his Pentium MMX and i was hooked.
More professional uses of virtualization came with time however the gaming bug still sticks with me.
This weekend i took some time to play around a Sega Dreamcast emulator - Lxdream - developed by Nathan Keynes as last time i tried to compile it i had some warnings caused by some linux includes which some undefs solved.
After that was fixed i tried to profile the code to see what could be improved. Fortunately Nathan already had the --enable-profile configure switch which sets `-pg' option when you run the compiler.
After that the gprof command generates a nice informative file.
Below the top lines of the output file
Maybe using OpenMP on that arm_execute_instruction is my next weekend computing fun.
A friend of mine some decades back showed me a Super Nintendo emulator on his Pentium MMX and i was hooked.
More professional uses of virtualization came with time however the gaming bug still sticks with me.
This weekend i took some time to play around a Sega Dreamcast emulator - Lxdream - developed by Nathan Keynes as last time i tried to compile it i had some warnings caused by some linux includes which some undefs solved.
#undef REG_RAX #undef REG_RCX #undef REG_RDX #undef REG_RBX #undef REG_RSP #undef REG_RBP #undef REG_RSI #undef REG_RDI #undef REG_R8 #undef REG_R9 #undef REG_R10 #undef REG_R11 #undef REG_R12 #undef REG_R13 #undef REG_R14 #undef REG_R15
After that was fixed i tried to profile the code to see what could be improved. Fortunately Nathan already had the --enable-profile configure switch which sets `-pg' option when you run the compiler.
After that the gprof command generates a nice informative file.
gprof src/lxdream gmon.out > analysis.txt
Below the top lines of the output file
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | Flat profile: Each sample counts as 0.01 seconds. % cumulative self self total time seconds seconds calls ms/call ms/call name 37.79 3.28 3.28 cpu_print_registers 9.10 4.07 0.79 123044895 0.00 0.00 arm_execute_instruction 7.26 4.70 0.63 ext_sdram_read_long 6.68 5.28 0.58 109333 0.01 0.01 xlat_get_code 2.77 5.52 0.24 18516563 0.00 0.00 sort_extract_triangles 2.65 5.75 0.23 ccn_prefetch 2.19 5.94 0.19 xlat_invalidate_long 2.19 6.13 0.19 1531965 0.00 0.00 ta_commit_polygon 2.07 6.31 0.18 ext_sdram_write_word 2.07 6.49 0.18 ocram_page0_read_byte 1.73 6.64 0.15 xlat_flush_page 1.50 6.77 0.13 150802470 0.00 0.00 arm_read_long 1.50 6.90 0.13 6922797 0.00 0.00 ta_write_tile_entry 1.50 7.03 0.13 1604 0.08 0.21 pvr2_scene_read 1.38 7.15 0.12 4663896 0.00 0.00 sort_add_triangle 1.27 7.26 0.11 3355889 0.00 0.00 pvr2_ta_process_block 1.15 7.36 0.10 62003 0.00 0.00 audio_mix_samples 1.04 7.45 0.09 62003 0.00 0.02 arm_run_slice 1.04 7.54 0.09 21625 0.00 0.00 arm_restore_cpsr 0.81 7.61 0.07 ext_sdram_read_word 0.81 7.68 0.07 ext_sdram_write_long 0.69 7.74 0.06 1238296 0.00 0.00 gl_render_tilelist 0.63 7.80 0.06 unmapped_prefetch |
Maybe using OpenMP on that arm_execute_instruction is my next weekend computing fun.
sexta-feira, 3 de julho de 2015
Starting with Odoo - Part 1
Some years ago i worked professionaly with OpenERP in its version 5 and 6 for a small portuguese company called OpenSecure . Life takes you in different routes sometimes and i lost track of its development, which made Odoo a really pleasant surprise.
So in order to refresh my own knowledge of OpenErp and Python i decided to do a series of tutorials, or if you prefer progress reports,where we'll be making a simple app for Odoo , a document scanner using tesseract ocr ( Tesseract-ocr ).
First we need to install Odoo.
The most complete tutorial, really a great job people , can be found here - how-to-install-openerp-odoo-8-on-ubuntu-server -
We'll also need a python binding for tesseract - pytesseract - which means in Ubuntu or in your OS choice you may need also to install pip.
In the Part 2 i'll describe the anotomy of an OpenERP app and how to use pytesseract to extract information from an image file.
If you can identify which kind of document it is the really fun part can begin :).
So in order to refresh my own knowledge of OpenErp and Python i decided to do a series of tutorials, or if you prefer progress reports,where we'll be making a simple app for Odoo , a document scanner using tesseract ocr ( Tesseract-ocr ).
First we need to install Odoo.
The most complete tutorial, really a great job people , can be found here - how-to-install-openerp-odoo-8-on-ubuntu-server -
We'll also need a python binding for tesseract - pytesseract - which means in Ubuntu or in your OS choice you may need also to install pip.
In the Part 2 i'll describe the anotomy of an OpenERP app and how to use pytesseract to extract information from an image file.
If you can identify which kind of document it is the really fun part can begin :).
Etiquetas:
odoo,
pip,
python,
tesseract,
ubuntu server
quarta-feira, 1 de julho de 2015
Before delving into Odoo i would like to share a project that has saved my life a couple of times - signtester .
If you need to sign (re-sign) several jar files take a look at it :)
If you need to sign (re-sign) several jar files take a look at it :)
Etiquetas:
certificates,
java,
multiple sign,
servoy,
signtester,
tool
terça-feira, 30 de junho de 2015
Javascript idiosyncrasies
To start this blog nothing better than a Javascript behaviour i noticed while working on a given project.
Let's say you submit a date like '2015-06-31' which is invalid. Javascript will do the smart thing, really people
, and consider that date as '2015-07-01' if you create a Date object out of it.
Searching for a solution i came across the following code:
Let's say you submit a date like '2015-06-31' which is invalid. Javascript will do the smart thing, really people
, and consider that date as '2015-07-01' if you create a Date object out of it.
Searching for a solution i came across the following code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
function isDate(txtDate)
{
var currVal = txtDate;
if(currVal == '')
return false;
var rxDatePattern = /^(\d{4})(\/|-)(\d{1,2})(\/|-)(\d{1,2})$/; //Declare Regex
var dtArray = currVal.match(rxDatePattern); // is format OK?
if (dtArray == null)
return false;
dtMonth = dtArray[3];
dtDay= dtArray[5];
dtYear = dtArray[1];
if (dtMonth < 1 || dtMonth > 12)
return false;
else if (dtDay < 1 || dtDay> 31)
return false;
else if ((dtMonth==4 || dtMonth==6 || dtMonth==9 || dtMonth==11) && dtDay ==31)
return false;
else if (dtMonth == 2)
{
var isleap = (dtYear % 4 == 0 && (dtYear % 100 != 0 || dtYear % 400 == 0));
if (dtDay> 29 || (dtDay ==29 && !isleap))
return false;
}
return true;
}
From : http://stackoverflow.com/questions/18758772/how-do-i-validate-a-date-in-this-format-yyyy-mm-dd-using-jquery
It seems pretty complete and it has a special case to workaround the behavior at the start of this post.
As an alternative you could create a new Date object and compare
dtMonth and
dtDay and
dtYear to be the same as before.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
function isDate(txtDate)
{
var currVal = txtDate;
if(currVal == '')
return false;
var rxDatePattern = /^(\d{4})(\/|-)(\d{1,2})(\/|-)(\d{1,2})$/; //Declare Regex
var dtArray = currVal.match(rxDatePattern); // is format OK?
if (dtArray == null)
return false;
dtMonth = dtArray[3];
dtDay= dtArray[5];
dtYear = dtArray[1];
var date = new Date(txtDate);
return (date.getMonth()==(dtMonth-1) && date.getDate()==dtDay && date.getFullYear()==dtYear);
}
You can test it here - http://jsfiddle.net/EywSP/2282/
The month count being from 0 to 11 also makes perfect sense.
My next post will focus on odoo and how to implement a simple questionnaire framework for your clients.
Subscrever:
Mensagens (Atom)