Showing posts with label Programming. Show all posts
Showing posts with label Programming. Show all posts

Wednesday, January 19, 2011

Sending output of a command to file and console

The following unix command prints the logs to the mycommand.log file. But it will not output the text to the Console.

mycommand >> /tmp/mycommand .log


This command sends the output to the console as well as to the mycommand.log file

mycommand 2>&1 | tee -a /tmp/mycommand.log

Count of a files in a directory and its subdirectpries Unix command

find -type f ¦ wc -l

Friday, July 6, 2007

Programmatically setting appenders log4j

Here is the code to initialize the appenders programmatically(java)
Logger logger = Logger.getLogger(CURRENT_LOGGER_NAME);
logger.removeAllAppenders();
FileAppender fa = new FileAppender(new SimpleLayout(),filename,true);
fa.activateOptions();
logger.addAppender(fa);



Monday, October 9, 2006

Printing the Hex equivalent of a unicode character (Java)

/*
* Converts the byte to hex
*/

public String byteToHex(byte b) {
char hexDigits[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9','A', 'B', 'C', 'D', 'E', 'F' };
char[] array = { hexDigits[(b >> 4) & 0x0f], hexDigits[b & 0x0f] };
return new String(array);
}
/*
* Returns the hex equivalent of a character
*/

public String charToHex(char c) {
//get the hex of a higher byte
byte hi = (byte) (c >>> 8);
//get the hex equivalent of lower byte
byte lo = (byte) (c & 0xff);
return byteToHex(hi) + byteToHex(lo);
}

Sunday, September 11, 2005

How to write blogs in telugu?

తెలుగు లో బ్లొగులు రాయడము ఎలా




Creating telugu blog is as simple as writing your script in Unicode. We write the telugu character equivalent in unicode(escaped html character).... The unicode telugu characters are defined at http://www.unicode.org/charts/PDF/U0C00.pdf


For examle to say namaskaaramulu you have to type నమస్కారములు
where








english character decimal equivalent of unicode
na న (3112)
ma ;మ(3118)
skaa స్కా (3128 3149 3093 3134)
ra ర (3120)
mu ము (3118 3137 )
lu లు (3122 3137)


The following site translates the english text into equivalent html character.. so you just jave to copy the html code there and add into this box ;)

http://www.iit.edu/~laksvij/language/telugu.html

First telugu Blog (మొదటి తెలుగు భ్లొగు)

ఇది నా మొదటి తెలుగు బ్లాగు.. ఈ బ్లొగ్ ని ఇలాగే నడిపిన్చా లని నా ప్రయటనమ్ --శ్రీ

Saturday, September 3, 2005

Printing the unicode characters to console from java program

I did bit of R and to print the unicode characters from Java.. and finally i found that its a very simple thing and can be done in couple of ways

1) using the java file.encoding system parameter -Dfile.encoding=UTF8. the advantage with this is your program can be run with multiple encodings
2) in java program like

public class InternationalHello {
public static void main (String[] argv) {
String helloInTelugu = "\U0C39\U0C32\UoC4B";

PrintStream out = System.out;
out.println(helloInTelugu );
}
}

cool and easy right..................