Some good resources for learning and fun. This is the place to gather.

210 views
Skip to first unread message

Seabook

unread,
Aug 30, 2011, 8:16:26 PM8/30/11
to happy-pr...@googlegroups.com
Hey buddies,
While you learning something, you always eager to find a good book to start with. It's even better to find a video tutorial.
I remember when I was learning Java, I BTed a lot of video materials from the internet to start with. And when I started to learn Objective-C, I got the free video Tutorial from Stanford. And always google this and google that for the new info.

So I would like to centralize a place to put good material links here, which could be easily accessible for every one. And later on I may organize the materials in Category.

I just found a good place to learn various programming skills, hope you guys enjoy it.
Google University, awesome place to learn. Thanks Google again, you are almighty god in my heart.
http://code.google.com/edu/

A good place to do online Coding and algorithm
http://codingbat.com/
TopCoder
http://www.topcoder.com

Thanks,
Seabook
Message has been deleted

Seabook

unread,
Sep 13, 2011, 9:19:55 AM9/13/11
to happy-pr...@googlegroups.com
Actually I was reading some Javascript books these days and come across to this guy's personal website.
And I found http://www.khanacademy.org/, which is an amazing site with all the free tutorial videos for all different subjects math, finance, accounting etc etc.

Hope you guys enjoy learning.

Seabook

unread,
Oct 11, 2011, 11:50:13 PM10/11/11
to happy-pr...@googlegroups.com
A good javascript book I am reading.
Share with you guys: http://eloquentjavascript.net/index.html
and a good site for playing around html, css, javascript.
http://jsfiddle.net/

Happy Coding,
Seabook

Seabook

unread,
Feb 19, 2012, 8:07:09 PM2/19/12
to happy-pr...@googlegroups.com
My India colleague told me that a good website.
http://www.techgig.com/codecontest/practice
I hadn't got a time look around yet, but I think it's at least a good exercises resource. As usual, share to all of you guys.

Also, I heard the website helps India IT Company to find the talents, so if you work in India, take a look and you may find a better job by doing the exercises in the site.

Seabook

unread,
Mar 19, 2012, 2:05:55 AM3/19/12
to happy-pr...@googlegroups.com

Algorithms for Permutations and Combinations


http://cs.utsa.edu/~dj/ut/utsa/cs3343/lecture25.html

Thanks,
Seabook

Seabook

unread,
Jul 19, 2012, 3:29:40 AM7/19/12
to happy-pr...@googlegroups.com
The Ultimate steps for encoding issues (Found in the Stack Over Flow and put it here as a backup. )

http://stackoverflow.com/questions/138948/how-to-get-utf-8-working-in-java-webapps

Answering myself as the FAQ of this site encourages it. This works for me:

Mostly characters äåö are not a problematic as the default character set used by browsers and tomcat/java for webapps is latin1 ie. ISO-8859-1 which "understands" those characters.

To get UTF-8 working under Java+Tomcat+Linux/Windows+Mysql requires the following:

Configuring Tomcat's server.xml

It's necessary to configure that the connector uses UTF-8 to encode url (GET request) parameters:

<Connector port="8080" maxHttpHeaderSize="8192"
 
maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
 
enableLookups="false" redirectPort="8443" acceptCount="100"
 
connectionTimeout="20000" disableUploadTimeout="true"
 
compression="on"
 
compressionMinSize="128"
 
noCompressionUserAgents="gozilla, traviata"
 
compressableMimeType="text/html,text/xml,text/plain,text/css,text/ javascript,application/x-javascript,application/javascript"
 
URIEncoding="UTF-8"
/>

The key part being URIEncoding="UTF-8" in the above example. This quarantees that Tomcat handles all incoming GET parameters as UTF-8 encoded. As a result, when the user writes the following to the address bar of the browser:

 https://localhost:8443/ID/Users?action=search&name=*ж*

the character ж is handled as UTF-8 and is encoded to (usually by the browser before even getting to the server) as %D0%B6.

POST request are not affected by this.

CharsetFilter

Then it's time to force the java webapp to handle all requests and responses as UTF-8 encoded. This requires that we define a character set filter like the following:

  package fi.foo.filters;

 
