Ruben Laguna's blog

Nov 15, 2007 - 1 minute read - Comments - added application authorized facebook permissions Uncategorized

Facebook API

I’ve been playing a little with Facebook API and I run into problems when trying to use the facebook.feed.publishStoryToUser api call. That call always return 0 (permissions error) for me. I realized that there’s a difference between “Added applications” and “Authorized applications”. So if you just direct the user to the login page (http://www.facebook.com/login.php?api_key=YOUR_API_KEY&v=1.0) from you application your app will end up in the Authorized Applications side. You have to direct the users to your application page in facebook first (http://www.

Nov 14, 2007 - 2 minute read - Comments - browser graph interactive java visualization

Graph visualization

After spending a bunch of time with the graphviz utilities (neato, dot, circo and twopi) trying to create a graph to understand the software dependencies between modules in a project I’ve been I assigned I realized that those tools don’t work well with large graphs. I tried and tried with no luck, I thought that the old linux kernel map poster used graphviz to create the poster but after googling a bit and reading the code for the FCGP project I found that they write PostScript directly.

Nov 5, 2007 - 2 minute read - Comments - bash corrupted crash cygwin linux setup.exe upgrade windows

cygwin: setup.exe crashes when upgrading packages

I’ve run into a very strange problem. Every time I run setup.exe and try to upgrade bash package setup.exe crashes with the familiar “setup.exe has generated errors and will be close by windows. you will need to restart the program. An error log is being created”. The solution I found is for bash package but I guess it also work for other packages as well After googling a bit I found the this mail thread .

Oct 16, 2007 - 1 minute read - Comments - apache derby describe java key show sys unique

How to get information on UNIQUE keys on Apache Derby

It’s not easy to get information on derby keys once you created them. I was looking for a command like “SHOW CREATE TABLE ” but no luck. I realized that the answer should lay in SYS tables. After googling a while I found the following bit of wisdom: The following query will give you the UNIQUE constraints on a table: select c.constraintname, c.constraintid from sys.systables t, sys.sysconstraints c where t.

Oct 16, 2007 - 1 minute read - Comments - axis2 axisservice configuration configurationcontext java services web

Passing configuration parameter to Axis2 services

One way to pass parameters to you Axis2 service: 1) write a tag inside your services.xml <?xml version="1.0" encoding="UTF-8"?><!-- This file was auto-generated from WSDL --><!-- by the Apache Axis2 version: 1.3 Built on : Aug 10, 2007 (04:45:47 LKT) --><serviceGroup><servicename="xxxxxxx"class="MyServiceLifeCycleImpl">.... <parametername="jdbcConnectionString">jdbc:derby:c:/demoderby2b;create=true;user=a;password=b;</parameter><parametername="jdbcDriver">org.apache.derby.jdbc.EmbeddedDriver</parameter>... </service></serviceGroup> 2) Write a ServiceLifeCycle class publicclassMyServiceLifeCycleImplimplementsServiceLifeCycle{privateLoglog=LogFactory.getLog(MyServiceLifeCycleImpl.class);publicvoidstartUp(ConfigurationContextconfCtx,AxisServiceaxisService){try{StringjdbcConnectionString=(String)axisService.getParameterValue("jdbcConnectionString");StringjdbcDriver=(String)axisService.getParameterValue("jdbcDriver");Class.forName(jdbcDriver).newInstance();Connectionconnection=DriverManager.getConnection(jdbcConnectionString);axisService.addParameter("jdbcConnection",connection);}catch(Exceptione){thrownewRuntimeException(e);}}.... 3) Add init method to your service ....privateServiceContextserviceContext;publicvoidinit(ServiceContextserviceContext){this.serviceContext=serviceContext;}.... 4) Access the parameter jdbcConnection from your service through serviceContext

Oct 15, 2007 - 1 minute read - Comments - application database derby instance java jvm sharing web webapp

Two web applications sharing the same Derby database

