Html Font Tutorial

1 Star2 Stars3 Stars4 Stars5 Stars6 Stars7 Stars8 Stars9 Stars10 Stars (1 votes, average: 5 out of 10)
Loading ... Loading ...

According to World Wide Web Consortium (W3C), the tag in HTML is deprecated. It is removed in a from its recommendations.W3C encourage to use style sheets (CSS) to define the layout and display properties of HTML elements. However there still a lot of people using it, it still worth to mention a while here.


Font Size

<font size=1>Font Size</font>
Size 1
Size 2
Size 3
Size 4
Size 5
Size 6


Font Color


Usually we can change html font color in two ways
1) Use Color Name Red Color

<font color=red>Red Color</font>

2) Use Hex code (#) Red Color

<font color=#FF0000>Red Color</font>

Please check my Html Color Tutorial to find out more web color http://www.mkyong.com/html/html-color-tutorial/


Font Face/ Font Family


We cannot expect them to be universally supported. Just see what your browser can make out of it:

<font face="Serif" > Font style </font>
Serif
Sans-serif
Cursive
Fantasy
Monospace
Times
Roman
Garamond
Palatino
Antiqua
Minion
Helvetica
Swiss
Impact
Script
Decorative
Blackletter
Fraktur
Comic Sans
Modern
Courier
Calibri
Frosty

The actual appearance will depend on browser and the fonts installed on your system. Internet Explorer and Firefox usually different font style in different way.


Beautiful First Letter Style


We learn how to use font face, font size and font color, here we combine all together and create a beautiful first letter

<font size="7" face="Arial" color="#FF0000">B</font>eautiful First Letter

Beautiful First Letter

Html Color Tutorial

1 Star2 Stars3 Stars4 Stars5 Stars6 Stars7 Stars8 Stars9 Stars10 Stars (1 votes, average: 8 out of 10)
Loading ... Loading ...

Life is full of colors, so does HTML ~ Color formula as below

RED + GREEN + BLUE = COLOR

Colors are displayed combining RED, GREEN, and BLUE.

Usually we can change html font color in two ways
1) Use Color Name Red Color

<font color=red>Red Color</font>

2) Use Hex code (#) Red Color

<font color=#FF0000>Red Color</font>

Web usually perfer color in hex code, because a lot colors we do not really know name :)

Table show major colors in web

Color Color HEX Color RGB
#000000 rgb(0,0,0)
#FF0000 rgb(255,0,0)
#00FF00 rgb(0,255,0)
#0000FF rgb(0,0,255)
#FFFF00 rgb(255,255,0)
#00FFFF rgb(0,255,255)
#FF00FF rgb(255,0,255)
#C0C0C0 rgb(192,192,192)
#FFFFFF rgb(255,255,255)

Beside major colors in web, web standard also support 216 Web Safe Colors, here a list

000000 000033 000066 000099 0000CC 0000FF
003300 003333 003366 003399 0033CC 0033FF
006600 006633 006666 006699 0066CC 0066FF
009900 009933 009966 009999 0099CC 0099FF
00CC00 00CC33 00CC66 00CC99 00CCCC 00CCFF
00FF00 00FF33 00FF66 00FF99 00FFCC 00FFFF
330000 330033 330066 330099 3300CC 3300FF
333300 333333 333366 333399 3333CC 3333FF
336600 336633 336666 336699 3366CC 3366FF
339900 339933 339966 339999 3399CC 3399FF
33CC00 33CC33 33CC66 33CC99 33CCCC 33CCFF
33FF00 33FF33 33FF66 33FF99 33FFCC 33FFFF
660000 660033 660066 660099 6600CC 6600FF
663300 663333 663366 663399 6633CC 6633FF
666600 666633 666666 666699 6666CC 6666FF
669900 669933 669966 669999 6699CC 6699FF
66CC00 66CC33 66CC66 66CC99 66CCCC 66CCFF
66FF00 66FF33 66FF66 66FF99 66FFCC 66FFFF
990000 990033 990066 990099 9900CC 9900FF
993300 993333 993366 993399 9933CC 9933FF
996600 996633 996666 996699 9966CC 9966FF
999900 999933 999966 999999 9999CC 9999FF
99CC00 99CC33 99CC66 99CC99 99CCCC 99CCFF
99FF00 99FF33 99FF66 99FF99 99FFCC 99FFFF
CC0000 CC0033 CC0066 CC0099 CC00CC CC00FF
CC3300 CC3333 CC3366 CC3399 CC33CC CC33FF
CC6600 CC6633 CC6666 CC6699 CC66CC CC66FF
CC9900 CC9933 CC9966 CC9999 CC99CC CC99FF
CCCC00 CCCC33 CCCC66 CCCC99 CCCCCC CCCCFF
CCFF00 CCFF33 CCFF66 CCFF99 CCFFCC CCFFFF
FF0000 FF0033 FF0066 FF0099 FF00CC FF00FF
FF3300 FF3333 FF3366 FF3399 FF33CC FF33FF
FF6600 FF6633 FF6666 FF6699 FF66CC FF66FF
FF9900 FF9933 FF9966 FF9999 FF99CC FF99FF
FFCC00 FFCC33 FFCC66 FFCC99 FFCCCC FFCCFF
FFFF00 FFFF33 FFFF66 FFFF99 FFFFCC FFFFFF

