Monday, July 25, 2016

3, 6, 9 게임 - Java (korean)

임의의 양의 정수를 정하고 그 수까지 3, 6, 9 게임을 수행

* 해당 숫자에서 3, 6, 9를 포함하고 있는 개수만큼 박수를 침


import java.util.ArrayList;
import java.util.List;

public class dateTest1 {
    public static void main(String[] args) {
        int a = 372;
        List  tsn = new ArrayList();
        tsn.add(3);
        tsn.add(6);
        tsn.add(9);
        boolean clap = false;
        for(int i=1 ; i<=a ; i++) {
            int temp = i;
            while(temp > 0) {
                if(tsn.contains(temp%10)){
                    System.out.print("짝!");
                    clap = true;
                }
                temp = temp/10;
            }
         if(clap) {
              System.out.println();
              clap = false;
              continue;
         } else   
             System.out.println(i);
        }
    }
}




Sunday, July 24, 2016

Import Project from Bitbucket to Eclipse

how to import project to eclipse (by clone),
when you already have project repository on bitbucket


1. File -> Import -> Git -> Project from Git


2. select URI


3. get URI from bitbucket


4. ctrl+v


5. select branches


6. select local directory


7. choose option you want (choose second in my case)



8. following steps are like 'Create Java Project'


9. restart eclipse, check repository and branches


10. right click on project -> Team -> Commit
- select changed files and drag&drop like direction
- summary or memo on commit message
- click 'Commit and Push'


11. OK







Tuesday, July 19, 2016

Create Bitbucket Repository and Connect Eclipse

Ubuntu 14.04
Eclipse Mars 4.5.2


1. join bitbucket and create repository
- dashboard -> repositories -> create repository


- create (can create private repositories only five)



2. install git plug-in on eclipse
- Help -> Install New Software
- fill in ' Work with: http://download.eclipse.org/egit/updates ' or just hit 'git'
- check the box 'Eclipse Git Team Provider'


- next -> next -> I accept  the terms of license agreement -> finish (take few minute.....)
- restart eclipse and can see in import menu


3. create project and connect with bitbucket
- create project and right click on it
- Team -> Share Project


- check 'Use or create repository in parent folder of project'
- choose project you want (already existed....)


- if you can not check, click 'Create Repository' and choose again


4. commit and push
- right click on project -> Team -> Commit
- select and move source files from 'unstaged changes' to 'staged changes'
- commit message is optional


- commit, maybe get error
- right click on project -> Team -> Push Branch 'master'


- fill clone url in ' Location -> URI : ', get from bitbucket


- hit user and password -> next


- next -> finish



- refresh dashboard of bitbucket
- can find commits




ref : http://embedded.kookmin.ac.kr/lectureMobile/index.php/Eclipse_%2B_Github_%EC%82%AC%EC%9A%A9%EB%B2%95


Monday, July 18, 2016

Install Git on Ubintu

2 ways are installing git on ubuntu

A. Installation
1. Using apt-get - it's simple, but not latest version.
$ sudo apt-get install git

2. Download and install manually - it can use latest version.
- install libraries
$ sudo apt-get install libcurl4-gnutls-dev libexpat1-dev gettext \
    libz-dev libssl-dev
