My Blog List

Wednesday, December 19, 2012

Mysql make user and password

First of all make database
mysql> create database DBName;

See all database list
mysql> show databases

mysql> use mysql

Making general user
mysql> grant usage on *.* to amarokuser@localhost identified by 'amarokpasswd'; Query OK, 0 rows affected (0.00 sec)
Making the user having all authorities
mysql> grant all privileges on amarokdb.* to amarokuser@localhost ; Query OK, 0 rows affected (0.00 sec)
commit all changes
mysql> FLUSH PRIVILEGES;
see allowed ip adresses
SELECT Host FROM mysql.user WHERE user='root';

Tuesday, December 11, 2012

Lucene Tutorial(1) - How to index Lucene


I'm first in use of lucene. I think this blog is not perfect for you because I'm not professional.
but what I wrote is by reading and stuying the book of Lucene in action 2.
so I hope this blog is going to be useful some of you

1. Indexing (3.6.1 version)

why Use?

when i can use this lucene?

Suppose~!  you have many text-files in your local computer, window xp, 7 and so on  search programs allow you find filename but not content in textfiles. 
how do search content?

so you have to use search engine like lucene


how to Index ?


explain :  

indexDir = directory that you want to index   (a.txt, b.txt, c.txt)
dataDir = destination directory where indexing file will store

IndexWriter = it is like translator original file into indexed file

TextFilesFilter class = filtering file extension
Document  = it is like file info class

Running this code
your first experience is done.


public class Indexer {
public static void main(String[] args) throws Exception {
if (args.length != 2) {
throw new IllegalArgumentException("Usage: java " + Indexer.class.getName() + " <index dir> <data dir>");
}
final String indexDir = args[0];
final String dataDir = args[1];
final long start = System.currentTimeMillis();
final Indexer indexer = new Indexer(indexDir);
int numIndexed;

try {
numIndexed = indexer.index(dataDir, new TextFilesFilter());
} finally {
indexer.close();
}
final long end = System.currentTimeMillis();
System.out.println("Indexing " + numIndexed + " files took " + (end - start) + " milliseconds");

}

private IndexWriter writer;

public Indexer(
String indexDir) throws IOException {
final Directory dir = FSDirectory.open(new File(indexDir));
writer = new IndexWriter(dir, new StandardAnalyzer(Version.LUCENE_30), true, IndexWriter.MaxFieldLength.UNLIMITED);
}

public void close() throws IOException {
writer.close();
}

public int index(String dataDir, FileFilter filter) throws Exception {
final File[] files = new File(dataDir).listFiles();
for (final File f : files) {
if (!f.isDirectory() && !f.isHidden() && f.exists() && f.canRead() && (filter == null || filter.accept(f))) {
indexFile(f);
}
}
return writer.numDocs();
}

private static class TextFilesFilter implements FileFilter {
@Override
public boolean accept(File path) {
return path.getName().toLowerCase().endsWith(".txt");
}
}

protected Document getDocument(File f) throws Exception {
final Document doc = new Document();
doc.add(new Field("content", new FileReader(f)));
doc.add(new Field("filename", f.getName(), Field.Store.YES, Field.Index.NOT_ANALYZED));
doc.add(new Field("fullpath", f.getCanonicalPath(), Field.Store.YES, Field.Index.NOT_ANALYZED));
doc.add(new NumericField("filesize").setIntValue((int) f.length()));
System.out.println(f.length());

return doc;
}

private void indexFile(File f) throws Exception {
System.out.println("Indexing " + f.getCanonicalPath());
System.out.println(f.lastModified());
final Document doc = getDocument(f);
writer.addDocument(doc);
}
}




Thursday, December 6, 2012

easyUnderstanding jsp include

<%@include file="/jsp/common/session.jsp"%>




<jsp:include page="/jsp/common/uppermenu.jsp" flush="true">
</jsp:include>

Tuesday, December 4, 2012

html image size 100%


/** 백그라운드 이미지를 전체 사이즈에 맞추기**/
background: url('bg_viewbar.gif')  no-repeat center center fixed;
-webkit-background-size: cover;
    -moz-background-size: cover;
    -o-background-size: cover;
    background-size: cover;

Sunday, December 2, 2012

Tuesday, November 27, 2012

future project plan

1. There is no free chat site in Korea. Chatting 
2, Link Page
3. Style application
4. tell me about what you can not tell (application)

