Thursday, February 18, 2010

Can You Get Cancer From A Purple Nurple

My life with VW Sedan (Beetle)

Here in my country in the last century and the beginning of this produced the vw vw sedan known as "beetle", the truth most of us in Mexico have one or had one. As I change jobs and do not want to go by bus because it's like about 1hr from my house near to the airport at CU where I work, my dad made me the great favor to lend the Porsche this is how I call love is a combination of porsche and Beetle, according to the story Hitler entrusted the task of designing a car for the German middle class were characteristics that did not use the radiator and winter weather that cars were not working well, the idea was to create a turbine engine oil cool, great idea, to run at about 100km/hr, which recently spent fuel, porsche design based on these characteristics.

Everything was great until Porsche started derrepente accelerate as the devil, and the noise was annoying and the worst happened, I told my dad I'd better save for a decent car but because that vw sedan and gave the last ( good at that moment was ignorant as to the blanketing of cars), my dad said it's just the valve (as good as the VW sedan is full injection), well that part so sucsiona entediando air from the filter to the part carburetor appears but is not, since in this model who is responsible for sending the gasified fuel injectors are, just save and buy it costs about $ 1 300 approx (MN), and buy it tires and it is also, but like any good son said no and gave the last Beetle, so I went to used cars and see their prices, I wanted a ford ka, but the truth is something inside me made me think and if I have to invest only about $ 3500 a Beetle and it works fine, but he said maybe a car a little more recent, but I remembered all the times I've lived so happy with this car:

- We went to Oaxaca, was the father trip (It was another Beetle that I have not actually).
"My father has been taken as 40 veses approximately Guerrero since we bought it and had not failed.
- So many talks with my Papa and Mama in travel.
- We went to Cuernavaca (4 veses) and all of wonder though I lost in the hills of tepozteco in Tepoztlan, and my Mom I was looking up to the police.
- A worked as truck and taxi for friends.
- was the first car that I kiss my girlfriend
- was the first car I had to send for repair after a crash but remained well.
- Always have a cheerful face. "The first car I learned to drive from the 12 0 14.
-I with a small town near the volcano is called peñuela, when I feel happy or sad, has always been by my side. I
-girlfriend's house to Ixtlahuaca. For all this and more would not trade it for anything, I hope and lasting a long time I decided to invest as I told my dad and I look great. Thanks Beetle for being with me.









Wednesday, February 17, 2010

How Do U Put Your Hair Like Dahvie Vanity

List Sort items in Java with java Collections.sort

Hi

All we ever bumped to order items from a list of java (java.util.List) I know many will say that it could do with the database adding an order by campo_de_tbl, but many applications do not require it and to do this deal java.util.Comparator.

Step 1. Create a bean, for practical purposes all the attributes are String: public class Concept



{private String id;
cve private String;
private String description;
private String value;
getValor
public String () { return value; } public void setValor (String value) { this.valor = value;} public String getId () {return id } public void setId (String id) {this.id = id
;}

getCve public String () {return
cve;
} public void
setCve (String cve) {
this.cve = cve;

} public String getDescription () {
return description;}
public void
setDescripcion (String description) {
this.descripcion = description;}






} Suppose we want to sort our data from our List Through The cve attribute.

Step 2. Create the class that implements the interface ConceptoComparator
Comparator
import java.util.Comparator;


ConceptoComparator public class implements Comparator {public int

compare (Object arg0, Object arg1) {
Concept withA = (Concept) arg0;
Concept with b = (Concept) arg1;

Long cveConA = Long.parseLong (conA. getCve ());
Long cveConB = Long.parseLong (conB.getCve ());

if (cveConA
return -1;


else if (cveConA> cveConB)
return 1;


return 0;
/ / TODO Auto-generated method stub}





} java.util.Comparator int compare (T a, T b) compares two objects and gives a negative value if a comes before b, zero if they are considered identical in ranking order, and a positive value if a comes after b .

Step 3: call (...) method

List Collections.sort

concepts = new ArrayList ();
Concept
con1 = new Concept (); < cveConB)
con1.setCve ("10017");

CON2 concept = new Concept ();
con2.setCve ("20001");
Concept
con3 = new Concept ();
con3.setCve ("10001");

conceptos.add (con1);
conceptos.add (CON2);
conceptos.add (Con 3);
System.out.println ("unsorted");

for (Concept with: concepts) {
System.out.println ("" + with . getCve ());}