- if you want various documents format, need to these libraries
$ sudo apt-get install asciidoc xmlto docbook2x
- download latest release version from follows
Kernel.org( https://www.kernel.org/pub/software/scm/git/ )
GitHub mirror( https://github.com/git/git/releases )
- compile and install
$ tar -zxf git-1.9.1.tar.gz
$ cd git-1.9.1
$ make configure
$ ./configure --prefix=/usr
$ make all doc info
$ sudo make install install-doc install-html install-info


B. Configuration setting
- user
$ git config --global user.name "user name"
$ git config --global user.email emailaddress@email.com
- editor
$ git config --global core.editor editorname
- checking config settings
$ git config --list
- usage help
$ git help 
$ git  --help
$ man git-
ex) $ git help config


C. Generate project
- generate folder
$ mkdir testGitProject
- generate git repository in above folder
$ git init
- add and commit
$ git add *.c
$ git add LICENSE
$ git commit -m 'message about this project version'


D. Clone remote repository
- follow command makes directory named "libgit2" and generate .git in "libgit2". And clone repository
$ git clone https://github.com/libgit2/libgit2
- only differ name of directory "mylibgit", others are same
$ git clone https://github.com/libgit2/libgit2 mylibgit


E. other commands
- check state of repository
$ git status
- commit
$ git commit
- view log
$ git log
- fetch or pull remote repository (pull = fetch + merge)
$ git fetch [remote-name]
$ git pull [remote-name]
- push
$ git push origin master


ref : https://git-scm.com/book/en/v2/Getting-Started-Installing-Git
ref : http://yokang90.tistory.com/47

Thursday, July 14, 2016

Ubuntu Commands and Tips #2

Memo - commands and tips in ubuntu


1. Network setting on ubuntu : when you can't connect lan(wired) network
- open follows
$ sudo gedit /etc/network/interfaces
- text in file
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
# The loopback network interface

auto lo
iface lo inet loopback
- case1_auto : add as follows under text in file
auto eth0
iface eth0 inet dhcp
- case2_manual : add as follows
auto eth0
iface eth0 inet static
        address 192.168.0.2
        netmask 255.255.255.0
        gateway 192.168.0.1
        dns-nameservers ~~~~~
- save and network restart
$ sudo ifdown eth0
$ sudo ifup eth0
ref : http://blog.iolate.kr/89
ref : http://promobile.tistory.com/300


2. Error : " ubuntu wired network unmanaged "
- open follows
$ sudo gedit /etc/NetworkManager/NetworkManager.conf
- file contains, set "managed=true"
[main]
plugins=ifupdown,keyfile

[ifupdown]
managed=false
- save and restart network manager
$ /etc/init.d/network-manager restart
ref : https://wishkane.wordpress.com/2013/07/11/ubuntu-network-manager-wired-networks-are-unmanaged/


3. Activate workspaces
- System Settings -> Appearance -> Behavior
- check "Enable workspaces"


4. 우분투 한글 및 한글 키보드 설정
- System Setting -> Language Support -> Language Support install
- System Setting -> Text Entry -> 왼쪽 하단에 '+'를 이용해서 'Korean(Hangul)' 이라고 되어있는 항목을 추가
(되도록이면 영어 - 한국어 순으로 설정)
- System Setting -> Keyboard -> Shortcuts -> Typing -> Compose Key를 'Disabled'에서 'Right Alt'로 변경
- terminal에 아래의 내용을 입력 (한/영 키 사용 위함)
$ sudo apt-get install dconf-editor
- 설치가 완료되면 org -> gnome -> desktop -> wm -> keybindings -> switch-input-source의 값을 'Hangul'이라고 입력



Wednesday, July 13, 2016

Ubuntu Commands and Tips #1

Memo - commands and tips in ubuntu


1. Check protocol / ip / port/ program id
$ sudo netstat -tnlp
*options : -t(connected TCP protocol) -n(numeric address) -l(port, state : 'LISTEN') -p(program id)


2. Process Termination
$ sudo kill PID


ref : http://zetawiki.com/wiki/%EB%A6%AC%EB%88%85%EC%8A%A4_%EA%B2%8C%EC%9D%B4%ED%8A%B8%EC%9B%A8%EC%9D%B4_%ED%99%95%EC%9D%B8
ref : http://kjvvv.kr/14174
ref : http://linuxism.tistory.com/48


3. Change the command-line prompt color
$ sudo gedit ~/.bashrc
and find this line
#force_color_prompt=yes
remove hash -> 'force_color_prompt=yes'

want to further changes.
ref : https://ubuntugenius.wordpress.com/2011/07/11/how-to-change-the-command-line-prompt-colour-in-the-ubuntulinux-terminal/


4. Back-up application : TimeShift
- installation
$ sudo apt-add-repository -y ppa:teejee2008/ppa
$ sudo aptitude update
$ sudo aptitude install timeshift
ref : https://launchpad.net/timeshift


5. Error : " Failed to fetch http://dl.google.com/linux/chrome/deb/dists/stable/Release Unable to find expected entry ‘main/binary-i386/Packages’ in Release file (Wrong sources.list entry or malformed file) "
- sol
$ sudo gedit /etc/apt/sources.list.d/google-chrome.list
and find the line add [amd64] like follows, Do not edit or replace any other text in this file
deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main
$ sudo apt-get update
ref : http://www.omgubuntu.co.uk/2016/03/fix-failed-to-fetch-google-chrome-apt-error-ubuntu


6. Error : " W: There is no public key available for the following key IDs: 1397BC53640DB551 "
- sol
$ sudo apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 1397BC53640DB551
$ sudo apt-get update
ref : http://askubuntu.com/questions/520718/no-public-key-available-while-upgrading-using-update-manager


7. Error : " W: GPG error: http://http.debian.net wheezy-backports InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 8B48AD6246925553 NO_PUBKEY 7638D0442B90D010 "
- sol.1
do same as above process
- sol.2
do as follows(reference)
ref : http://askubuntu.com/questions/13065/how-do-i-fix-the-gpg-error-no-pubkey





Monday, July 11, 2016

Errors and Problems - text, image, title clipping

Memo - occurred errors & exceptions

Linux 14.04
Eclipse Mars 4.5.2
Jsoup


1. DB Connection
- call URL data
Error : exception in thread main java.net.sockettimeoutexception read timed out
ref : http://stackoverflow.com/questions/6571548/i-get-a-sockettimeoutexception-in-jsoup-read-timed-out

- insert userAgent
Error : exception in thread main org.jsoup.httpstatusexception http error fetching url. status=403
ref : http://stackoverflow.com/questions/14467459/403-error-while-getting-the-google-result-using-jsoup

- url of pdf
Error : org.jsoup.unsupportedmimetypeexception unhandled content type. must be text/*
ref : http://stackoverflow.com/questions/16327105/connection-error-org-jsoup-unsupportedmimetypeexception-unhandled-content-typ



2. Jsoup
Error : jsoup java.util.zip.zipexception not in gzip format
ref : http://stackoverflow.com/questions/13018732/java-util-zip-zipexception-not-in-gzip-format
ref : https://github.com/MrL1605/Pronto-Auth/blob/master/logout.java
Jsoup.connect(url).userAgent(~~~)
.header("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,**;q=0.8")
.header("Accept-Encoding", "gzip, deflate")


Error : java.io.ioexception too many redirects occurred trying to load url
ref : http://stackoverflow.com/questions/7765316/too-many-redirects-occurred-trying-to-load-url-there-arent-any-redirects
ref : https://github.com/MrL1605/Pronto-Auth/blob/master/logout.java
.userAgent("Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:39.0) Gecko/20100101 Firefox/39.0")


Error : exception in thread main org.jsoup.unsupportedmimetypeexception unhandled content type
ref : http://stackoverflow.com/questions/16327105/connection-error-org-jsoup-unsupportedmimetypeexception-unhandled-content-typ
Jsoup.connect(articleURL)~~~ .ignoreContentType(true)


Error : javax net ssl sslhandshakeexception sun security validator validatorexception pkix path building failed
ref : https://www.lesstif.com/pages/viewpage.action?pageId=12451848
$ wget https://java-use-examples.googlecode.com/svn/trunk/src/com/aw/ad/util/InstallCert.java

$ gedit InstallCert.java
remove line "package com.aw.ad.util;" top
$ javac InstallCert.java

$ java -cp ./ InstallCert undertheradar.co.kr
Enter certificate to add to trusted keystore or 'q' to quit: [1]
Added certificate to keystore 'jssecacerts' using alias 'undertheradar.co.kr-1
$ keytool -exportcert -keystore jssecacerts -storepass changeit -file output.cert -alias undertheradar.co.kr-1

$ sudo keytool -importcert -keystore /usr/lib/jvm/java-8-oracle/jre/lib/security/cacerts -storepass changeit -file output.cert -alias undertheradar.co.kr-1