Posts belonging to Category Uncategorized



bugzilla

I wanted to try Bugzilla but these days I have little time to play with software and install look like it was going to take to long. After an easier install I was recomened to use a virtual machine. will try it with virtual box

http://www.turnkeylinux.org/bugzilla

Update: turnkeylinux is great. I tried bugzilla and Trac with VirtualBox and they just work. I wish i had seen this website before. they also have mysql virtual server

Zk GenericForwardComposer limit scope

After having a few problem with the scope of my spring beans for hours we found the answer here:

http://en.wikibooks.org/wiki/ZK/How-Tos/Integrate-Other-Frameworks

ZK gmaps – Failed to process rm e._area is undefined

While using zk gmaps/gmapz I could not find anything on the internet on why I was getting the error “Failed to process rm e._area is undefined” so if you are having this problem here is the solution. When you create Gmarker set the “maxzoom” to zero.

Gmarker marker = new Gmarker();
marker.setMaxzoom(0);

 

ZK – Communicating with the server

Using Javascript instead of zscript  to calculate a value means you don’t have to communicate with the server until necessary but how do you send data back to the server? I could not find a complete answer so here is my answer below:

In your zul page you will need a textbox (hidden if you want)

<textbox id="serverComm" class="serverComm"></textbox>

Your Javascript put something like this to trigger event

    zk.Widget.$($(".serverComm")).setValue("value to send");
    wid = zk.Widget.$($(".serverComm"));
    zAu.send(new zk.Event(wid, 'onUser', location));

In your “GenericForwardComposer” you need to listen for the event:

	Textbox serverComm;
	public void onUser$serverComm(Event event) throws Exception {
		Event eventx = Events.getRealOrigin((ForwardEvent)event);
		String test = eventx.getData().toString();
		System.out.println(test);
	}

So you don’t make the same mistakes I made:

  • don’t make your on event like “onMyEvent” I think  “onUser” is an event made just for this.
  • I tried sending value without the textbox but it just did not work.

 

GeoLocation using Google API

I been trying to get the users GEO-location so I can pre-fill one of the questions with the users country. This code did the trick

the HTML:

<script type="text/javascript" src="http://www.google.com/jsapi?key=ABQIAAAA-O3c-Om9OcvXMOJXreXHAxQGj0PqsCtxKvarsoS-iqLdqZSKfxS27kJqGZajBjvuzOBLizi931BUow"></script>
<script type="text/javascript" src="/js/geoIP.js" ></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<div class="countryDiv"/>
	<input>
</div>

 

 

the Script:

google.load("maps", "2", {callback: initialize});

  function initialize() {

    // Initialize default values
    var latlng = new google.maps.LatLng(37.4419, -100.1419);
    var location = "";

    // If ClientLocation was filled in by the loader, use that info instead
    if (google.loader.ClientLocation) {
      latlng = new google.maps.LatLng(google.loader.ClientLocation.latitude, google.loader.ClientLocation.longitude);
      location = "" + getFormattedLocation() + "";
    }
   	alert(location);
   	$(".countryDiv input").val(""+location);
  }

  function getFormattedLocation() {

	  return google.loader.ClientLocation.address.country;
  }

 

 

Amazon web services

Amazon web services looks very complicated at first but this document really helps to explain the different products they have.

http://media.amazonwebservices.com/AWS_Storage_Options.pdf

Amazon EC2 asecurity

Amazon EC2 cloud allow root access to the Instance over ssh.  This is a Bad Idea. To secure your Instance and give you a more secure method to access it:

  1. Log into your Instance
  2. Add yourself a local account, make sure to add this account to the wheel group:
    # useradd -G wheel account
  3. Set the password for the new account:
    # passwd account
  4. Edit the /etc/sudoers file to allow your new account to perform commands:
    # visudo
  5. Remove the comment from the following line in sudoers, I do the second line so I don’t have to use a password every time:
    ## Allows people in group wheel to run all commands
    # %wheel        ALL=(ALL)       ALL
    ## Same thing without a password
    %wheel  ALL=(ALL)       NOPASSWD: ALL

After you’ve edited the /etc/sudoers file, perform these steps on your Amazon EC2 Instance:

  1. Change to your new account’s home directory:
    cd /home/account
  2. Create a .ssh directory:
    mkdir .ssh
  3. Copy the authorized_keys file from root to your new account:
    cp /root/.ssh/authorized_keys .ssh
  4. Set the proper permissions on the .ssh directory and its contents:
    chown -R account:account .ssh

You can now access your Amazon EC2 account using your Private Key.

 

taken from: http://robpickering.com/2010/08/battle-of-the-clouds-rackspacecloud-vs-amazon-ec2-247

 

 

Amazon web services – tomcat and mysql

I just got an account with Amazon web services and I hope to get tomcat and mysql running sometime in the near future.

sudo apt-get install mysql-server tomcat6

That’s really as complicated as it gets. Depending on how you do your webapp deployment, you’ll want to install tomcat6-admin

this is what i think i have to do:

sudo apt-get install tomcat6-admin

Config files can be found in

/etc/mysql
/etc/tomcat6
/etc/default/tomcat6.

Start and stop servers using

/etc/init.d/tomcat6 start|stop
/etc/init.d/mysql start|stop

*http://stackoverflow.com/questions/5334989/installing-tomcat-6-and-mysql-server-on-ubuntu-ec2-instance

Java print date (calendar) dd/MM/yyyy

This code is very simple but when I need it I always forget how to do it and i spend to long searching for it.

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.GregorianCalendar;

import org.junit.Test;

public class ManualOverrideProcessImplTest  {

	@Test
    public void test1() {
		Calendar today = new GregorianCalendar();

		SimpleDateFormat df = new SimpleDateFormat();
		df.applyPattern("dd/MM/yyyy");
        System.out.println(df.format(today.getTime()));
	}

}

Also it is very easy to create a static String but a Date takes a little more work

    public static final Date END_DATE;
    static{
    	DateFormat format = new SimpleDateFormat("yyyy-MM-dd");
    	try {
			END_DATE = (Date)format.parse("9999-12-31");
		} catch (ParseException e) {
			throw new RuntimeException(e);
		}
    }

END

Java for both 32-bit and 64-bit

I wish I known this before:

“Java for both 32-bit and 64-bit IE browsers.
If you use both 32-bit and 64-bit browser interchangeably, you need a Java Plug-in for each browser. Hence you will need to install both 32-bit and 64-bit Java respectively.”1

1) http://www.java.com/en/download/faq/java_win64bit.xml