Collections.sort (concepts, new ConceptoComparator ());
System.out.println ("sorted"); for (Concept with: concepts) {System.out.println
("" + con.getCve ());}



the result will be something like this:
unordered

20001 10017 10001

sorted
10001 10017

20001


Tuesday, February 2, 2010

Georgia Potbelly Pigs

Md5 (java.security.MessageDigest)

Hello here I put a code that was looking for some time occupying the API (java.security.MessageDigest) of java to encrypt a string.

---------------------- import


java.security.MessageDigest;
java.security.NoSuchAlgorithmException import;

{public class Md5

private MessageDigest alg;
private String md5;


/ **

* * @ param message * @ throws NoSuchAlgorithmException

* / public void

md5 (String message) throws NoSuchAlgorithmException { computeDigest (bytes);
} public String


getMd5 () {return md5
;
} public void


setMd5 (String md5) {
this.md5 = md5;

} / ** * Performs
digestion
MD5 algorithm * @ param bytes
* / public void

computeDigest (byte [] bytes) {
String str = "";
alg. ();// reset restores the summary
alg.update (bytes) / / update the summary, using the specified
bytes byte [] hash = Alg.digest ();// complete the calculation of dispersive
code for (int i = 0; i
int v = hash [i] & 0xFF;
if (v
cad + = Integer.toString (v, 16). toUpperCase ()+"";
}

this.setMd5 (CAD);

}}



--------------------- -------------------------------

The way to take the class would be:

Md5 md5 = new Md5 ();
md5.md5 ("Hello World");
md5String = md5.getMd5 String ();
System.out.print ("md5" + md5String)


Monday, February 1, 2010

Magic Tilt Trailer Vin Label

CPR GWT (gwt-ext Netbeans)

Hi
< hash.length;i++){
entry is required for this pre-configured with a gwt project in Netbeans and configured in plugin gwt-ext (jar).
< 16) cad+="0";
First I would like to talk about the advantages of GWT and then talk about the disadvantages.

- Everything Back End
programs
, which means you do not necessarily have to learn html, css, javascript, java just have to know the

Front End Back End programs as it sounds so strange is, the gwt compiler is responsible for generating an optimal code in js for your application.

- The way to make asynchronous requests are made quickly through RCP.

- The learning curve is quick.

- The applications run in most browsers (IE, Firefox).

Well after this brief introduction we will create an application that give users a CRUD

.




For our example we must create our model and view package level: org.aplication.client where is all in code that turns into Front End. After
create a class User call within the package org.aplication.client.modelo


Create a class named User.

org.aplication.client.modelo package;
import
com.google.gwt.user.client.rpc.IsSerializable;
/ ** * * @ author Isaac

* / public class User implements
IsSerializable {

private String name; private String name; private int age;

cve private int;
getApellido
public String () {return name
;
} public void
setApellido (String name) { this.apellido = surname; } public int

getCve ()
cve {return;}


setCve public void (int cve) {
this.cve = cve;
} public int

getEdad () {return
age
} public void

SETEDER (int age) {
this.edad = age;


} public String getName () {return name
;
} public void

setNombre (String name) {this.name = name
;




}}

This gwt class implements IsSerializable of that is the charge to serialize our class and allows communication between a client and server.

Step 2. Create a package named view (org.aplication.client.view) and a class called GuiUsuario, Uml class diagram for this class will be more or less like this but then we will be adding more methods or classes.






Well first we create our form and then our rcp.


org.aplication.client.view package;
import
com.gwtext.client.core.EventObject;
com.gwtext.client.core.Position import, import
com.gwtext.client.widgets.Button;
com.gwtext.client.widgets.MessageBox import, import
com.gwtext.client.widgets.Window;
com.gwtext.client.widgets.event.ButtonListenerAdapter import, import
com.gwtext.client.widgets.form.FormPanel ;
com.gwtext.client.widgets.form.TextField import; Import
org.aplication.client.modelo.Usuario;

/ **
* * @ author Isaac

