Showing posts with label programing. Show all posts
Showing posts with label programing. Show all posts

Sunday, July 08, 2018

Seoul Bus Information - TOPIS (html, php)


-- html
<!DOCTYPE html>
<html>
<head>
<title>bus find</title>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body style="font-size:12;font-family:verdana">
<b>Search "station - topis.db"</b><br>

<form action="search_stname.php" method="post">
정류소ID<input type="text" name="stid"><input type="submit">
</form>

</body>
</html>

-- php

<?php

$stid = $_POST["stid"];
$stname = $_POST["stname"];
$line = $_POST["line"];
//$stname_es = sqlite_escape_string($stname);


// -- 다국어 -- 정류소아이디(stid) - station table
if ( !empty($stid) ) {
   //$dbhandle = sqlite_open('topis.db', 667, $error);
   //$dbhandle = new SQLite3('topis.db', 667, $error);
   $myPDO = new PDO('sqlite:topis.db');
  
   // if (!$dbhandle) die ($error);
   // $stm0 = "select sn, stid, stname, xypos from station where stid = '01003'";
   $stm0 = "select sn, stid, stnmkr, stnmen, stnmcn, stnmjp, note from mlineinfo where stid like '%".$stid."%';";
   $result = $myPDO->query($stm0);
   echo "<br><hr>정류소ID(stid)검색: ".$stm0."<br>";

   //$ok = sqlite_exec($dbhandle, $stm, $error);
   //if (!$ok) die("Error: $error"); 
   //echo "Form submitted successfully";
   echo "<table><tr><td>연번</td><td>정류소ID</td><td>정류소명</td><td>en</td><td>cn</td><td>jp</td></tr>";
   foreach($result as $row) {
      echo "<td>" . $row['sn'] . "</td>";
      echo "<td>" . $row['stid'] . "</td>";
      echo "<td>" . $row['stnmkr'] . "</td>";
      echo "<td>" . $row['stnmen'] . "</td>";
      echo "<td>" . $row['stnmjp'] . "</td>";
      echo "</tr>";
   }
   echo "</table>";
}

?>

Seoul Bus Information - TOPIS (download, sqlite)

# -*- coding: utf-8 -*-
#+STARTUP: overview
#+LANGUAGE: ko
#+PROPERTY: header-args:sqlite :dir ~/pkg/map/topis/20180403/ :db topis.db :var rel="cur" :results line :colnames yes :exports results
: #+PROPERTY: header-args:sqlite :dir ~/org/ :db journal.db :var rel="cur" :results silent :colnames yes
: #+PROPERTY: Effort_ALL 0 0:10 0:20 0:30 1:00 2:00 4:00 6:00 8:00


* download
** 정류장
http://data.seoul.go.kr/dataList/datasetView.do?infId=OA-15067&srvType=F&serviceKind=1

http://opengov.seoul.go.kr/data/15223948

서울시 버스정류소 위치 데이터(20180502).xls

** 노선
http://topis.seoul.go.kr/refRoom/openRefRoom_3_1.do
201804_Bus_노선.xls

http://topis.seoul.go.kr/
교통정보 자료실 > 버스 운행노선 현황
홈 > 교통자료실 > 기타 정보 > 버스 운행노선 현황

http://topis.seoul.go.kr/refRoom/openRefRoom_1_2.do#
번호     제목     첨부     작성일     다운로드수
966    2017 11월 버스 운행노선 현황    첨부파일 있음    2017-12-22    52
965    2017 10월 버스 운행노선 현황    첨부파일 있음    2017-12-22    4

서울시 교통량 생성개요
수집기간 : 1년 365일, 24시간 (00 ~ 24시)
수집범위 : 주요간선도로 및 도시고속도로

    도심24개소
    시계36개소
    교량22개소
    간선54개소
    도시고속9개소

http://bus.go.kr/

순번    노선ID    정류소ID    노선번호    정류소명    정류소번호    Y좌표    X좌표    YX좌표
1    100100124    102000271    0017    청암자이아파트    03689    37.5345469961    126.9465552752    37.5345469961, 126.9465552752


* 다국어 버스노선
서울시 버스 정류소 노선도 다국어 목록 정보.xls

