2016년 5월 26일 목요일

[Qt5] Open Default Web Browser


#include 

    QDesktopServices::openUrl(QUrl("freecatz.blogspot.kr"));

[Qt5] Hardware Infomation

#include 

    qInfo() << QSysInfo::currentCpuArchitecture();
    qInfo() << QSysInfo::kernelType();
    qInfo() << QSysInfo::kernelVersion();
    qInfo() << QSysInfo::machineHostName();
    qInfo() << QSysInfo::prettyProductName();
    qInfo() << QSysInfo::productType();
    qInfo() << QSysInfo::productVersion();
    ....

[Qt5] UUID

#include 

    QUuid uuid = QUuid::createUuid();
    qInfo() << uuid.toString();

[Qt5] IP Address and MAC Address

.pro file

QT       += network



.cpp source file

#include 
#include 

    QString _MAC = "";
    QString _IP = "";
    
    QTcpSocket socket;
    socket.connectToHost("8.8.8.8", 53); // google DNS, or something else reliable
    if (socket.waitForConnected(3000)) {
//        qInfo() << socket.localAddress().toString();
        foreach(QNetworkInterface interface, QNetworkInterface::allInterfaces()){
            foreach (QNetworkAddressEntry entry, interface.addressEntries()){
                if(socket.localAddress().toString() == entry.ip().toString()){
                    qInfo() << socket.localAddress().toString() << " - " << interface.hardwareAddress();
                    _MAC = interface.hardwareAddress();
                    _IP = socket.localAddress().toString();
                }
            }
        }
    } else {
        qInfo() << socket.errorString();
    }

    socket.destroyed();

2016년 5월 20일 금요일

[EtC] tomcat server.xml

<?xml version='1.0' encoding='utf-8'?>
<!--
  Licensed to the Apache Software Foundation (ASF) under one or more
  contributor license agreements.  See the NOTICE file distributed with
  this work for additional information regarding copyright ownership.
  The ASF licenses this file to You under the Apache License, Version 2.0
  (the "License"); you may not use this file except in compliance with
  the License.  You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
-->
<!-- Note:  A "Server" is not itself a "Container", so you may not
     define subcomponents such as "Valves" at this level.
     Documentation at /docs/config/server.html
 -->