* / public class
GuiUsuario {private User user; private Window window;
FormPanel formPanel private, private
TextField name;
private TextField name;
private TextField age
public

FormPanel getFormPanel () {


FormPanel formPanel = new ();


formPanel.setFrame (true);


formPanel.setTitle ( User ");


name = new TextField (" Name "," name ", 230);


name = new TextField (" Name " "Name", 230);


age = new TextField ("age" and "age", 230);


formPanel.add (name);
formPanel.add (last)
formPanel . add (age);
formPanel
return;}

public getUsuario User () {return
user; } public Window
GetWindow () {
window = new Window () ;
window.setTitle ("Layout Window");
window.setClosable (true);
window.setWidth (600);
window.setHeight (350);


window.setPlain (true);

window.setCloseAction (Window.HIDE) window.add (getFormPanel ());

buttonNewUser =
Button new Button ("New User");
buttonNewUser.addListener (new ButtonListenerAdapter () {

@ Override public void onClick (Button button, EventObject e) {
MessageBox.alert ("test event ");

}}
)
window.setButtonAlign (Position.CENTER)
window.addButton (buttonNewUser)
return window;
} public void setUsuario (User user) { this.usuario = user;


}}
The method GetWindow () is responsible for creating the window and also to create the FormPanel through getFormPanel method (), then just need to call our Gui since it will be the class EntryPoint MainEntryPoint that is in the package org.aplication. client.
org.aplication.client package; com.google.gwt.core.client.EntryPoint import, import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.Widget;
import com.google.gwt.user.client.ui.ClickListener;
import com.gwtext.client.widgets.Window;
import org.aplication.client.view.GuiUsuario;

/**
* Main entry point.
*
* @author isaac */ public class MainEntryPoint implements EntryPoint { /** * Creates a new instance of MainEntryPoint */
public MainEntryPoint() {
}
/** * The entry point method, called automatically by loading a module
* that declares an implementing class as an entry-point
*/
public void onModuleLoad () {final

Button button = new Button ("Click me!");

button.addClickListener (new clickListener () {public void
onClick (Widget w) {
GuiUsuario GuiUsuario guiUsuario = new ();
winUsu = guiUsuario.getWindow Window ();
winUsu.show ();

}});

RootPanel.get (). add (button);


}}






winUsu.show ();

This method makes the Window class window is displayed on the client browser.

Depues we run a project and we should have something like this.






Step 3. We create the CPR right-click on new / other depues gwt option appears and a list where this gwtrcp we click and then we ask in the name of the service package where we will put it.





Serbian creation: We'll call and you should be GWTServiceUser org.aplication.client.servicio
package

Then we have a structure like the following:


A gwt needs rcp 3 main classes and mapping in the web.xml you already do by default netbeans assistant.
within the package
org.aplication.client.servicio - interface GWTServiceUserAsync GWTServiceUser -interface and server side in the package this class org.aplication.server.servicio:
-class
GWTServiceUserImpl
The class diagram for the creation of users from client to server is:

The code for each class is: package
org.aplication.client.servicio; com.google.gwt.user.client.rpc.RemoteService import, import
com.google.gwt.user. client.rpc.RemoteServiceRelativePath;
org.aplication.client.modelo.Usuario import; / ** * * @ author Isaac

* /
@ RemoteServiceRelativePath ("service / gwtserviceuser)
public interface extends GWTServiceUser
RemoteService {public String newuser (User user);}


---------------

org.aplication.client.servicio package;
import com. google.gwt.user.client.rpc.AsyncCallback; org.aplication.client.modelo.Usuario import;
/ **
* * @ author Isaac

* / public interface

GWTServiceUserAsync {public void newuser (User user, AsyncCallback callback);}




-------------------------------------- org.aplication.server.servicio package;
com.google.gwt.user.server.rpc.RemoteServiceServlet
import, import

java.util.AbstractList;
import java.util.ArrayList;
import java.util.List;
org.aplication.client.modelo.Usuario import, import
org.aplication.client.servicio.GWTServiceUser;

/ ** * @
*
author isaac
* /


public class GWTServiceUserImpl extends RemoteServiceServlet implements GWTServiceUser {

private static List
users = null;
private static int contCve = 0;

public String newuser (User user) {
contCve + +;
user. setCve (contCve)

if (users == null) {


users = new ArrayList ();
usuarios.add (user)


usuarios.add} else (user);

for (User u: users) {
System.out.println ("user" + u.getNombre ());}


return "has been created user "}






} ------------------------------------- ------------------------


org.aplication.client.view package;
import com.google.gwt.core.client.GWT ;
com.google.gwt.user.client.rpc.AsyncCallback import, import
com.google.gwt.user.client.rpc.ServiceDefTarget;
com.gwtext.client.core.EventObject import, import
com.gwtext . client.core.Position;
import com.gwtext.client.widgets.Button;
com.gwtext.client.widgets.MessageBox import, import
com.gwtext.client.widgets.Window;
com.gwtext.client.widgets.event.ButtonListenerAdapter import, import
com.gwtext.client.widgets.form.FormPanel;
com.gwtext.client.widgets.form.TextField import, import
org.aplication.client.modelo.Usuario;
org.aplication.client.servicio.GWTServiceUser import; import
org.aplication.client.servicio.GWTServiceUserAsync;

/ **
* * @ author Isaac

* / public class


GuiUsuario {private User user;
private Window window;
FormPanel formPanel private, private
TextField name;
private TextField name;
private TextField age
GWTServiceUserAsync private static service;
public
FormPanel getFormPanel () {


FormPanel formPanel = new ();
formPanel.setFrame (true);
formPanel.setTitle (User) ;
name = new TextField ("Name", "name", 230);
name = new TextField ("Name", "name", 230);
age = new TextField ("age" and "age", 230 )
formPanel.add (name);
formPanel.add (last)
formPanel.add (age);
formPanel

return;}

User public
getUsuario () {return
user;
} public Window

GetWindow () {

window = new Window ();
window.setTitle ("Layout Window");
window.setClosable (true);
window.setWidth (600);
window.setHeight (350);
window.setPlain (true);
window.setCloseAction (Window.HIDE)
window.add (getFormPanel ());

buttonNewUser = new Button Button ("New User");
buttonNewUser.addListener (new ButtonListenerAdapter () {


@ Override public void onClick (Button button, EventObject e) {
User u = new User ();
u.setEdad (Integer.parseInt (edad.getText ()));
u.setNombre (nombre.getText ());
u.setApellido (last . getText ());

insertaUsuario (u);



}}
)


window.setButtonAlign (Position.CENTER)
window.addButton (buttonNewUser)



return window;
} public void

setUsuario (User user) {
this.usuario = user;




} public void insertaUsuario (User user) {


/ / Create an asynchronous callback to handle the result.
final AsyncCallback callback = new AsyncCallback () {public void

onSuccess (Object result) {
String response = (String) result;

MessageBox.alert (response);

} public void

onFailure (Throwable caught) {
MessageBox.alert ("Error" + caught);

}};

getService (). newuser (username, callback);



} public static
GWTServiceUserAsync getService () {
service = (GWTServiceUserAsync) GWT.create (GWTServiceUser.class) ServiceDefTarget
endpoint = (ServiceDefTarget) service;
moduleRelativeURL = GWT.getModuleBaseURL String () + "service / gwtserviceuser"
endpoint.setServiceEntryPoint (moduleRelativeURL )
return service;}




}

----------------------------------- -----

- The important part that we understand the gwt rcp is that we can send beans from customers to our server clearly without needing to take
request.

The menera that this is done is right through the following method GuiUsuario

class.


GWTServiceUserAsync public static getService () {


service = (GWTServiceUserAsync) GWT.create (GWTServiceUser.class)


ServiceDefTarget endpoint = (ServiceDefTarget) service;


moduleRelativeURL = GWT.getModuleBaseURL String () + "service / gwtserviceuser"


endpoint.setServiceEntryPoint (moduleRelativeURL)


return service;}



and occupy the following method call within the same class: public void
insertaUsuario (User user ) {
/ / Create an asynchronous callback to handle the result. final AsyncCallback callback = new AsyncCallback () {public void onSuccess (Object result) {
String response = (String) result; MessageBox.alert (response);
} public void
onFailure (Throwable caught) { MessageBox.alert ("Error" + caught);
}}; getService (). newuser (username, callback);}

When you execute this method directly call method getService () which has a method called newuser which we send as a parameter the user and his task callback will be receiving the response from the server rcp here GWTServiceUserImpl class to override the newuser that is where we create the list and insert elements it and it responds with the message return "Created user" which is received by the callback in:

public void onSuccess (Object result) {
String response = (String) result;

MessageBox.alert (response )
.
.
.

Finally we need the event the GuiUsuario button to create the user and call the

insertaUsuario ButtonNewUser Button = new Button ("New User");
buttonNewUser.addListener (new ButtonListenerAdapter () {


@ Override public void onClick (Button button, EventObject e) {
User u = new User ();
u. SETEDER (Integer.parseInt (edad.getText ()));
u.setNombre (nombre.getText ());
u.setApellido (apellido.getText ());

insertaUsuario (u);}




});



After we run the project and our application is ready to create users I put a static list of users but it can be inserted into a database with jdbc or hibernate.









Well that's it then create a grid ....

Dedicated to my little princess.



Part