#+name: creating
#+begin_src sqlite :var tb="mlineinfo"
-- drop table if exists $tb;
create table $tb (
  sn int, -- 연번
  stid varchar(30), -- 정류소ID
  stnmkr varchar(50), -- 정류소명
  stnmen varchar(100), -- 정류소명
  stnmcn varchar(100), -- 정류소명
  stnmjp varchar(100), -- 정류소명
  note varchar(50) -- 유형
);
#+end_src

#+RESULTS: creating

#+name: insert
#+begin_src sqlite :var tb="mlineinfo"
insert into $tb values (0,'my id', 'my station','a-en' ,'a-cn', 'a-jp','note');
#+end_src

#+RESULTS: insert

#+begin_src sqlite :var tb="mlineinfo"
select count(*) from $tb;
#+end_src

#+RESULTS:
| count(*) |
|----------|
|        0 |

#+begin_src sqlite :var tb="mlineinfo"
delete from $tb;
#+end_src

#+RESULTS:



* lineinfo

-- 기존
업체명,노선번호,유형,
기점,종점,인가대수,
인가거리,운행시간,
운행횟수,최소,최대,
첫차시간,막차시간

company,line,types,
starting,ending,nums,
distance,taketime,
carsby,mimby,maxby,
stime,etime


-- 변경
업체명,노선번호,유형,
기점,종점,인가대수,
운행대수,예비대수, -- new added 2 column
인가거리,운행시간,
총운행횟수,최소,최대,
첫차시간,막차시간

#+name: creating
#+begin_src sqlite :var tb="lineinfo"
drop table $tb;
#+end_src

#+name: creating
#+begin_src sqlite :var tb="lineinfo"
-- drop table if exists $tb;
create table $tb (
  company varchar(50), -- 업체명
  line varchar(20), -- 노선번호
  types varchar(10), -- 유형
  starting varchar(50), -- 기점
  ending varchar(50), -- 종점
  nums int, -- 인가대수
  allocated int, -- 운행대수
  areserved int, -- 예비대수
  distance int, -- 인가거리
  taketime int, -- 운행시간
  carsby int, -- 운행횟수
  mimby int, -- 최소
  maxby int, -- 최대
  stime varchar(5), -- 첫차
  etime varchar(5) -- 막차시간
);
#+end_src
* station

#+name: creating - Year 2017
#+begin_src sqlite :var tb="station"
drop table if exists $tb;
create table $tb (
  sn integer, -- 순번
  lid int2, -- 노선ID
  stid int2, -- 정류소ID
  lnum varchar(10), -- 노선번호
  stname varchar(50), -- 정류소명
  stnum varchar(15), -- 정류소번호
  xpos varchar(20), -- Y좌표
  ypos varchar(20), -- X좌표
  xypos varchar(40) -- YX좌표
);
#+end_src


#+name: creating Year 2018
#+begin_src sqlite :var tb="station"
drop table if exists $tb;
create table $tb (
  sn integer, -- 순번 --> add excel -- o
  stid varchar(14), -- 정류소ID or 정류소번호 -- o
  stname varchar(50), -- 정류소명 --> o
  xpos varchar(20), -- Y좌표 o
  ypos varchar(20), -- X좌표 o
  xypos varchar(40) -- YX좌표 --> add
);
#+end_src

Monday, May 14, 2018

전자정부 개발자 개발환경 (부제: 개미굴)

From. http://www.egovframe.org/wiki/doku.php?id=egovframework:dev2:install_guide


egovframework:dev2:install_guide
From: http://www.egovframe.org/wiki/doku.php?id=egovframework:dev2:install_guide


* Install Guide

순서에 맞게 설치


* Eclipse Neon(4.6) Packages 이용 시 설치가이드

- 소프트웨어
 > 버전
 > 자동설치/업데이트주소
 > 필수여부


** Eclipse 4.6.3 필수
http://www.eclipse.org/downloads/packages/eclipse-ide-java-ee-developers/neon3
 → Eclipse IDE for Java EE Developers 다운로드


** Spring Core 3.8.4 필수
http://dist.springsource.com/release/TOOLS/update/e4.5
 → Core / Spring IDE → Spring IDE Core


** UML2 Extension 5.2.3 필수
http://download.eclipse.org/releases/neon
 → Modeling → UML2 Extender SDK


