Zagura’s blog

July 13, 2010

Could not create the Java virtual machine. error adding brasil.gov.br/brasil.gov.br.crt

Filed under: Linux, Programming — puthre @ 2:23 pm

If you are getting these kind of errors when you try to install java on debian under a virtual machine, then you perhaps need to increase the available memory.

July 12, 2010

How to check packet loss for VOIP purposes

Filed under: English, Linux, voip — puthre @ 9:52 am

Yesterday I had some problems with the VOIP connection. I heard my party very well but he could barely hear me.
Normal run of mtr to the other host showed no packet loss but I was able to pinpoint the packet loss to the other party with
mtr -n -s 200 -i 0.02 [ip-address]
(you need to be root)
which sends 50 packets/seconds 200 bytes/packet which pretty much emulates the rtp stream.

April 30, 2010

acerhk - gcc: -pg and -fomit-frame-pointer are incompatible

Filed under: Uncategorized — puthre @ 10:57 pm

If you have problems compiling acerhk on the latest ubuntu distribution modify
/usr/src/`uname -r`/Makefile and comment :

ifdef CONFIG_FUNCTION_TRACER
#KBUILD_CFLAGS<->+= -pg
endif

Remove the comment after the successful compile so you leave the sources as they were.

March 19, 2010

SPL-C ERROR - Please use the proper driver on Samsung CLP-310N printer

Filed under: English, Linux — puthre @ 12:10 am

If you get this error written on the test page when using Ubuntu or any other Linux distribution, you should install the Samsung Unified Driver. I’ve followed the tutorial on http://ubuntuforums.org/showthread.php?t=341621 point II.c and then I’ve added the network printer as lpd:///PASSTHRU with Make and Model “Samsung CLP-310 Series (SPL-C)” (NOT Samsung CLP-310 Foomatic/foo2qpdl)

March 10, 2010

How to programmatically dump the threads list of a running java process in bash

Filed under: English, Java, Linux, Programming — puthre @ 4:43 pm

It seems that jdb cannot accept commands from command line, so we must use expect.
I created the following expect script dumpthreads
You can use it like:
dumpthreads java_process_pid

#!/usr/bin/expect
set pid [lindex $argv 0];
spawn jdb -connect sun.jvm.hotspot.jdi.SAPIDAttachingConnector:pid=$pid;
expect “>”;
send “threads\n”;
expect “>”;
send “quit\n”;

January 27, 2010

Midnight commander does not save the settings in Ubuntu

Filed under: English, Linux — puthre @ 2:34 pm

Today I encountered a strange problem with Midnight Commander 4.6.2 in Ubuntu. I wanted to change the default Ubuntu setting to use the internal edit. I actually like the mc internal editor and I want to use it. The problem was that the setting was not saved when I chosed “Save setup” even if a message “Setup saved to ~/.mc/ini” appeared. There was no ~/.mc folder. After I did
mkdir ~/.mc
everything worked as expected.
This seems to be a bug in mc.

January 13, 2010

Emtec S800 board picture

Filed under: English, Linux — puthre @ 11:39 am

Here is a picture of the internal board of my newly aquired Emtec S800 PVR. It works on Linux but Emtec was not so kind to provide the sources of the PVR application (there are some sources of an alternative OEM - Ellion available on the net). I needed to open the box to put a resistor at the internal fan because it was too noisy.
dsc_0806.JPG

October 13, 2009

How to convert DVD iso to avi using mplayer

Filed under: English, Linux — puthre @ 9:43 pm

Here is a python script to convert an .iso of a DVD to avi and to encode it using mpeg4. It is a slightly modified version of the script found at http://lists.mplayerhq.hu/pipermail/mplayer-users/2003-April/032226.html to work with newer versions of mplayer/mencoder.

Later edit:
It seems that mplayer/mencoder know to play/convert .iso files directly so we can do:
mencoder in.iso -o /dev/null -ovc xvid -xvidencopts pass=1:bitrate=800:threads=2 -oac copy
mencoder in.iso -o out.mpeg -ovc xvid -xvidencopts pass=2:bitrate=800:threads=2 -oac copy

September 24, 2009