<Server port="8005" shutdown="SHUTDOWN">
  <Listener className="org.apache.catalina.startup.VersionLoggerListener" />
  <!-- Security listener. Documentation at /docs/config/listeners.html
  <Listener className="org.apache.catalina.security.SecurityListener" />
  -->
  <!--APR library loader. Documentation at /docs/apr.html -->
  <Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
  <!-- Prevent memory leaks due to use of particular java/javax APIs-->
  <Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" />
  <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
  <Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener" />

  <!-- Global JNDI resources
       Documentation at /docs/jndi-resources-howto.html
  -->
  <GlobalNamingResources>
    <!-- Editable user database that can also be used by
         UserDatabaseRealm to authenticate users
    -->
    <Resource name="UserDatabase" auth="Container"
              type="org.apache.catalina.UserDatabase"
              description="User database that can be updated and saved"
              factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
              pathname="conf/tomcat-users.xml" />
  </GlobalNamingResources>

  <!-- A "Service" is a collection of one or more "Connectors" that share
       a single "Container" Note:  A "Service" is not itself a "Container",
       so you may not define subcomponents such as "Valves" at this level.
       Documentation at /docs/config/service.html
   -->
  <Service name="Catalina">

    <!--The connectors can use a shared executor, you can define one or more named thread pools-->
    <!--
    <Executor name="tomcatThreadPool" namePrefix="catalina-exec-"
        maxThreads="150" minSpareThreads="4"/>
    -->


    <!-- A "Connector" represents an endpoint by which requests are received
         and responses are returned. Documentation at :
         Java HTTP Connector: /docs/config/http.html (blocking & non-blocking)
         Java AJP  Connector: /docs/config/ajp.html
         APR (HTTP/AJP) Connector: /docs/apr.html
         Define a non-SSL/TLS HTTP/1.1 Connector on port 8080
    -->
    <Connector port="8080" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443"
      disableUploadTimeout="true"
               enableLookups="false"
               URIEncoding="UTF-8" />
    <!-- A "Connector" using the shared thread pool-->
    <!--
    <Connector executor="tomcatThreadPool"
               port="8080" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443" />
    -->
    <!-- Define a SSL/TLS HTTP/1.1 Connector on port 8443
         This connector uses the NIO implementation that requires the JSSE
         style configuration. When using the APR/native implementation, the
         OpenSSL style configuration is required as described in the APR/native
         documentation -->
    <!--
    <Connector port="8443" protocol="org.apache.coyote.http11.Http11NioProtocol"
               maxThreads="150" SSLEnabled="true" scheme="https" secure="true"
               clientAuth="false" sslProtocol="TLS" />
    -->

    <!-- Define an AJP 1.3 Connector on port 8009 -->
    <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />


    <!-- An Engine represents the entry point (within Catalina) that processes
         every request.  The Engine implementation for Tomcat stand alone
         analyzes the HTTP headers included with the request, and passes them
         on to the appropriate Host (virtual host).
         Documentation at /docs/config/engine.html -->

    <!-- You should set jvmRoute to support load-balancing via AJP ie :
    <Engine name="Catalina" defaultHost="localhost" jvmRoute="jvm1">
    -->
    <Engine name="Catalina" defaultHost="freecatz.pe.kr" jvmRoute="tomcat1">

      <!--For clustering, please take a look at documentation at:
          /docs/cluster-howto.html  (simple how to)
          /docs/config/cluster.html (reference documentation) -->
      <!--
      <Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"/>
      -->


        <Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"
                 channelSendOptions="8">

          <Manager className="org.apache.catalina.ha.session.DeltaManager"
                   expireSessionsOnShutdown="false"
                   notifyListenersOnReplication="true"/>

          <Channel className="org.apache.catalina.tribes.group.GroupChannel">
            <Membership className="org.apache.catalina.tribes.membership.McastService"
                        address="228.0.0.4"
                        port="45564"
                        frequency="500"
                        dropTime="3000"/>
            <Receiver className="org.apache.catalina.tribes.transport.nio.NioReceiver"
                      address="auto"
                      port="4000"
                      autoBind="100"
                      selectorTimeout="5000"
                      maxThreads="6"/>

            <Sender className="org.apache.catalina.tribes.transport.ReplicationTransmitter">
              <Transport className="org.apache.catalina.tribes.transport.nio.PooledParallelSender"/>
            </Sender>
            <Interceptor className="org.apache.catalina.tribes.group.interceptors.TcpFailureDetector"/>
            <Interceptor className="org.apache.catalina.tribes.group.interceptors.MessageDispatch15Interceptor"/>
          </Channel>

          <Valve className="org.apache.catalina.ha.tcp.ReplicationValve"
                 filter=""/>
          <Valve className="org.apache.catalina.ha.session.JvmRouteBinderValve"/>

          <Deployer className="org.apache.catalina.ha.deploy.FarmWarDeployer"
                    tempDir="/tmp/war-temp/"
                    deployDir="/tmp/war-deploy/"
                    watchDir="/tmp/war-listen/"
                    watchEnabled="false"/>

          <ClusterListener className="org.apache.catalina.ha.session.ClusterSessionListener"/>
        </Cluster>


      <!-- Use the LockOutRealm to prevent attempts to guess user passwords
           via a brute-force attack -->
      <Realm className="org.apache.catalina.realm.LockOutRealm">
        <!-- This Realm uses the UserDatabase configured in the global JNDI
             resources under the key "UserDatabase".  Any edits
             that are performed against this UserDatabase are immediately
             available for use by the Realm.  -->
        <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
               resourceName="UserDatabase"/>
      </Realm>

      <Host name="freecatz.pe.kr"
       appBase="webapps"
            unpackWARs="false"
            autoDeploy="false">
   <Alias>freecatz.pe.kr</Alias>
   <Context className="org.apache.catalina.core.StandardContext"
                     reloadable="true"
                     allowLinking="true"
                     cachingAllowed="true"
                     charsetMapperClass="org.apache.catalina.util.CharsetMapper"
                     cookies="true"
                     crossContext="true"
                     displayName="API Service"
                     docBase="/home/tomcat/webapps/freecatz.pe.kr/ROOT"
                     path=""
                     privileged="false"
                     swallowOutput="false"
                     useNaming="true"
                     workDir="/home/tomcat/server/apache-tomcat-8.0.43_1/work/freecatz.pe.kr"
                     wrapperClass="org.apache.catalina.core.StandardWrapper">
            </Context>

        <!-- SingleSignOn valve, share authentication between web applications
             Documentation at: /docs/config/valve.html -->
        <!--
        <Valve className="org.apache.catalina.authenticator.SingleSignOn" />
        -->

        <!-- Access log processes all example.
             Documentation at: /docs/config/valve.html
             Note: The pattern used is equivalent to using pattern="common" -->
        <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
               prefix="localhost_access_log" suffix=".txt"
               pattern="%h %l %u %t &quot;%r&quot; %s %b" />

      </Host>
    </Engine>
  </Service>