** Subversive SVN Connector     6.0.4 필수
 http://download.eclipse.org/technology/subversive/4.0/update-site/
   → Subversion SVN Team Provider Plugin
   → Subversive SVN Team Provider(4.0.5) 설치

 http://community.polarion.com/projects/subversive/download/eclipse/6.0/neon-site/
   → Subversive SVN Connectors
   → Subversive SVN Connectors(6.0.4) 설치, SVNKit 1.8.14 Implementation(6.0.4) 설치


** eGovFrame     3.7.0  필수
    http://maven.egovframe.kr:8080/update_3.7/에서 필요 기능 설치

** JUnit     4.12     필수
  Eclipse에 JUnit이 내장되어 있으므로 별도 설치 필요 없음


** MyBatipse     1.1.0  선택
     http://dl.bintray.com/harawata/eclipse
  → MyBatipse → MyBatipse(1.1.0)


** PMD     4.0.14 선택
    https://dl.bintray.com/pmd/pmd-eclipse-plugin/updates/ (not work)
  → PMD for Eclipse 4 → PMD Plug-in (4.0.14) 설치

   ---> use this
   http://netassist.dl.sourceforge.net/project/pmd/pmd-eclipse/update-site-latest/

   (ref. https://github.com/pmd/pmd-eclipse-plugin/issues/19)


** FindBugs     3.0.1 선택
    http://findbugs.cs.umd.edu/eclipse


** Properties Editor     6.0.4 선택
    http://propedit.sourceforge.jp/eclipse/updates/
 → PropertiesEditor 설치


** EclEmma     3.0.0
    http://update.eclemma.org/
 → EcliEmma → EclEmma Java Code Coverage


** Gradle     1.0.21 선택
     http://download.eclipse.org/buildship/updates/e45/releases/1.0
 → Buildship: Eclipse Plug-ins for Gradle
  → Buildship: Eclipse Plug-ins for Gradle


** Developer Tools     23.0.7
     http://rgladwell.github.com/m2e-android/updates/
 → Developper Tools → 모두설치     안드로이드 개발 필수


** Android Connector for M2E     1.4.0
    http://rgladwell.github.com/m2e-android/updates/
 → Android for Maven Eclipse → Android for Maven Eclipse
     안드로이드 개발 필수

Monday, April 03, 2017

raspberry pi - mariadb install and change default data dir

* mariadb

sudo apt-get install mariadb-server

mysql -u root -p
 "mypassword"

CREATE DATABASE IF NOT EXISTS new_database;
SELECT database();
DROP DATABASE new_database;
DROP DATABASE IF EXISTS new_database;


** check
mysql -u root -p

: Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
SELECT database();

: +------------+
: | database() |
: +------------+
: | NULL       |
: +------------+
: 1 row in set (0.01 sec)

select @@datadir;
: +-----------------+
: | @@datadir       |
: +-----------------+
: | /var/lib/mysql/ |
: +-----------------+
: 1 row in set (0.00 sec)

exit
: Bye


** change default data directory


*** stop service
- stop service
sudo service mysql stop

> check
sudo service mysql status

- directory move

> permission check
 --> /var/lib/mysql
   drwxr-xr-x  4 mysql   mysql   4.0K  4월  3 15:44 mysql

ls -alh /var/lib/mysql/


*** move default directory with tar-mode
mkdir $new_volume/mysql

cd $new_volume/mysql
mkidr -p $new_volume/log
sudo cp -apR /var/log/mysql /$new_volume/log/


*** copy with rsync

ref.
>> https://www.digitalocean.com/community/tutorials/how-to-change-a-mariadb-data-directory-to-a-new-location-on-centos-7


*** modify my.cnf
sudo cp /etc/mysql/my.cnf /etc/mysql/my.cnf-dist
sudo vi /etc/mysql/my.cnf


-- my.cnf
#+title:
#+begin_src conf
[client]
port            = 3306
socket          = /var/run/mysqld/mysqld.sock

# modified for utf8 client
default-character-set=utf8  # <-- added with modified


[mysqld]
...
socket          = /var/run/mysqld/mysqld.sock # leave it
# datadir               = /var/lib/mysql # modified
datadir         = /NEW_VOLUME_ROOT/mysql # modified
tmpdir          = /tmp # leave it
...
# -- modify
bind-address          = 127.0.0.1
# bind-address            = 0.0.0.0

# -- modify
log_error = /NEW_VOLUME_ROOT/log/mysql/error.log
#log_bin                        = /var/log/mysql/mysql-bin.log
..
# expire_logs_days      = 10
expire_logs_days        = 2 # modified
# max_binlog_size         = 100M
max_binlog_size         = 10M # modified
#binlog_do_db           = include_database_name
#binlog_ignore_db       = include_database_name

# ssl-ca=/etc/mysql/cacert.pem
# ssl-cert=/etc/mysql/server-cert.pem
# ssl-key=/etc/mysql/server-key.pem
#
# added following 2 line for utf8 -- modified
init_connect=SET collation=utf8_general_ci
init_connect=SET NAMES utf8
# -- default-character-set=utf8 # error
# character-set-server=utf8 # new DB create with option character-set
# collation-server=utf8_general_ci


[client]
port=3306
# unmodified:w

# socket=/mnt/volume-nyc1-01/mysql/mysql.sock


!includedir /etc/my.cnf.d

#+end_src


*** test connect

tail -f /NEW_VOLUME_ROOT/log/mysql/error.log

sudo service mysql start

sudo service mysql status
: ● mysql.service - LSB: Start and stop the mysql database server daemon
:    Loaded: loaded (/etc/init.d/mysql)
:    Active: active (running) since 월 2017-04-03 16:39:16 KST; 33s ago
:   Process: 28500 ExecStop=/etc/init.d/mysql stop (code=exited, status=0/SUCCESS)
:   Process: 29028 ExecStart=/etc/init.d/mysql start (code=exited, status=0/SUCCESS)
:    CGroup: /system.slice/mysql.service
:            ├─29053 /bin/bash /usr/bin/mysqld_safe
:            ├─29206 /usr/sbin/mysqld --basedir=/usr --datadir=/NEW_VOLUME_ROOT/mysql --plugin-dir=/usr/li...
:            └─29207 logger -t mysqld -p daemon.error


- check local connect
mysql -u root -p

\quit


- check host connect
mysql -h MY_MARIADB_HOST -u root -p
: Enter password:
: ERROR 1130 (HY000): Host 'pii.local' is not allowed to connect to this MariaDB server


*** create table & user

sudo netstat -tap | grep mysql

mariadb-client-core-10.0

- connect
mysql -u root -p
or
mysql -h server_ip -P 3306 -u root -p

- root: create user
CREATE USER 'myuser'@'%' IDENTIFIED BY 'mypassword';
flush privileges;

: CREATE USER 'myuser'@'192.168.0.3';
: CREATE USER 'myuser'@'%';
: CREATE USER myuser@test IDENTIFIED BY 'mypassword';
: mysql -h my_server_ip -u myuser -p

-- other options
CREATE USER foo
  WITH MAX_QUERIES_PER_HOUR 10
  MAX_UPDATES_PER_HOUR 20
  MAX_CONNECTIONS_PER_HOUR 30
  MAX_USER_CONNECTIONS 40;

-- check grant or privileges

 > commit;
flush privileges;
status;

 > if super priviledge need - with grant option
#+begin_src sql
GRANT ALL PRIVILEGES ON journaldev.* TO 'USER_ME'@'%' WITH GRANT OPTION;
GRANT ALL PRIVILEGES ON journaldev.* TO 'USER_ME'@localhost WITH GRANT OPTION;
#+end_src


*** client install

$ mysql-workbench
The following packages will be REMOVED:
  mariadb-client-core-10.0

The following NEW packages will be installed:

  libaec0 libarmadillo6 libarpack2 libcrypto++6 libctemplate3
  libdap17v5 libdapclient6v5 libepsilon1 libfreexl1 libgdal20
  libgeos-3.5.0 libgeos-c1v5 libgeotiff2 libhdf4-0-alt libhdf5-10
  libkmlbase1 libkmldom1 libkmlengine1 libminizip1 libmysqlclient20
  libmysqlcppconn7v5 libnetcdf11 libodbc1 libogdi3.2 libpq5 libproj9
  libqhull7 libspatialite7 libsuperlu4 libsz2 liburiparser1
  libvsqlitepp3v5 libxerces-c3.1 libzip4 mysql-client mysql-client-5.7
  mysql-client-core-5.7 mysql-utilities mysql-workbench
  mysql-workbench-data odbcinst odbcinst1debian2 proj-bin proj-data
  python-cffi-backend python-cryptography python-enum34 python-idna
  python-ipaddress python-mysql.connector python-paramiko
  python-pyasn1 python-pyodbc python-pysqlite2 ttf-bitstream-vera


- ubuntu client (only)
sudo apt-get install mariadb-client-core-10.0

※ mysql-workbench will automatically install
mysql-client, mysql-client-core then
remove mariadb-clinet

so, reinstall mariadb-clinet-core

sudo apt-get install mariadb-client-core-10.0

then clinet prompt will change from "mysql" to "MariaDB"
MariaDB [(none)]>


** remove mysql start service
https://mariadb.com/kb/en/mariadb/installing-system-tables-mysql_install_db/ https://www.digitalocean.com/community/tutorials/how-to-change-a-mariadb-data-directory-to-a-new-location-on-centos-7


** Prevent MySQL from starting on boot up
sudo update-rc.d -f mysql remove

then
  You would then start mysql manually using

sudo service mysql start


** referance
How To Change a MariaDB Data Directory to a New Location on CentOS 7
https://www.digitalocean.com/community/tutorials/how-to-change-a-mariadb-data-directory-to-a-new-location-on-centos-7


sudo service mysql status

: ● mysql.service - LSB: Start and stop the mysql database server daemon
:    Loaded: loaded (/etc/init.d/mysql)
:    Active: inactive (dead) since 월 2017-04-03 15:54:30 KST; 58s ago
:   Process: 28500 ExecStop=/etc/init.d/mysql stop (code=exited, status=0/SUCCESS)

Thursday, January 17, 2013

Websocket in HTML5

* Websocket
- 간단한 채팅
- 화이트 보드
- 메시지 동기화 및 모니터링


HTML5 Draft 의 Websocket 의 기능은 마음에 들지만
'이제 와서는 사족 같다' .

소켓으로 만들든 Json 같은 javascript 로 하든 구동이 되는데 굳이 브라우저에 다 넣을 필요가 있는가다. 여튼 잠재된 보안 문제로

** Internet Explorer
- Internet Explorer 9.0.8080.16414 256-bit, RC Version 에서는 기능을 막아 놨다.

** Firefox
- 3.4x 이후 버전은 기본 옵션으로 Enabled 됨
- Firefox 4.0 Beta... 12 인가 14인가...  에서는 다음과 같이 활성화 시켜야 한다.

Browse to about:config
-  Set network.websocket.enabled  value to true (Default Enabled)
-  Set network.websocket.override-security-block preferences to true(Default Not Enabled)
   ; 재시작 없이 작동 함

** Google Chrome
10.648.133 - Enabled


참고로,

http://blog.chromium.org/2009/12/web-sockets-now-available-in-google.html

자바스크립트로 보기
javascript:alert("WebSockets are " + (window.WebSocket ? "" : "not ") + "supported");

;;; 링크
----------------

A Silverlight client (and a JavaScript client, via the HTML bridge)
can only communicate using the proposed WebSocket protocol using ports
in the range 4502-4534.




요즘 웹 프로그래밍

1998년 첨 c 로 Web CGI 를 할땐 별 대안이 없었다.
하긴 cgi 를 fortran, basic, lisp 로 할 순 없는 노릇이니(물론 가능하다)

한 번은 3천만원짜리 IBM 워크스테이션에서 cgi 를 돌리려는데 컴파일러가 없었다. 3천짜리 워크스테이션이다. 옆엔 1억2천짜리 F50 ibm 서버도 있는데 이놈도 컴파일러가 없다. 개발 팩키지를 구입하지 않아서 컴파일러가 없었다.

해서 쓰지 않던 데스크탑에 리눅스를 설치하고, 네트웍 Bridge를 구성한다고 일주일 동안 커널 컴파일 하고,  apache 에 붙여 cgi 를 돌렸다.

그리고, php, python, aspx,c# 를 쓴다.

최근 Ruby on Rails를 보다 이젠 프레임워크와 패턴의 세상이 왔다는 생각이 들었다. 솔직히, 그냥 interactive 하려면 굳이 패턴이나 프레임워크 까지 갈 필요가 있겠는가...

여튼 요즘은 C#, Java 이런걸로 웹을 한다! 한때는 asp, php 도 무겁다고 느꼈었던 걸 보면 장족의 발전 아닌가

Pranten

 Pranten