Wednesday, December 17, 2008

a good lookup snippet

    @SuppressWarnings("unchecked")
public T lookup(Class clazz, final String pJndiName) {
T cs = null;
String jndiName = (pJndiName == null)
? jndiPrefix + clazz.getSimpleName() + "Bean/remote"
: pJndiName;

LOG.debug("Looking for "+jndiName);
try {
Object o = context.lookup(jndiName);
if (o == null) {
System.err.println("unable to find " + jndiName);
} else {
System.out.println("retrieved instance of "
+ o.getClass().getName());
}
cs = (T) PortableRemoteObject.narrow(o, clazz);

} catch (NamingException e) {
e.printStackTrace();
}
return cs;
}

Tuesday, December 16, 2008

Ouch!!! Dependency injection is incomplete!!!

i've found this blog post about remote ejb injection, and it makes me sad :_(

Wednesday, November 5, 2008

Encoding with mancoder (from wmv to xvid)


nice -n 19 mencoder -ss 00:03:00 -endpos 70 -vf scale=352:288 <source_file> ofps 23.976 -oac mp3lame -lameopts abr:br=92 -ovc xvid -xvidencopts pass=2:bitrate=100 -o <dest_file>


where

nice is to increase process priority
-ss start time
-endpos stop after 70 seconds
-vf scale to resize original to quarter PAL
bitrate for web from 100 to 150 is ok

Wednesday, October 22, 2008

Uncertainty principle and quanta

The values of certain pairs of conjugate variables (time and software quality, for instance) cannot both be known with arbitrary precision. That is, the more precisely you want one value, the less precisely you get the other. This is not a statement about the limitations of a software engineer's ability to design a system, but rather about the nature of the system itself.

In software engineering, a man (plural: men) is an indivisible unit of work and is related to both time and software quality. Behind this, one finds the fundamental notion that a software system may be "quantized", referred to as "quantization". This means that the man can take on only certain discrete numerical tasks, rather than any value, at least within a range.

Friday, October 17, 2008

Some applications to replace MS Windows III

After lot of time I'm playing chess again (collecting defeats :D). Linux provides software to deal with chess too, my preferred are: scid, which is a game database with analysis capabilities and crafty, which is an analysis engine.

Reaching managed beans

Managed beans are reachable by injection through configuration of the faces-config or through look up using expressions like:


(MyBean)FacesContext.getCurrentInstance()
.getApplication().evaluateExpressionGet(
FacesContext.getCurrentInstance(),
"#{myBeanName}", MyBean.class);

Monday, September 22, 2008

disable http and ftp access to oracle-xe


SQL> -- disable http and ftp access
SQL> begin
2 dbms_xdb.sethttpport('0');
3 dbms_xdb.setftpport('0');
4 end;
5 /

PL/SQL procedure successfully completed.

SQL> -- get current status
SQL> select dbms_xdb.gethttpport as "HTTP-Port"
, dbms_xdb.getftpport as "FTP-Port" from dual;

HTTP-Port FTP-Port
---------- ----------
0 0

Sunday, September 21, 2008

EJB3 has incomplete entity management

After to have (zero)configured your session beans, it is possible to add AS behaviors using AS specific deployment descriptors... and that's good because portability becomes only a deploy configuration before packaging...
entities are not ready, seems to be not possible to provide entity manager specific behaviors at configuration level, as written in hibernate documentation:
In the current release only pure EJB3 annotations overriding are supported. If you wish to use Hibernate specific features in some entities, you'll have to either use annotations or fallback to hbm files.
sob...

Thursday, September 18, 2008

usefull namespaces

ejb-jar.xml <ejb-jar version="3.0"> http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd

persistence.xml <persistence xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd" version="1.0" xmlns="http://java.sun.com/xml/ns/persistence">

web.xml <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">

faces-config.xml <faces-config version="1.2" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xi="http://www.w3.org/2001/XInclude" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_1_2.xsd">