</Server>

2016년 5월 19일 목요일

[MySqL] my.cnf backup

#
# The MySQL database server configuration file.
#
# You can copy this to one of:
# - "/etc/mysql/my.cnf" to set global options,
# - "~/.my.cnf" to set user-specific options.
#
# One can use all long options that the program supports.
# Run program with --help to get a list of available options and with
# --print-defaults to see which it would actually understand and use.
#
# For explanations see
# http://dev.mysql.com/doc/mysql/en/server-system-variables.html

# This will be passed to all mysql clients
# It has been reported that passwords should be enclosed with ticks/quotes
# escpecially if they contain "#" chars...
# Remember to edit /etc/mysql/debian.cnf when changing the socket location.
[client]
port = 3306
socket = /var/run/mysqld/mysqld.sock
default-character-set = utf8

# Here is entries for some specific programs
# The following values assume you have at least 32M ram

# This was formally known as [safe_mysqld]. Both versions are currently parsed.
[mysqld_safe]
socket = /var/run/mysqld/mysqld.sock
nice = 0

[mysqld]
#
# * Basic Settings
#
user = mysql
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
port = 3306
basedir = /usr
datadir = /var/lib/mysql
tmpdir = /tmp
lc-messages-dir = /usr/share/mysql
skip-external-locking

init_connect = SET collation_connection = utf8_general_ci
init_connect = SET NAMES utf8
character-set-server = utf8
collation-server = utf8_general_ci
log-bin-trust-function-creators=1
log-error=/var/log/mysql/mysql-err.log
log-slow-queries=/var/log/mysql/mysql-slow.log


#
# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
bind-address = 127.0.0.1

#
# * Fine Tuning
#
key_buffer = 128M
max_allowed_packet = 128M
thread_stack = 192K
thread_cache_size       = 8
# This replaces the startup script and checks MyISAM tables if needed
# the first time they are touched
myisam-recover         = BACKUP
max_connections        = 500
#table_cache            = 64
#thread_concurrency     = 10
#
# * Query Cache Configuration
#
query_cache_limit = 1M
query_cache_size        = 16M

#
# * Logging and Replication
#
# Both location gets rotated by the cronjob.
# Be aware that this log type is a performance killer.
# As of 5.1 you can enable the log at runtime!
#general_log_file        = /var/log/mysql/mysql.log
#general_log             = 1
#
# Error log - should be very few entries.
#
log_error = /var/log/mysql/error.log
#
# Here you can see queries with especially long duration
#slow_query_log_file = /var/log/mysql/mysql-slow.log
#slow_query_log      = 1
#long_query_time = 2
#log_queries_not_using_indexes
#
# The following can be used as easy to replay backup logs or for replication.
# note: if you are setting up a replication slave, see README.Debian about
#       other settings you may need to change.
#server-id = 1
#log_bin = /var/log/mysql/mysql-bin.log
expire_logs_days = 10
max_binlog_size         = 100M
#binlog_do_db = include_database_name
#binlog_ignore_db = include_database_name
#
# * InnoDB
#
# InnoDB is enabled by default with a 10MB datafile in /var/lib/mysql/.
# Read the manual for more InnoDB related options. There are many!
#
# * Security Features
#
# Read the manual, too, if you want chroot!
# chroot = /var/lib/mysql/
#
# For generating SSL certificates I recommend the OpenSSL GUI "tinyca".
#
# ssl-ca=/etc/mysql/cacert.pem
# ssl-cert=/etc/mysql/server-cert.pem
# ssl-key=/etc/mysql/server-key.pem



[mysqldump]
quick
quote-names
max_allowed_packet = 128M
default-character-set = utf8


[mysql]
default-character-set = utf8
#no-auto-rehash # faster start of mysql but no tab completition

[isamchk]
key_buffer = 16M