import java.io.IOException;
 
import javax.servlet.Filter;
 
import javax.servlet.FilterChain;
 
import javax.servlet.FilterConfig;
 
import javax.servlet.ServletException;
 
import javax.servlet.ServletRequest;
 
import javax.servlet.ServletResponse;

 
public class CharsetFilter implements Filter
   
{
   
private String encoding;

   
public void init(FilterConfig config) throws ServletException
   
{
    encoding
= config.getInitParameter("requestEncoding");

   
if( encoding==null ) encoding="UTF-8";
   
}

   
public void doFilter(ServletRequest request, ServletResponse response, FilterChain       next)
   
throws IOException, ServletException
   
{
   
// Respect the client-specified character encoding
   
// (see HTTP specification section 3.4.1)
   
if(null == request.getCharacterEncoding())
      request
.setCharacterEncoding(encoding);


   
/**
 * Set the default response content type and encoding
 */

 response
.setContentType("text/html; charset=UTF-8");
 response
.setCharacterEncoding("UTF-8");


   
next.doFilter(request, response);
   
}

   
public void destroy(){}
   
}

This filter makes sure that if the browser hasn't set the encoding used in the request, that it's set to UTF-8.

The other thing done by this filter is to set the default response encoding ie. the encoding in which the returned html/whatever is. The alternative is to set the response encoding etc. in each controller of the application.

This filter has to be added to the web.xml or the deployment descriptor of the webapp:

 <!--CharsetFilter start--> 

 
<filter>
   
<filter-name>CharsetFilter</filter-name>
   
<filter-class>fi.foo.filters.CharsetFilter</filter-class>
     
<init-param>
       
<param-name>requestEncoding</param-name>
       
<param-value>UTF-8</param-value>
     
</init-param>
 
</filter>

 
<filter-mapping>
   
<filter-name>CharsetFilter</filter-name>
   
<url-pattern>/*</url-pattern>
 
</filter-mapping>

The instructions for making this filter are found at the tomcat wiki (http://wiki.apache.org/tomcat/Tomcat/UTF-8)

JSP page encoding

All JSP-pages of the webapp need to have the following at the top of them:

 <%@page pageEncoding="UTF-8" contentType="text/html; charset=UTF-8"%>

If some kind of a layout with different JSP-fragments is used, then this is needed in all of them.

HMTL-meta tags

JSP page encoding tells the JVM to handle the characters in the JSP page in the correct encoding. Then it's time to tell the vrowser in which encoding the html page is:

This is done with the following at the top of each xhtml page produced by the webapp:

   <?xml version="1.0" encoding="UTF-8"?>
   
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
   
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fi">
   
<head>
   
<meta http-equiv='Content-Type' content='text/html; charset=UTF-8' />
   ...

JDBC-connection

When using a db, it has to be defined that the connection uses UTF-8 encoding. This is done in context.xml or wherever the JDBC connection is defiend as follows:

      <Resource name="jdbc/AppDB" 
       
auth="Container"
       
type="javax.sql.DataSource"
       
maxActive="20" maxIdle="10" maxWait="10000"
       
username="foo"
       
password="bar"
       
driverClassName="com.mysql.jdbc.Driver" url="jdbc:mysql://localhost:3306/      ID_development?useEncoding=true&amp;characterEncoding=UTF-8"
   
/>

MySQL database and tables

The used database must use UTF-8 encoding. This is achieved by creating the database with the following:

   CREATE DATABASE `ID_development` 
   
/*!40100 DEFAULT CHARACTER SET utf8 COLLATE utf8_swedish_ci */;