facelets <html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:f="http://java.sun.com/jsf/core">

application.xml <!DOCTYPE application PUBLIC "-//Sun Microsystems, Inc.//DTD J2EE Application 1.3//EN" "http://java.sun.com/dtd/application_1_3.dtd"> <application>

Thursday, August 21, 2008

Useful VIM commands

Working with VI can be very fast if commands are known... i've found this recap here

Thursday, July 24, 2008

alternatives

JRE
update-alternatives --config java

JDK
update-alternatives --config java_sdk_su

Sunday, July 13, 2008

Time's tyrant

No matter if we're working on a product, if customer ask customer must have and if time is so few who cares about the product, better to take care of the project... :/

Friday, June 27, 2008

Listing psql slash commands

# \?
\a toggle between unaligned and aligned mode
\c[onnect] [dbname|- [user]]
connect to new database (currently 'booktown')
\C <title> table title
\copy ... perform SQL COPY with data stream to the client machine
\copyright show PostgreSQL usage and distribution terms
\d <table> describe table (or view, index, sequence)
\d{t|i|s|v} list tables/indices/sequences/views
\d{p|S|l} list permissions/system tables/lobjects
\da list aggregates
\dd [object] list comment for table, type, function, or operator
\df list functions
\do list operators
\dT list data types
\e [file] edit the current query buffer or [file] with external editor
\echo <text> write text to stdout
\encoding set client encoding
\f <sep> change field separator
\g [file] send query to backend (and results in [file] or |pipe)
\h [cmd] help on syntax of sql commands, * for all commands
\H toggle HTML mode (currently off)
\i <file> read and execute queries from
\l list all databases
\lo_export, \lo_import, \lo_list, \lo_unlink
large object operations
\o [file] send all query results to [file], or |pipe
\p show the content of the current query buffer
\pset <opt> set table output = {format|border|expanded|fieldsep|
null|recordsep|tuples_only|title|tableattr|pager}
\q quit psql
\qecho <text> write text to query output stream (see \o)
\r reset (clear) the query buffer
\s [file] print history or save it in [file]
\set <var> <value> set internal variable
\t show only rows (currently off)
\T <tags> HTML table tags
\unset <var> unset (delete) internal variable
\w <file> write current query buffer to a
\x toggle expanded output (currently off)
\z list table access permissions
\! [cmd] shell escape or command

PS after about a month... not yet satisfied by OpenSUSE 11... or better... not yet satisfied byt KDE4.0 .... still wondering why plasmoids... which is their need... mmm bah...

Thursday, June 5, 2008

<input type="image" />, internet explorer and firefox

AH no way to work around a strange issue with <input type="image" /> and LookupDispatchAction in struts 1.2. Everything works perfectly in development where i'm using Firefox, no way to make it works using IE6 for linux. Bah....

Sunday, June 1, 2008

tcp port conflict starting jboss

eheheh jboss all configuration failed to start cause a tcp port conflict on port 1316. The conflict was with KTorrent running to spread seeds of my downloaded linux distributions.

Metrics

It is important to know the metrics of the code. Metrics are used to know measures of your code and let you understand if it is growing more than a desired measure, this will help to maintain the sources. I've found a good eclipse plugin called... metrics, it is available from its website, and it is given to work with Eclipse 3.1 even if i've found no problems to run it with Eclipse 3.3 (64bit).
Its website provides a brief description of some metric meanings that is worth to be read. As an example, the value of the McCabe Cyclomatic Complexity measure will provide a value to use to know if the already designed unit tests are enough exhaustive or if they lack some test cases.

Friday, May 23, 2008

Compiz, OpenSUSE 11 beta 2 and KDE4