file Explorer connect to ftp if error occur

http://hanarush.tistory.com/82

Wednesday, November 21, 2012

Monday, November 19, 2012

log4j.properties to log4j.xml Translator

http://logback.qos.ch/translator/

Extract Files(doc, excel) TO TEXT

this blod explain about what you are curious

http://fazlansabar.blogspot.kr/2012/06/apache-lucene-tutorial-indexing.html

Tuesday, November 13, 2012

tab menu html

http://www.bloggertipandtrick.net/2010/09/amazing-jquery-tabs-widgets-collection.html

Thursday, November 8, 2012

루씬 기본 형태

I don't know this is my first time to write story about lucene
this is open  source that is powerfull~!

form now on I plan to write kind of tutorial of lucene

Monday, November 5, 2012

window.onload

this is a part of javascript
after page being loaded window.onload will be called..


window.onload = init;

function init() {
document.getElementById('loading').style.display='none';
}

function loginSubmit(){
document.getElementById('button').style.display='none';
document.getElementById('loading').style.display='block';
document.forms["login"].submit();
}

Thursday, November 1, 2012

Wednesday, October 24, 2012

Tuesday, October 23, 2012

HTML5 GOOD Tutorial LINK

http://designmodo.com/50-useful-html5-tutorials-techniques-and-examples-for-web-developers/

Monday, October 22, 2012

Ajax Example MyStyle


function sendAjax() {

var xhr = new XMLHttpRequest();

var params="company_id="+"203"+"&"+"search.max="+max+"&"+"search.pos="+pos;
xhr.open( "GET",
'url?' + params,
true);
xhr.setRequestHeader(
'app-agent',
'platform_kind=20;platform_ver=1.0.1;device_id=0a171eecebeb462b1ba40f02c2d0d4374889d268;app_name=eagletalk_mobile;app_vers=3.0.4;device_model=jmeter;emulator=true;network_type=WiFi;');
xhr.setRequestHeader('access-token',
'gw343#Gb8MGMbNeHsHj22p4uuRD85cdQM=');
xhr.onreadystatechange = function() {
if (xhr.readyState == 4 && xhr.status == 200)
{
var obj = eval( '(' + xhr.responseText + ')' );
var list =  obj.list;
for(var i=0; i<list.length; i++){
var html= '<div class="frame" id="frame">'+
'<div id ="content" class="ccc">'+
'<p id="content_title"><strong>'+list[i].title+'</strong></p>'+
'<p id="right_time"><strong>'+getDate(list[i].reg_dttm)+'</strong>PM</p>'+
'</div>'+
'<div id="right_navi">'+
'<div id ="icon">'+
'<img src="image/com_icon_arrow.png">'+
'</div>'+
'</div>'+
'</div>'
$("#scroller-body").append(html);
}

// refresh
if(myScroll != null){
myScroll.refresh();
}
listSetting();
pos = pos+max;
isWorking = false;
}


}
xhr.send();
}

Android Touch Effect From Jquery


It effects Good

if you want to touch from mobile web

$('.ccc').bind('touchstart', function() {
$(this).css("background-color","blue");
});
$('.ccc').bind('touchend', function() {
$(this).css("background-color","yellow");
});

CSS good Effects

http://rockingcode.com/misc/photo-gallery-and-slideshow/20-background-effects-using-jquery-with-19-excellent-examples/

Friday, October 19, 2012

DSLR 사이트

http://www.slrclub.com/

Html heaer, center, footer


example

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style type="text/css">
html,
body {
height: 100%;
margin: 0;
padding: 0;
}
#head {
height: 100px;
background: #ddd;
position: relative;
z-index: 1;
}
#body {
min-height: 100%;
margin: -100px 0 -50px;
}
* html #body {
height: 100%;
}
#content-area {
padding: 100px 0 50px;
}
#foot {
height: 50px;
background: #ddd;
}
</style>
</head>

<body>
<div id="head">
요건 100px 높이 헤드
</div>
<div id="body">
<div id="content-area">
<p>컨텐츠 영역 1</p>
<p>컨텐츠 영역 2</p>
<p>컨텐츠 영역 3</p>
<p>(계속 추가해서 테스트 가능)</p>
</div>
</div>
<div id="foot">
요건 50px 높이 풋
</div>
</body>
</html>