#
# * IMPORTANT: Additional settings that can override those from this file!
#   The files must end with '.cnf', otherwise they'll be ignored.
#
!includedir /etc/mysql/conf.d/

2016년 4월 28일 목요일

2016년 4월 15일 금요일

[LiNuX] vim 환경 설정



아래의 설정을 ~/.vimrc 파일에 적용 한다.

set nu
  : 라인 넘버

set smartindent
  : 좀더 지능적인 들여쓰기 사용

syntax on
  : 구분 강조 기능 사용

filetype on
  : 파일의 종류에 따라 구분 강종

set visualbell
  : 사용자 실수를 경고할때 비프임 대신 비주얼 벨로 경고

set ruler
  : 화면 우측하단에 (행,열) 번호 추가




set tabstop=4
  : 탭간격을 2칸으로 지정

set expandtp
  : 탭문자를 공백문자로 변환

set nobackup
  : 백업파일을 생성하지 않음

set autoindent
  : 자동 들여쓰기 사용

set incsearch
  : 키워드를 입력할때 검색하는 점진 검색 사용

colorscheme evening
  : vi색상테마변경

set background=dark
  : 어두운 배경색 상용

set hisearch
  : 검색어 강조 기능 사용. 데비안7 버젼에서 안되는 것 같음.

set ignorecase
  : 검색,편집 치환시에 대소문자 구분하지 않음


출처 : http://sehkmg.blogspot.kr/2012/01/vi-editor-c.html

2016년 4월 7일 목요일

[EtC] 톰켓 여러개 설치



- Tomcat 1호기(?) 설치 위치 : /usr/local/tomcat-7.0.64_1/
- Tomcat 2호기(?) 설치 위치 : /usr/local/tomcat-7.0.64_2/


Tomcat 1호기(?) 의 server.xml 파일 내용
<Server port="8005" shutdown="SHUTDOWN">
    ... 중략 ...
    <Connector port="8080"
                    protocol="HTTP/1.1"
                    connectionTimeout="20000"
                    redirectPort="8443"
                    disableUploadTimeout="true"
                    enableLookups="false"
                    URIEncoding="UTF-8" />
    ... 중략 ...
    <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />


Tomcat 2호기(?) 의 server.xml 파일 내용
<Server port="8006" shutdown="SHUTDOWN">
    ... 중략 ...
    <Connector port="8081"
                    protocol="HTTP/1.1"
                    connectionTimeout="20000"
                    redirectPort="8443"
                    disableUploadTimeout="true"
                    enableLookups="false"
                    URIEncoding="UTF-8" />
    ... 중략 ...
    <Connector port="8010" protocol="AJP/1.3" redirectPort="8443" />


Tomcat 1호기(?) 의 catalina.sh 파일 내용에 추가
export CATALINA_HOME=/usr/local/tomcat-7.0.64_1
export TOMCAT_HOME=/usr/local/tomcat-7.0.64_1
export CATALINA_BASE=/usr/local/tomcat-7.0.64_1
CATALINA_PID=/usr/local/tomcat-7.0.64_1/bin/tomcat.pid


Tomcat 2호기(?) 의 catalina.sh 파일 내용에 추가
export CATALINA_HOME=/usr/local/tomcat-7.0.64_2
export TOMCAT_HOME=/usr/local/tomcat-7.0.64_2
export CATALINA_BASE=/usr/local/tomcat-7.0.64_2
CATALINA_PID=/usr/local/tomcat-7.0.64_2/bin/tomcat.pid


2016년 4월 1일 금요일

[LiNuX] 한번 입력으로 비밀번호 변경

리눅스의 쉘스크팁트에서 비밀번호를 변경 하는 경우 아래와 같이 사용이 가능 하다.

root@localhost:~# echo '비밀번호' | passwd --stdin 계정

예)
root@localhost:~# echo '@@1234&&' | passwd --stdin freecatz



데비안 계열 리눅스의 passwd 명령에는 --stdin 옵션이 없다.

검색을 해보니 chpasswd 명령을 이용 하면 된다고 한다.


root@localhost:~# echo '계정:비밀번호' | chpasswd

예)
root@localhost:~# echo 'freecatz:@@1234&&' | chpasswd


자세한 내용은 아래의 참고 사이트를 확인 할 것.


참고 사이트 : http://snoopybox.co.kr/1713