I and my friends have received invitation from seemly friendly email from friend email to join them such as the "Desk Top Dating".
When you receive the email, delete it immediately and do not follow through it. This is a trap!
Generally, for any email/web site asking for login/password for another email account, don't follow through that and delete that email unless you know you are giving information to a well trusted email service such as google. Otherwise, you are in danger of exposing your complete email contact list to an unknown user/web site.
For example the mentioned "Desktop Dating" email, this is what the hacker site was doing:
1. in the email it ask you to input your email id (for example yahoo) and password,
2. the "desktop dating" site could use your yahoo email id and password and login to your email account and (don't be fooled by the encryption of the password that shows on the page)
3. read your emails and
4. fetch all your email contact and send the chain email to all your contacts.
5. The cycle continues back to step 1 for all your contacts and their contacts again and again unless you stop it from step 1.
If you already input your email id /password to site like that, change your password now, inform your friends do not open that email from you etc.
Wednesday, October 28, 2009
Sunday, October 25, 2009
Use GSON to access json response in grails action
Communicate with external service through gson
1. download gson package and extract the jar into lib directory
http://code.google.com/p/google-gson/
2. grails action
def fetch={
def data
def reader
try {
URL url = new URL("http://localhost:8080/controller/action");
reader = new BufferedReader(new InputStreamReader(url.openStream()));
JsonParser jp = new JsonParser()
JsonElement je = jp.parse(reader)
data = je.getAt("data");
reader.close()
} catch (MalformedURLException e) {
// ...
} catch (IOException e) {
// ...
} finally {
reader.close()
}
render data;
}
1. download gson package and extract the jar into lib directory
http://code.google.com/p/google-gson/
2. grails action
def fetch={
def data
def reader
try {
URL url = new URL("http://localhost:8080/controller/action");
reader = new BufferedReader(new InputStreamReader(url.openStream()));
JsonParser jp = new JsonParser()
JsonElement je = jp.parse(reader)
data = je.getAt("data");
reader.close()
} catch (MalformedURLException e) {
// ...
} catch (IOException e) {
// ...
} finally {
reader.close()
}
render data;
}
Saturday, October 24, 2009
Create google wave robot from grails
1. use grails 1.1.1 (1.2.M3 does not work yet!!!)
2. create a grail project gswordwave
grails create-app gswordwave
3. uninstall hiberante
grails uninstall-plugin hibernate
4. install app engine plugin, selected jdo ( default)
grails install-plugin app-engine
5. run the app with this command:
grails app-engine
6. kill it
7. do initial deployment and make sure it works without wave stuff
8. download the google wave client jars from
2. create a grail project gswordwave
grails create-app gswordwave
3. uninstall hiberante
grails uninstall-plugin hibernate
4. install app engine plugin, selected jdo ( default)
grails install-plugin app-engine
5. run the app with this command:
grails app-engine
6. kill it
7. do initial deployment and make sure it works without wave stuff
- Register your application on appengine site. gswordwave
- grails set-version 1
- grails app-engine package
- %APP-ENGINE-HOME%/bin/appcfg.cmd update ./target/war
8. download the google wave client jars from
- http://code.google.com/p/wave-robot-java-client/downloads/list and copy all the wave client jar to the lib directory in the grails root dir, also download servlet.api.2.5.jar into lib
- mkdir src/java/parroty/server
- copy http://code.google.com/apis/wave/extensions/robots/java-tutorial.html src/parroty/ParrotyServlet.java into the above directory src/java/parroty/server and name it ParrotyServlet.java and update the package to parroty.server.
- Make a web-app/_wave dir. Create in it a capabilties.xml file and copy paste the code
<?xml version="1.0" encoding="utf-8"?>
<w:robot w="http://wave.google.com/extensions/robots/1.0">
<w:capabilities>
<w:capability name="WAVELET_PARTICIPANTS_CHANGED" content="true">
</w:capability>
<w:version>1</w:version>
</w:capabilities>
</w:robot></pre>
9. In your appengine-web.xml (mine is in
c:\users\yiguang\.grails\1.1.1\projects\gswordbible\stage)file
you will find your application id is there already(mine, "gswordwave").
<appengine-web-app xmlns="http://appengine.google.com/ns/1.0">
<application>gswordwave</application>
<version>0.1</version>
<sessions-enabled>true</sessions-enabled>
<ssl-enabled>true</ssl-enabled>
<system-properties>
</system-properties>
</appengine-web-app>
10. add your ParrotyServlet config into src\templates\war\web.xml :
<servlet>
<servlet-name>Parroty</servlet-name>
<servlet-class>parroty.server.ParrotyServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Parroty</servlet-name>
<url-pattern>/_wave/robot/jsonrpc</url-pattern>
</servlet-mapping>
11. do redeployment
- grails app-engine package
- %APP-ENGINE-HOME%/bin/appcfg.cmd update ./target/war
12. check it out
http://gswordwave.appspot.com/_wave/capabilities.xml
13. goto your wave account and add gswordwave@appsport.com onto
your contact list and start to communicate with it
Wednesday, October 21, 2009
Pintout Unicode of a String
I don't use this often but I run into the problem occasionally. For example an special character in a text from database broken XML when it is put into xml. The problem is I don't know what character is doing it. So I need to find the unicode and replace it.
This is how to do it:
def thatString="sdsdsd sd fsd fsd fsd fsd fsd s ->s sd fsdf sdf "
that.toCharArray().each{ch->
printf("%04X%n", (int)ch);
}
This will printout all the unicode of the string
This is how to do it:
def thatString="sdsdsd sd fsd fsd fsd fsd fsd s ->s sd fsdf sdf "
that.toCharArray().each{ch->
printf("%04X%n", (int)ch);
}
This will printout all the unicode of the string
Subscribe to:
Posts (Atom)