Some 3d pictures I took around Rosia Montana and Piatra Corbului (red-cyan glasses needed)

Filed under: Pictures — puthre @ 7:28 pm

11_scaled.JPG10_scaled.JPG9_scaled.JPG8_scaled.JPG7_scaled.JPG
6_scaled.JPG5_scaled.JPG3_scaled.jpg2_scaled.jpg1_scaled.jpg

June 16, 2009

How to convince the SmartGWT ListGrid to automatically fetch from the server only the data it displays

Filed under: English, Java, Programming, Web — puthre @ 7:29 pm

Since I was looking all over the net how to do this and I only found pieces of information, here is an example:

JAVA:
  1. public class OperationsGrid extends ListGrid{
  2.     OperationsGrid(){
  3.         super();
  4.         TreeGridField accNoField = new TreeGridField("accountNo", 150);
  5.         TreeGridField commentField = new TreeGridField("comment"150);
  6.  
  7.         setFields(accNoField,commentField);
  8.         setHeight100();
  9.         setWidth100();
  10.         setAutoFetchData(true);
  11.         setAlternateRecordStyles(true);
  12.         setDataSource(OperationsDS.getInstance());
  13.         setShowFilterEditor(true);
  14.     }
  15. }

JAVA:
  1. public class OperationsDS extends DataSource{
  2.     static OperationsDS instance = null;
  3.      static OperationsDS getInstance(){
  4.         if(instance == null){
  5.             instance = new OperationsDS();
  6.         }
  7.          return instance;
  8.     }
  9.  
  10.     OperationsDS(){
  11.  
  12.         setDataURL(xpath);
  13.         DataSourceTextField noField = new DataSourceTextField("accountNo", "Account Number", 128);
  14.         DataSourceTextField commentField = new DataSourceTextField("comment", "Comment", 128);
  15.  
  16.         noField.setRequired(true);
  17.         noField.setPrimaryKey(true);
  18.  
  19.         setFields(noField,commentField);
  20.         setDataFormat(DSDataFormat.JSON);
  21.         setRecordXPath("response/result");
  22.         setClientOnly(false);
  23.     }
  24.      @Override
  25.      protected Object transformRequest(DSRequest dsRequest){
  26.          String url = null;
  27.  
  28.          if(dsRequest.getOperationType().equals(DSOperationType.FETCH)){
  29.              dsRequest.setActionURL(getDataURL()+"&start="+dsRequest.getStartRow()+"&end="+dsRequest.getEndRow());
  30.          }
  31.          return super.transformRequest(dsRequest);
  32.      }
  33.      @Override
  34.     protected void transformResponse(DSResponse response, DSRequest request,
  35.             Object data) {
  36.         DSOperationType operationType = request.getOperationType();
  37.  
  38.         if (operationType == DSOperationType.FETCH) {
  39.             JSONArray info = XMLTools.selectObjects(data, "/response/resultInfo/numTotalRows");
  40.             Integer total = (int)Math.round(info.get(0).isNumber().doubleValue());
  41.  
  42.             info = XMLTools.selectObjects(data, "/response/resultInfo/startRow");
  43.             Integer start = (int)Math.round(info.get(0).isNumber().doubleValue());
  44.  
  45.             info = XMLTools.selectObjects(data, "/response/resultInfo/endRow");
  46.             Integer end = (int)Math.round(info.get(0).isNumber().doubleValue());
  47.  
  48.             if(total != null)
  49.                 response.setTotalRows(total);
  50.             if(start != null)
  51.                 response.setStartRow(start);
  52.             if(end != null)
  53.                 response.setEndRow(end);
  54.         } else {
  55.             super.transformResponse(response, request, data);
  56.         }
  57.  
  58.     }
  59. }

In this example the server outputs in JSON format and returns the the current start row, current end row and total number of rows in response/resultInfo.
Basically you need to override transformRequest and transformResponse. In transformRequest you should add the start and end row to the requestURL and in transformResponse you should set the startRow, endRow, and totalRows, provided that you receive this information from your server. Also don't forget to setAutoFetchData(true) on the grid.

Hope this helps somebody.

Next Page »

Powered by WordPress