Color ~ so beautiful….

Crysis Reckoning chapter is not responsing

1 Star2 Stars3 Stars4 Stars5 Stars6 Stars7 Stars8 Stars9 Stars10 Stars (1 votes, average: 2 out of 10)
Loading ... Loading ...

Crysis - Reckoning - The End chapter always not responsing, after load game, Crysis will auto hang after few minutes, i have no idea what is going on? I hope latest Crysis Pathed v1.2 can fix it. When i try install Crysis patchv1.2, it always display windows installer error and returned ‘1642′. This is weird and stupid bug patch i ever seen before. I start googling, i saw so many people encounter the same problem, why EA didnt take any action?

A lot people said reinstall Crysis will fix the problem. I tried but it failed as well, may be it is because i hanvt patched v1.1? I tried install patched v1.1, but it failed again, it drive me insance, ending soon but i can not continue!!!

I started to think…may be my windows Vista problem? Ok i will do anything for Crysis…., i willing to give it a try, i reinstall my windows to XP SP2. Wow it work!!! I can continue to play ending chapter with no stuck or not responsing anymore. I’m not sure may be Crysis ending chapter have problem playing with windows Vista. Great Crysis i’m coming…..

where is Crysis saved file?

1 Star2 Stars3 Stars4 Stars5 Stars6 Stars7 Stars8 Stars9 Stars10 Stars (1 votes, average: 3 out of 10)
Loading ... Loading ...

I need to backup my Crysis saved file, but the saved file is not installed in Crysis folder. After few search, i found out this is located at document\my game folder.

C:\Users\mkyong\Documents\My Games\Crysis

Just backup above folder. This is where Crysis store their game saved file.

TO_DATE function between PostgreSQL 8.2 and 8.3

1 Star2 Stars3 Stars4 Stars5 Stars6 Stars7 Stars8 Stars9 Stars10 Stars (3 votes, average: 9 out of 10)
Loading ... Loading ...

As we all know PostgreSQL 8.3 make very strong checking on data type, it make a lot application hit many data type error after migration from PostgreSQL8.x to PostgreSQL8.3. Mostly is cause by data type checking.

One of the common error is to_date() function. It accept two text as parameters.

to_date(text,text)

Ok now i create a table as following. A simple table call n_url_test contain a createddate as timestamp data type.

CREATE TABLE n_url_test
(
  urltestid bigserial NOT NULL,
  createddate timestamp without time zone DEFAULT now(),
  CONSTRAINT n_url_to_test_pkey PRIMARY KEY (urltestid)
)

I run following sql in PostgreSQL8.2, it return my expected result as ‘YYYY-MM-DD’ format.

--PostgreSQL 8.2
---------------
SELECT  to_date(createddate,'YYYY-MM-DD') FROM n_url_test;

However after i migrated to PostgreSQL8.3, i hit following error

--PostgreSQL 8.3
---------------
SELECT  to_date(createddate,'YYYY-MM-DD') FROM n_url_test;
 
--------------------------------------------------------------------------------
ERROR:  FUNCTION to_date(timestamp without time zone, unknown) does NOT exist
LINE 1: SELECT  to_date(createddate,'YYYY-MM-DD') FROM n_url_test
                ^
HINT:  No FUNCTION matches the given name AND argument types. 
You might need TO ADD explicit type casts.
 
********** Error **********

PostgreSQL 8.3 will not automatically convert from timestamp to text for us like what it does in previous version. We need to explicit type casts createddate like following

--PostgreSQL 8.3
---------------
SELECT  to_date(createddate::text,'YYYY-MM-DD') FROM n_url_test;

Append ::text to createddate will explicit convert datatype as text, It’s work. PostgreSQL8.3 strictly checking on data type is good function , but please do not forget there still have a lot people using previous version. It cause a lot problem if application is design base on ignore data type checking like what i mention above.

How to download file from website- Java / Jsp

1 Star2 Stars3 Stars4 Stars5 Stars6 Stars7 Stars8 Stars9 Stars10 Stars (3 votes, average: 8.67 out of 10)
Loading ... Loading ...