Then, all of the tables need to be in UTF-8 also:

   CREATE TABLE  `Users` (
   
`id` int(10) unsigned NOT NULL auto_increment,
   
`name` varchar(30) collate utf8_swedish_ci default NULL
    PRIMARY KEY  
(`id`)
   
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_swedish_ci ROW_FORMAT=DYNAMIC;

The key part being CHARSET=utf8.

MySQL server configuration

MySQL serveri has to be configured also. Tupically this is done in Windows by modifying my.ini -file and in Linux by configuring my.cnf -file. In those files it should be defined that all clients connected to the server use utf8 as the default character set and that the default charset used by the server is also utf8.

   [client]
   port
=3306
   
default-character-set=utf8

   
[mysql]
   
default-character-set=utf8

Mysql procedures and functions

These also need to have the character set defined. For example:

   DELIMITER $$

   DROP FUNCTION IF EXISTS
`pathToNode` $$
   CREATE FUNCTION
`pathToNode` (ryhma_id INT) RETURNS TEXT CHARACTER SET utf8
   READS SQL DATA
   
BEGIN

    DECLARE path VARCHAR
(255) CHARACTER SET utf8;

   SET path
= NULL;

   
...

   RETURN path
;

   
END $$

   DELIMITER
;

GET requests: latin1 and UTF-8

If and when it's defined in tomcat's server.xml that GET request parameters are encoded in UTF-8, the following GET requests are handled properly:

   https://localhost:8443/ID/Users?action=search&name=Petteri
   https
://localhost:8443/ID/Users?action=search&name=ж

Because ASCII-characters are encoded in the same way both with latin1 and UTF-8, the string "Petteri" is handled correctly.

The Cyrillic character ж is not understood at all in latin1. Because Tomcat is instructed to handle request parameters as UTF-8 it encodes that character correctly as %D0%B6.

If and when browsers are instructed to read the pages in UTF-8 encoding (with request headers and html meta-tag), at least Firefox 2/3 and other browsers from this period all encode the character themselves as %D0%B6.

The end result is that all users with name "Petteri" are found and also all users with the name "ж" are found.

But what about äåö?

HTTP-specification defines that by default URLs are encoded as latin1. This results in firefox2, firefox3 etc. encoding the following

    https://localhost:8443/ID/Users?action=search&name=*Päivi*

in to the encoded version

    https://localhost:8443/ID/Users?action=search&name=*P%E4ivi*

In latin1 the character ä is encoded as %E4. Even though the page/request/everything is defined to use UTF-8. The UTF-8 encoded version of ä is %C3%A4

The result of this is that it's quite impossible for the webapp to correly handle the request parameters from GET requests as some characters are encoded in latin1 and others in UTF-8. Notice: POST requests do work as browsers encode all request parameters from forms completely in UTF-8 if the page is defined as being UTF-8

Stuff to read

A very big thank you for the writers of the following for giving the answers for my problem:

answered Sep 26 '08 at 11:48
kosoant
2,93041228


These steps also work with Struts/tiles and a postgres database. – kosoant Sep 26 '08 at 11:55

cool. nice answer. – anjanb Sep 26 '08 at 14:45

In the server.xml there is a mistake. It is not "compession" it is "compression". – Julien Chastang Feb 14 '09 at 23:36
1  
fantastic! Excellent answer which solved my encoding problem. Thanks! – Mads Mobæk May 6 '09 at 12:07
6  
Two comments: 1) in HMTL-meta tags you included a xml declaration. Remove it, it would only trigger browsers in quirks mode, you don't want to have that. Also, the HTML meta tags are in fact already implicitly done by JSP pageEncoding, so you could even leave it away. 2) in MySQL database and tables you used utf8_swedish_si, this should have been utf8_unicode_ci. You could even leave the collation away, just CHARACTER SET utf8 is enough. – BalusC Dec 4 '09 at 14:46

Seabook

unread,
Aug 21, 2012, 8:50:51 PM8/21/12
to happy-pr...@googlegroups.com
Free Online Courses from Berkeley, MIT, and Harvard - Certificate earned on completion
http://www.ozbargain.com.au/node/77969

If you have time and interest, please have a look.

Seabook

unread,
Oct 17, 2012, 11:58:26 PM10/17/12
to happy-pr...@googlegroups.com
For java scripting lovers, Groovy is a good start.
I found a good article in Chinese, so share with you guys who can read Chinese
http://blog.csdn.net/hivon/article/details/4256296


On Wednesday, 31 August 2011 10:16:26 UTC+10, Seabook wrote:
Reply all
Reply to author
Forward
0 new messages