I just realized that to be able to open/share the same Derby database from two different web applications running in the same Tomcat instance (same JVM) you’ll need to put derby.jar in the $TOMCAT_HOME/common/lib and remove it from your applications WEB-INF/lib. I got the clue from this RIFE web page the jarfiles you need are derby.jar and derbytools.jar . Due to classloader peculiarities, don’t copy them to your application’s web/WEB-INF/lib/ subdirectory, or to Tomcat’s shared/lib/ directory.

Oct 9, 2007 - 2 minute read - Comments - dojo flexjson java javascript json output serialize xstream

Dojo, JSON, Xstream and FLEXJSON

I’ve been trying to use XStream to generate JSON to be consumed by Dojo. But I can’t find the way to generate the right JSON from XStream, it keeps adding extraneous {} around. I even tried this but no luck . For example I want to generate this JSON output (taken from Dojo FilteringSelect example) : {"identifier":"abbreviation", "items": [ {"name":"Alaska", "label":"Alaska","abbreviation":"AK"}, {"name":"Wyoming", "label":"Wyoming","abbreviation":"WY"} ]} My attempt usign XStream: packagecom.rubenlaguna.json;importjava.util.ArrayList;importjava.util.Collection;importcom.thoughtworks.xstream.XStream;importcom.thoughtworks.xstream.io.json.JettisonMappedXmlDriver;classItemCollection{publicStringidentifier;publicCollection<Item>items=newArrayList<Item>();publicItemCollection(Stringidentifier){this.identifier=identifier;}publicbooleanadd(Itemarg0){returnitems.add(arg0);}}classItem{publicStringname;publicStringlabel;publicStringabbreviation;publicItem(Stringname,Stringlabel,Stringabbreviation){this.name=name;this.label=label;this.abbreviation=abbreviation;}}publicclassWriteXStreamDojoTest{publicstaticvoidmain(String[]args){ItemCollectionitemCollection=newItemCollection("abbreviation");itemCollection.add(newItem("Alaska","Alaska","AK"));itemCollection.add(newItem("Wyoming","Wyoming","WY"));XStreamxstream=newXStream(newJettisonMappedXmlDriver());StringerroneousJsonStr=xstream.toXML(itemCollection);System.out.println(erroneousJsonStr);}} resulted in the following JSON Output (i added some space and breaklines for readability):

Sep 26, 2007 - 1 minute read - Comments - bash clear clear.exe command cygwin first found installation linux ncurses not not-found time troubleshooting windows

bash: clear: command not found

If your are getting “bash: clear: command not found” on you first install of cygwin you have to make sure that you include ncurses packages in your cygwin installation. clear.exe doesn’t come in the standard installation. You must include ncurses to get clear.exe in your system. If you are using bash you can use Ctrl-L and get the same result though. UPDATE: ncurses is a cygwin package in libs category in Utils category.

Sep 6, 2007 - 1 minute read - Comments - bug compare contentMergeViewer eclipse formatting java patch screenshot viewer

Eclipse Bug #201116 update: Switch compare viewer for java files

I’ve submitted a patch (Attachment #77777 and a couple of screenshots ( Attachment #77774 y Attachment #77776) to Bug #201116. It’s only a preliminary work but it enables the user to select with contentMergeViewer to use with each FileType/ContentType. Now it’s only useful if you use my java formatting compare plugin. Currently the org.eclipse.compare subsystem will allow only one contentMergeViewer per fileType or contentType and you cannot tell which one it will be as Szymon Brandys comments.

Sep 6, 2007 - 1 minute read - Comments - http linux redirect redirectmatch root subfolder web

How to redirect your root web directory to a subfolder with .htaccess

If you tried (like me) to redirect your / (root) web directory to a subfolder (like /wp/) modifying .htaccess in this way: Redirect 301 / http://rubenlaguna.com/wp/ You probably found that it didn’t work. The browser will end up in an endless loop of redirections. Firefox will complain with this error message: The page isn't redirecting properly Firefox has detected that the server is redirecting the request for this address in a way that will never complete.