Here i show a simple java example to demonstrate how to let user download a file from website. No matter you are using struts , JSP, Spring or whatever other java framework, the logic is same.

1) First we have to set HttpServletResponse response to tell browser about system going to return an application file instead of normal html page

response.setContentType("application/octet-stream");
response.setHeader("Content-Disposition",
"attachment;filename=downloadfilename.csv");

we can also specified a download file name in attachment;filename=, above example export a csv file name “downloadfilename.csv” for user download.

2) There have 2 ways to let user download a file from website

Read file from physical location

File file = new File("C:\\temp\\downloadfilename.csv");
FileInputStream fileIn = new FileInputStream(file);
ServletOutputStream out = response.getOutputStream();
 
byte[] outputByte = new byte[4096];
//copy binary contect to output stream
while(fileIn.read(outputByte, 0, 4096) != -1)
{
	out.write(outputByte, 0, 4096);
}
fileIn.close();
out.flush();
out.close();

Export database data or string directly to InputStream for user download.

StringBuffer sb = new StringBuffer("whatever string you like");
InputStream in = new ByteArrayInputStream(sb.toString().getBytes("UTF-8"));
ServletOutputStream out = response.getOutputStream();
 
byte[] outputByte = new byte[4096];
//copy binary contect to output stream
while(in.read(outputByte, 0, 4096) != -1)
{
	out.write(outputByte, 0, 4096);
}
in.close();
out.flush();
out.close();

3) Done

Here i show my struts example to demonstrate how to directly write data into InputStream and output it as “temp.cvs” to let user download.

public ActionForward export(ActionMapping mapping, ActionForm form,
	HttpServletRequest request, HttpServletResponse response)
	throws Exception {
 
	//tell browser program going to return an application file instead of html page
      response.setContentType("application/octet-stream");
      response.setHeader("Content-Disposition","attachment;filename=temp.csv");
 
		try 
		{
			ServletOutputStream out = response.getOutputStream();
			StringBuffer sb = generateCsvFileBuffer();
 
			InputStream in = new ByteArrayInputStream(sb.toString().getBytes("UTF-8"));
 
 
			byte[] outputByte = new byte[4096];
			//copy binary contect to output stream
			while(in.read(outputByte, 0, 4096) != -1)
			{
				out.write(outputByte, 0, 4096);
			}
			in.close();
			out.flush();
			out.close();
 
		}
		return null;
	}
 
private static StringBuffer generateCsvFileBuffer()
{
	StringBuffer writer = new StringBuffer();
 
		writer.append("DisplayName");
		writer.append(',');
		writer.append("Age");
		writer.append(',');
		writer.append("HandPhone");
		writer.append('\n');
 
            writer.append("mkyong");
		writer.append(',');
		writer.append("26");
		writer.append(',');
		writer.append("0123456789");
		writer.append('\n');
 
 
		return writer;
}

How to export data to CSV file - Java

1 Star2 Stars3 Stars4 Stars5 Stars6 Stars7 Stars8 Stars9 Stars10 Stars (1 votes, average: 5 out of 10)
Loading ... Loading ...

CSV is stand for Comma-separated values, CSV is a delimited data format that has fields/columns separated by the comma character and records/rows separated by newlines.

More detail please check http://en.wikipedia.org/wiki/Comma-separated_values

Please take a look at CSV sample,

Display Name,   Age, Hand Phone
Micheal , 30, 0123456789
Bill, 25, 0129876543

Actually CSV is just like a text file with a certain delimited like comma “,” or semi-comma “;” or any other delimited character you want. Here i will show how to use java to export data or writing data into a CSV file.

This sample is very simple and straight froward, it just use java FileWriter object to create a normal text file (CSV file).

package com.mkyong.test;
 
import java.io.FileWriter;
import java.io.IOException;
 
public class GenerateCsv
{
   public static void main(String [] args)
   {
	   generateCsvFile("c:\\test.csv"); 
   }
 
   private static void generateCsvFile(String sFileName)
	{
		try
		{
		    FileWriter writer = new FileWriter(sFileName);
 
			writer.append("DisplayName");
			writer.append(',');
			writer.append("Age");
			writer.append('\n');
 
			writer.append("MKYONG");
			writer.append(',');
			writer.append("26");
			writer.append('\n');
 
			writer.append("YOUR NAME");
			writer.append(',');
			writer.append("29");
			writer.append('\n');
 
			//generate whatever data you want
 
			writer.flush();
			writer.close();
		}
		catch(IOException e)
		{
		 e.printStackTrace();
		} 
	}
}

Simple right? Writing / export data to CSV file is exactly same with writing data into a normal text file. This is simple, we do not need any third party library to do it.

How to check Linux CPU Information

1 Star2 Stars3 Stars4 Stars5 Stars6 Stars7 Stars8 Stars9 Stars10 Stars (1 votes, average: 3 out of 10)
Loading ... Loading ...

