venerdì 17 settembre 2010

openXReports broken on OpenX v.2.8.5

If you get this error generating Campaign Delivery Report on OpenX:

 Fatal error: Class 'DataObjects_Campaigns' not found in /var/www/openx/plugins/reports/oxReportsStandard/liveCampaignDeliveryReport.class.php on line 251  

You can repair it adding the red line below on OPENX_PATH/plugins/reports/oxReportsStandard/liveCampaignDeliveryReport.class.php:

 .  
 .  
 .  
 require_once LIB_PATH . '/Extension/reports/ReportsScope.php';  
 require_once MAX_PATH . '/lib/OA/Dll.php';  
 require_once MAX_PATH . '/lib/max/Dal/DataObjects/Campaigns.php';  
 /**  
  * A plugin to generate a report showing conversion tracking information,  
  * for the supplied date range. The report contains a single worksheet:  
  *  
 .  
 .  
 .  

martedì 14 settembre 2010

Google Maps Suggestion with YUI Library Example

This is an example of use Google Maps Suggestion, api version 3, in your site using YUI library.
The main problem was about to connect the query of ScriptNodeDataSource with his handler response, infact the callback that google maps returns not allow in his name the square bracket...
To test you can use wget. The first one is how google like callback name:


[dometec@precision2 tmp]$ wget -q -O - "http://www.google.com/maps/suggest?cp=20&hl=it&num=5&q=sapr&callback=callback" && echo
callback&&callback({suggestion:[{query:"Sapri, Italia",interpretation:{term:[{start:0,.......


The second one is how yui's ScriptNodeDataSource object named callback parameter:

[dometec@precision2 tmp]$ wget -q -O - "http://www.google.com/maps/suggest?cp=20&hl=it&num=5&q=sapr&callback=callback[1]" && echo
{suggestion:[{query:"Sapri, Italia",interpretation:{term:[{start:0,end:5,fea.............

In the last call the callback parameter in the response is absent, evaporated! :S
The "patch" is to overwrite the generateRequestCallback of ScriptNodeDataSource object to set an appropriate name and write your own callback function that refresh the AutoComplete widget.



dsScriptNode.generateRequestCallback = function () { return "&callback=callbackGMapsSuggestion"; };
...
callbackGMapsSuggestion = function (queryResult) {
  var r = {};
  r.results = queryResult.suggestion;
  //oAC is the instance of YUI AutoComplete widget
  oAC.handleResponse(null, r, null);
};


The complete HTML Test Page http://dev.zonablog.net/mapsuggestion.html:
 <html>  
      <head>  
           <title>Google Maps Suggestion with YUI Library Example</title>  
           <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">  
           <link type="text/css" rel="stylesheet" href="http://yui.yahooapis.com/2.8.1/build/logger/assets/skins/sam/logger.css">  
           <link type="text/css" rel="stylesheet" href="http://yui.yahooapis.com/2.8.1/build/fonts/fonts-min.css" />  
           <link type="text/css" rel="stylesheet" href="http://yui.yahooapis.com/2.8.1/build/autocomplete/assets/skins/sam/autocomplete.css" />  
           <script type="text/javascript" src="http://yui.yahooapis.com/2.8.1/build/yahoo-dom-event/yahoo-dom-event.js"></script>  
           <script type="text/javascript" src="http://yui.yahooapis.com/2.8.1/build/dragdrop/dragdrop-min.js"></script>  
           <script type="text/javascript" src="http://yui.yahooapis.com/2.8.1/build/json/json-min.js"></script>  
           <script type="text/javascript" src="http://yui.yahooapis.com/2.8.1/build/connection/connection-min.js"></script>  
           <script type="text/javascript" src="http://yui.yahooapis.com/2.8.1/build/get/get-min.js"></script>  
           <script type="text/javascript" src="http://yui.yahooapis.com/2.8.1/build/animation/animation-min.js"></script>  
           <script type="text/javascript" src="http://yui.yahooapis.com/2.8.1/build/datasource/datasource-min.js"></script>  
           <script type="text/javascript" src="http://yui.yahooapis.com/2.8.1/build/autocomplete/autocomplete-min.js"></script>  
           <style type="text/css">  
                #myAutoComplete {  
                  width: 15em;  
                  padding-bottom: 2em;  
                }  
           </style>  
           <script type="text/javascript">  
                var dsScriptNode;  
                var oAC;  
                function init() {  
                     dsScriptNode = new YAHOO.util.ScriptNodeDataSource("http://www.google.com/maps/suggest?cp=20&hl=it&num=5&&");  
                     dsScriptNode.generateRequestCallback = function () { return "&callback=callbackGMapsSuggestion"; };  
                     dsScriptNode.responseSchema = { fields: ["query"] };  
                  oAC = new YAHOO.widget.AutoComplete("myInput", "myContainer", dsScriptNode);  
                  oAC.prehighlightClassName = "yui-ac-prehighlight";  
                  oAC.useShadow = true;  
                  oAC.generateRequest = function (sQuery) { return "q=" + sQuery; };  
                };  
                callbackGMapsSuggestion = function (queryResult) {  
                     var r = {};  
                     r.results = queryResult.suggestion;  
                     oAC.handleResponse(null, r, null);  
                };  
                YAHOO.util.Event.onDOMReady(init);  
           </script>  
      </head>  
      <body class="yui-skin-sam">  
           <h1>Google Maps Suggestion with YUI Library Example</h1>  
           <label for="myInput">Enter a location:</label>  
           <div id="myAutoComplete">  
                <input id="myInput" type="text">  
                <div id="myContainer"></div>  
           </div>  
      </body>  
 </html>  

Enjoy :)

martedì 7 settembre 2010

Merge PDF File with Ghostscript

Use this command to merge PDF fil using Ghostscript:

 $ gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile=Merged.pdf 1.pdf 2.pdf 3.pdf 

sabato 4 settembre 2010

MySql and watch for data changes from shell

This is an useful command that I use where I need to watch data changes in a mysql table:


 watch -n 1 "echo \"select * from fnbl_user;\" | mysql --password=yourpassword --database=funambol"
I use the feauture of mysql client program that accept statements from standard input.
This command execute the select query from the specified table every second.

venerdì 3 settembre 2010

The magic Java Remote Debug string

When you have to debug an application with your prefered editor (like Eclipse :)), you can launch the java application with this string, don't worry if it is in local host or remote host:

 java ... -Xrunjdwp:transport=dt_socket,address=20118,server=y,suspend=n ...

and connect to server for debugging on port specified in address parameter.

The transport parameter specify what type of communication you are using to connect to the server, if you specify dt_socket, you have to set the server parameter to y. The JVM will stay listening on all network interface of server.

The last parameter (suspend) tell to the JVM if it have to wait the first connection from your IDE before start (y) or not (n).