Tuesday, September 4, 2012

oracle update table order by old_id

update (select * from mytable order by old_id) set new_id = mysequence.nextval;

Friday, July 27, 2012

linux java classpath

vi /etc/profile

add below lines

#JAVA SETTING
export JAVA_HOME=/home/hadstore/java/jdk1.6.0_33
export PATH=$PATH:$JAVA_HOME/bin
export CLASSPATH=.:$JAVA_HOME/jre/lib/ext:$JAVA_HOME/lib/tools.jar

souce /etc/profile : this is for reload

Sunday, June 24, 2012

mysql unique setting

ALTER TABLE [table] ADD UNIQUE (USER_ID)

First of all, you can make some column unique when creating table

CREATE TABLE Persons
(
seq int NOT NULL,
LastName varchar(255) NOT NULL,
FirstName varchar(255),
UNIQUE (seq)
)
Second, when you alter table.

ALTER TABLE TB_USER ADD UNIQUE (USER_ID);


Thursday, June 21, 2012

Tuesday, June 19, 2012

javaScript Confirm Box


<!DOCTYPE html>
<html>
<body>

<p>Click the button to display a confirm box.</p>

<button onclick="myFunction()">Try it</button>

<p id="demo"></p>

<script type="text/javascript">
function myFunction()
{
var x;
var r=confirm("Press a button!");
if (r==true)
  {
  x="You pressed OK!";
  }
else
  {
  x="You pressed Cancel!";
  }
document.getElementById("demo").innerHTML=x;
}
</script>

</body>
</html>

Thursday, June 14, 2012

load balancing apache -> http.conf




LoadModule jk_module modules/mod_jk.so



JkWorkerProperty worker.list=ajp13w
JkWorkerProperty worker.ajp13w.type=lb
JkWorkerProperty worker.ajp13w.balanced_workers=WAS1,WAS2
JkWorkerProperty worker.sticky_session=true


JkWorkerProperty worker.WAS1.type=ajp13
JkWorkerProperty worker.WAS1.host=localhost
JkWorkerProperty worker.WAS1.port=8009
JkWorkerProperty worker.WAS1.lbfactor=1

JkWorkerProperty worker.WAS2.type=ajp13
JkWorkerProperty worker.WAS2.host=192.168.0.32
JkWorkerProperty worker.WAS2.port=8009
JkWorkerProperty worker.WAS2.lbfactor=1