Linux CPU information is store in /proc/cpuinfo, we can check our Linux CPU information by issue following command

cat /proc/cpuinfo

Sample output in my Linux machine

debian:~# cat /proc/cpuinfo
processor       : 0
vendor_id       : GenuineIntel
cpu family      : 6
model           : 15
model name      : Intel(R) Core(TM)2 CPU          6300  @ 1.86GHz
stepping        : 8
cpu MHz         : 1861.324
cache size      : 2048 KB
fdiv_bug        : no
hlt_bug         : no
f00f_bug        : no
coma_bug        : no
fpu             : yes
fpu_exception   : yes
cpuid level     : 10
wp              : yes
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov                                                                                                   pat pse36 clflush dts acpi mmx fxsr sse sse2 ss nx lm constant_tsc up pni ds_cpl                                                                                                   cx16 lahf_lm
bogomips        : 3734.51

Spring AOP Interceptor transaction is not working

1 Star2 Stars3 Stars4 Stars5 Stars6 Stars7 Stars8 Stars9 Stars10 Stars (1 votes, average: 4 out of 10)
Loading ... Loading ...

I just wonder why my Spring AOP transaction is not working in following three interceptors? Below is part of my Spring AOP xml declaration.

 <bean id="testAutoProxyCreator"
		class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator">
		<property name="interceptorNames">
			<list>
				<idref bean="urlInterceptorInsert" />
				<idref bean="urlInterceptorCommit" />
				<idref bean="urlInterceptorRelease" />
			        <idref bean="matchGenericTxInterceptor" />
			</list>
		</property>
		<property name="beanNames">
			<list>
				<idref local="urlBo" />
			</list>
		</property>
	</bean>

Below is my Spring AOP transaction manager Interceptor, it will intercept any method to run it as transaction.

<idref bean="matchGenericTxInterceptor" />

However transaction is not roll back in three of my interceptors if error occur.

<idref bean="urlInterceptorInsert" />
<idref bean="urlInterceptorCommit" />
<idref bean="urlInterceptorRelease" />

I just wonder why my Generic Spring transaction manager (matchGenericTxInterceptor) is not match to my 3 interceptors. I have no idea how to make it work. After i million tried and error, i simply change sequence of my interceptor xml file like following (put matchGenericTxInterceptor on top)

 <bean id="testAutoProxyCreator"
		class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator">
		<property name="interceptorNames">
			<list>
                                <idref bean="matchGenericTxInterceptor" />
				<idref bean="urlInterceptorInsert" />
				<idref bean="urlInterceptorCommit" />
				<idref bean="urlInterceptorRelease" />
			</list>
		</property>
		<property name="beanNames">
			<list>
				<idref local="urlBo" />
			</list>
		</property>
	</bean>

Wow, It work! My 3 interceptors transaction is not roll back if error occur is because my interceptor is executed before my transaction manager interceptor(matchGenericTxInterceptor). After change the sequence to let transaction manager interceptor(matchGenericTxInterceptor) execute first, all my interceptors can support transaction very well. Here i want to highlight is Sequence of Spring AOP interceptor is very very important.

PostgreSQL - How to change default schema

1 Star2 Stars3 Stars4 Stars5 Stars6 Stars7 Stars8 Stars9 Stars10 Stars (1 votes, average: 4 out of 10)
Loading ... Loading ...

“public” is PostgreSQL default scheme, i have to change it because i had migrated a new database data into another new schema call “new_public”.
Before start to change, i have to check what is current PostgreSQL default schema?

1) Command

SHOW search_path

2) Check postgresql.conf

#---------------------------------------------------------------------------
# CLIENT CONNECTION DEFAULTS
#---------------------------------------------------------------------------
 
# - Statement Behavior -
 
#search_path = '"$user",public'		# schema names
#default_tablespace = ''		# a tablespace name, '' uses
					# the default
#check_function_bodies = on
#default_transaction_isolation = 'read committed'
#default_transaction_read_only = off

Here i show how to change Postgresql default schema.

SET search_path = new_schema

However above command is apply to current session only, next time schema will change back to public. If we want to make effect permanently, we have to change in postgresql.conf file like following.

#---------------------------------------------------------------------------
# CLIENT CONNECTION DEFAULTS
#---------------------------------------------------------------------------
 
# - Statement Behavior -
 
#search_path = '"$user",public'		# schema names
search_path = '"$user",new_schema'	# NEW SCHEMA HERE
#default_tablespace = ''		# a tablespace name, '' uses
					# the default
#check_function_bodies = on
#default_transaction_isolation = 'read committed'
#default_transaction_read_only = off

After that just restart PostgreSQL service. Done.