Something has changed... but i succeded in setting up compiz... first of all i've executed what previously was called gnome-xgl-switch --enable-xgl and that's good!!! i'm using KDE why do i have to call gnome? then... i've executed
xgl-switch --enable-xgl
finally i've set up a symbolic link to compiz-manager into ~/.kde4/Autostart and restarted the laptop... the hardest way is the lack of informations but it's still so young...

Blogspot and new posts... it could be better...

This editor doesn't work with konqueror :_(

Saturday, May 17, 2008

Wireless card, kernel module and firmware

Sometime it's not enought to have wifi card kernel modules loaded, sometime it is required to install the firmware too.
This is the case for the BCM94311MCG wlan mini-pci card which is the wifi card in the Acer Extensa 5620Z laptop.
OpenSUSE 10.3 (and OpenSUSE 11 beta 2, which is the O.S. i'm using right now) has kernel modules for that card but requires another step as root user.
Connect the PC to a network using the ethernet and run as root the following command:
/usr/sbin/install_bcm43xx_firmware
which will download and install the firmware.
Reboot the PC and configure the wireless card... everything should go in the perfect way (as happend to me with suse 10.3 and 11b2).

Tuesday, May 13, 2008

Shell aliases, the .bashrc file

To personalize the shell with additional aliases edit or create it if missing the ~/.bashrc file. More infos can be found at the bash man page. Don't add aliases in the ~/.profile cause they can be ignored.

Friday, May 9, 2008

Some applications to replace MS Windows II

  • video capture: recordMyDesktop and encoding: KVideoEncoder (easy GUI to mencoder)
  • UML: umbrello, BOUML
  • privacy: KGPG instead of PGP

Tuesday, May 6, 2008

Google Webmaster Toolkit

From google page and after sign in, go to My Account and then Webmasters Tools.

Add your site, put the given meta tag (something like
<meta content='XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX' name='verify-v1'/>
) to verify it in the home page and complete the verify step.

Go on managing the web site, adding the sitemap which can be your RSS feed (for example http://morphy76.blogspot.com/rss.xml?max-results=500&start-index=1).


After a few time, indexes and statistics are created and the verify meta tag can be removed.

Trent the Great

It's possible to download the new NIN album for free from here.

Monday, May 5, 2008

Some applications to replace MS Windows

Lots of free alternatives, some examples:
  • photo editing, imaging: TheGimp instead of Photoshop (not the same, but enough)
  • photo archiving: digiKam, instead of Picasa (?);
  • browser web: konqueror, firefox, opera, instead of Internet Explorer;
  • email: kmail, thunderbird, evolution, instead of Outlook;
  • chat: kopete, amsn, pidgin, instead of MSN, konversation instead of Mirc;
  • voip: skype, gizmo, ekiga;
  • dev: quanta+, eclipse, netbeans, kdevelop;
  • filesharing: amule, ktorrent, instead of emule;
  • ftp: kasablanca;
  • burning: k3b instead of Nero;
  • backup dvd: k9copy;
  • multimedia: mplayer instead of Media Player, amaroK instead of iTune;
  • dvd authoring: ManDVD, avidemux, cinelerra;
  • office: openoffice, koffice instead of Office;
  • desktop search engine: beagle instead of Google Desktop;
  • desktop effects: compiz-fusion instead of Aero;
  • other stuff: knotes, akregator...
...and gaming? Something can be found here

Saturday, May 3, 2008

Intro

It's so bad to have a so empty page... so... this blog will be about some memories kept online... it should be better than having them as plain text files in my home directory. Some trivial, other, i hope, more interesting and they will be about java, linux, php, web... everything i think worth to be remembered.

This blog is written in (bad) english, cause it is very annoying when you think to have found a fix to your network card driver problem and then realize that the char-set and the language of the solution is something coming from mars...

The first step is del.icio.us: a great way to store and share bookmarks... so great that it can be used as a real alternative to search engines like goog ehm uhm... and yahoo...

A nice firefox plug-in, called My Del.icio.us, gives a very good integration between the service and the browser. A must.