JkLogFile logs/jk.log
JkLogLevel info
JkLogStampFormat "[%a %b %d %H:%M:%S %Y]"
#JkMount /*.jsp ajp13w
JkMount /* ajp13w
JkMount /example/* ajp13w

JkUnMount /*.html ajp13w
JkUnMount /*.gif ajp13w
JkUnMount /*.jpg ajp13w
#JkMount /servlet/* ajp13w

Apache2.2 and Tomcat 7.x

톰캣 7.x  + 아파치 2.x + mod_jk

http://blog.naver.com/PostView.nhn?blogId=gkdrhd93&logNo=10117411982

Saturday, May 5, 2012

MYSQL Authority~!


$ mysql -u root -p
Enter password:

mysql> use mysql

mysql> GRANT ALL ON *.* to root@'192.168.1.4' IDENTIFIED BY 'your-root-password'; 

mysql> FLUSH PRIVILEGES;
if i want all ipaddress can access to DB Server
mysql> GRANT ALL ON *.* to root@'%' IDENTIFIED BY 'your-root-password'

Friday, April 6, 2012

Change Database Characters

Change Character set

There are many way to change character set
this way is to change database character set
ALTER DATABASE dbname CHARACTER SET utf8 COLLATE utf8_general_ci;
belows sql query shows that what kind of character set mysql has
mysql> show character set;

Wednesday, April 4, 2012


+x means a+x : all user can execute

$ chmod +x your-script-name
$ chmod 755 your-script-name





Examples:
$ bash bar
$ sh bar
$ ./bar



echo show on monitor


$ vi first
#
# My first shell script
#
clear
echo "Knowledge is Power"


$ ./first

Tuesday, March 20, 2012


when you write 'free' on linux

you will know the rest of you computer memory

[root@posu7 logs]# free

             total       used       free     shared    buffers     cached
Mem:        524288     404716     119572          0      76072      93512
-/+ buffers/cache:     235132     289156
Swap:      1081336        112    1081224

Sunday, March 11, 2012

Install Mysql

Now I let you know how to install MySQl on linux

First this will check if mysql is already installed on linux
# rpm -qa | grep mysql

Remove previouse Versin
# rpm -e  mysql-devel-5.0.77-4.el5_5.4 –-nodeps(--nodeps will ignore dependencies)

And go to web site to find the version that you want to install


# rpm -ivh Mysql-server....rpm
# rpm -ivh Mysql-share.....rpm
# rpm -ivh mysql-devel......rpm
# rpm -ivh mysql-client......rpm

A) If you are /using mysql on RedHat Linux (Fedora Core/Cent OS) then use following command:

* To start mysql server:
/etc/init.d/mysqld start
* To stop mysql server:
/etc/init.d/mysqld stop
* To restart mysql server
 /etc/init.d/mysqld restart
# service mysqld start
# service mysqld stop
# service mysqld restart
$ mysql -u root -p
Enter password:

mysql> use mysql

mysql> GRANT ALL ON *.* to root@'192.168.1.4' IDENTIFIED BY 'your-root-password'; 

mysql> FLUSH PRIVILEGES;
and /etc/sysconfig vi iptables and add open 3306 port

Saturday, March 10, 2012

What is RPM

RPM(RedHat Package Manager)

RPM Package Manager (RPM) is a package management system.[2]The name RPM variously refers to the .rpm file format, files in this format,software packaged in such files, and the package manager itself. RPM was intended primarily for GNU/Linux distributions; the file format is the baseline package format of the Linux Standard Base.

rpm -qi :  mtools-3.9.8-2.i386.rpm print package summary
rpm -i : mtools-3.9.8-2.i386.rpm install package
rpm -ivh : mtools-3.9.8-2.i386.rpm install, monitor and verify pack
rpm -q : mtools verify if pack installed
rpm -qa :  list all installed packs
rpm -ql : mtools list all files installed for pack
rpm -qd : mtools list pack doc files only
rpm -e  : mtools erase package
rpm -Uvh :  * upgrade all packs in distribution

What is Wget

What is Wget

Definition: wget: retrieves files from the web Wget is a network utility to retrieve files from the Web using http and ftp, the two most widely used Internet protocols. It works non-interactively, so it will work in the background, after having logged off. The program supports recursive retrieval of web-authoring pages as well as ftp sites -- you can use wget to make mirrors of archives and home pages or to travel the Web like a WWW robot. Wget works particularly well with slow or unstable connections by continuing to retrieve a document until the document is fully downloaded. Re-getting files from where it left off works on servers (both http and ftp) that support it. Both http and ftp retrievals can be time stamped, so wget can see if the remote file has changed since the last retrieval and automatically retrieve the new version if it has. Wget supports proxy servers; this can lighten the network load, speed up retrieval, and provide access behind firewalls. http://www.gnu.org/software/wget/


To istall on linux

yum install wget

It is very easy

Thursday, March 8, 2012

FTP Install

First you need to download lftp


[root@localhost /]# yum install lftp

after that 

mkdir /usr/local/src/ftpd
cd /usr/local/src/ftpd


before you write below line, you should look on the http://www.proftpd.org/
and check lasted version.

lftpget ftp://ftp.proftpd.org/distrib/source/proftpd-1.3.4a.tar.gz

[root@localhost ftpd]# tar -xvzf proftpd-1.3.4a.tar.gz
proftpd-1.3.4a/
proftpd-1.3.4a/doc/
proftpd-1.3.4a/doc/utils/
proftpd-1.3.4a/doc/utils/ftpcount.html
proftpd-1.3.4a/doc/utils/ftpmail.html
proftpd-1.3.4a/doc/utils/ftpasswd.html
proftpd-1.3.4a/doc/utils/ftpscrub.html
proftpd-1.3.4a/doc/utils/ftpwho.html
proftpd-1.3.4a/doc/utils/ftptop.html
proftpd-1.3.4a/doc/utils/ftpquota.html
proftpd-1.3.4a/doc/utils/ftpdctl.html
proftpd-1.3.4a/doc/utils/index.html
proftpd-1.3.4a/doc/utils/ftpshut.html
proftpd-1.3.4a/doc/contrib/
proftpd-1.3.4a/doc/contrib/mod_sql_odbc.html
proftpd-1.3.4a/doc/contrib/mod_wrap2_file.html
proftpd-1.3.4a/doc/contrib/mod_ifsession.html
proftpd-1.3.4a/doc/contrib/mod_exec.html
proftpd-1.3.4a/doc/contrib/mod_quotatab.html
proftpd-1.3.4a/doc/contrib/mod_ldap.html
proftpd-1.3.4a/doc/contrib/mod_radius.html
proftpd-1.3.4a/doc/contrib/

...............


[root@localhost proftpd-1.3.4a]# ./configure --prefix=/usr/local/server/proftpd --enable-autoshadow --enable-shadow
checking build system type... i686-pc-linux-gnu
checking host system type... i686-pc-linux-gnu
checking target system type... i686-pc-linux-gnu
checking for gcc... no
checking for cc... no
checking for cl.exe... no
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details.
[root@localhost proftpd-1.3.4a]# 



if you find 

checking build system type... i686-pc-linux-gnu
checking host system type... i686-pc-linux-gnu
checking target system type... i686-pc-linux-gnu
checking for gcc... no
checking for cc... no
checking for cl.exe... no
configure: error: no acceptable C compiler found in $PATH

you should install : yum install gcc
you should install : yum install make

and retry ./configure ..........


write : make

write : make install

/usr/local/server/proftpd/etc/proftpd.conf 

oepn with vi 

and line 27 nogroup -> nobody

[root@localhost sbin]# ./proftpd &
[1] 11663

why & add??
this means that we run server in background


vi iptables

# Generated by iptables-save v1.4.2 on Mon Jul 11 14:23:01 2011
*filter
:INPUT ACCEPT [1190:468478]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [763:273145]
:RH-Firewall-1-INPUT - [0:0]
-A INPUT -j RH-Firewall-1-INPUT
-A FORWARD -j RH-Firewall-1-INPUT
-A RH-Firewall-1-INPUT -i lo -j ACCEPT
-A RH-Firewall-1-INPUT -p icmp --icmp-type any -j ACCEPT
-A RH-Firewall-1-INPUT -p 50 -j ACCEPT
-A RH-Firewall-1-INPUT -p 51 -j ACCEPT
-A RH-Firewall-1-INPUT -p udp --dport 5353 -d 224.0.0.251 -j ACCEPT
-A RH-Firewall-1-INPUT -p udp -m udp --dport 631 -j ACCEPT
-A RH-Firewall-1-INPUT -p tcp -m tcp --dport 631 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 21 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 443 -j ACCEPT
COMMIT

service iptables restart

and try to access from ftp tools






Friday, March 2, 2012

Pattern easy

This is very is and amazing if you know

ex) if(split[i].matches("[A-Za-z]+\\.?")){
    }

what dose that mean?

i'm just looking for JAVA API

[A-Za-z] : those alphabet A from Z or a-z is available
 +       [A-Za-z] uses more than one time
\\
.?       : .? means one or nothing  


"33. "             return false
"gefefeddd."       return true
"ddddfedAE"        return true
"d.d.d"            return false
"ddkdkjeij.33412"  return false
"12312tjkjkd@#"    return false

Thursday, March 1, 2012

TopCoder1


I just started Topcoder
it is very interesting for me
because i have to think about a lot of things.
this homepage is really good
I hope my coding pattern and style will be better than now~!


do you want to do this with me?
write message to me~!

this article is about tho question    "practiceRooms/Inv 2001 R1/ 500"




my answer is below~!







import java.util.ArrayList;


public class SquareDigits {
public static void main(String args[]){
int a= new SquareDigits().smallestResult(112);
System.out.println(a);
}


public int smallestResult(int value){
int count =0;
ArrayList<Integer> tArray= new ArrayList<Integer>();
int sum = 0;
String sValue ="";
sValue =String.valueOf(count);
while(true){

for(int i=0; i<sValue.length(); i++){
String eachValue = sValue.substring(i, i+1);
sum = sum + Integer.parseInt(eachValue)*Integer.parseInt(eachValue);
}

if(sum == value){
if(tArray.size()==0) return count;
return tArray.get(0);
}else{
if(tArray.contains(sum)){
count=count+1;
tArray.clear();
sValue =String.valueOf(count);
sum=0;
}else{
tArray.add(sum);
sValue =String.valueOf(sum);
sum=0;
}
}
}
}
}

and my Rank is below