2018/10/08

여자에 대한 명언

마누라가 죽었다, 나는 자유다!
- 보들레르

부유한 독신주의자에게는 무거운 세금이 부과되어야 한다. 그런 사람만 남보다 행복하다는 것은 불공평하기 때문에
- 오스카 와일드

여자들은 나에게 있어서는 코끼리와 같다. 바라보는 것은 좋아하지만 집에까지 가져오고 싶지는 않다.
- 필즈

여자가 결혼할 때 보는 세 가지 조건이 있다. 첫째는 남자의 돈이고, 둘째는 남자 집안의 돈이며, 셋째는 자신에게 들어올 돈이다.
- 로마 격언

남자가 마누라한테 차 문을 열어줄 땐, 그 차가 새차거나 그 마누라가 새 마누라일 때 뿐이다.
-에든버러 공작 필립 왕자

여자와 포도주는 남자의 판단을 망친다.
- 스페인 격언

여자의 눈물을 믿지 마라. 마음대로 되지 않을 때 우는 것이 여자의 천성이기 때문이다.
- 소크라테스

그대는 가난한 남자를 사랑하는 여자를 본 적이 있습니까?
- 마르셀 파뇰

두 여자를 화해시키는 일보다 유럽을 통일하는 것이 더 쉽다.
- 나폴레옹

한 여자의 결점을 알고 싶다면 그녀의 친구들 앞에서 그녀를 칭찬해보라.
- 벤저민 프랭클린

미인은 떼를 지어 다니지 않는다.
- 아라비아 격언

2018/08/18

[기사] 테슬라 또 내부고발.."도난사건 은폐·직원 도청 등"

테슬라 또 내부고발.."도난사건 은폐·직원 도청 등"


일론 머스크 최고경영자(CEO)의 상장폐지 발언으로 미국 증권당국의 조사를 받게 된 테슬라가 이번에는 원자재 도난 사건과 마약거래 등을 은폐하고 직원들을 도청ㆍ감시해왔다는 논란에 휩싸였다.

CNBC 등 현지 언론에 따르면 테슬라의 리튬이온 전지공장인 기가팩토리에서 보안업무를 담당해온 전직 직원 칼 한센은 16일(현지시간) 이 같은 내용으로 증권거래위원회(SEC)에 테슬라를 고발했다. 앞서 엔지니어출신인 전직 직원 마틴 트립이 테슬라 차량에 들어간 일부 배터리에 문제가 있다고 밝힌 후 두 번째 내부고발이다.


한센은 테슬라가 올해 1분기 기가팩토리에서 3700만달러 규모의 구리, 원자재를 도난당한 사실을 주주들에게 숨기고, 휴대전화와 컴퓨터를 도청하거나 해킹하는 방식으로 직원들을 감시해왔다고 주장했다.

또한 테슬라가 기가팩토리의 직원이 마약거래에 관여했을 수 있다는 사실을 인지했음에도 현지 법 집행기관과 마약단속국(DEA)에 밝히지 않았다고 고발했다. 그는 내부적으로 이 같은 문제를 회사 측에 제기한 이후 자신이 7월 중순께 보복 해고됐다고도 덧붙였다.


출처 : https://news.v.daum.net/v/20180817091700834?f=m

2018/07/25

[DB] New Features of Oracle 12c

New Features of Oracle 12c Summarized

01. Pluggable Databases Through Database Consolidation:

Oracle is doing every thing to jump into the cloud bandwagon. With 12C, Oracle is trying to address the problem of Multitenancy through this feature. There is a radical change and a major change in the core database architecture through the introduction of Container Databases also called CBD and Pluggable Databases (PDB). The memory and process is owned by the Container Database. The container holds the metadata where the PDBs hold the user data. You can create upto 253 PDBs including the seed PDB.
In a large setup, it is common to see 20 or 30 different instances running in production environment. With these many instances, it is a maintenance nightmare as all these instances have to be separately
•Upgraded
•Patched
•Monitored
•Tuned
•RAC Enabled
•Adjusted
•Backed up and
•Data Guarded.
With Pluggable Databases feature, you just have to do all this for ONE single instance. Without this feature, prior to 12C, you would have to create separate schemas and there is always a thread of security how much ever the isolation we build into it. There are problems with namespace conflicts, there is always going to be one public synonym that you can create. With PDBs you can have a separate HR or Scott schema for each PDB, separate Emp, Dept Tables and separate public synonyms. Additionally, 2 PDBs can talk to each other through the regular DB Link feature. There is no high startup cost of creating a database any more. Instead of one instance per day, the shift is into one instance per many databases. For the developer community, you can be oblivious of all this and still continue to use the PDBs as if it were a traditional database, but for the DBAs the world would look like it has changed a lot.
Another cool feature is, you can allocate a CPU percentage for each PDB.
Another initiative being, it has announced a strategic tieup with salesforce.com during the first week of July 2013.

02. Redaction Policy:

This is one of the top features in Oracle 12C. Data Redaction in simple terms means, masking of data. You can setup a Data Redaction policy, for example SSN field in a Employee table can be masked. This is called redaction. From Sql Develop you can do this by going to the table: Employee->Right click on Security Policy->click on New->click on Redaction Policy->Enter SSN.
When you do a select * from employee, it will show that the SSN is masked.
The new data masking will use a package called DBMS_REDACT. It is the extension to the FGAC and VPD present in earlier versions.
By doing this, whoever needs to view the data will be able to see it where as the other users will not be able to view it.

03. Top N Query and Fetch and offset Replacement to Rownum:

With the release of Oracle Database 12c, Oracle has introduced this new SQL syntax to simplify fetching the first few rows. The new sql syntax "Fetch First X Rows only" can be used.

04. Adaptive Query Optimization and Online Stats Gathering:

With this feature, it helps the optimizer to make runtime adjustments to execution plan which leads to better stats. For statements like CTAS (Create Table As Select) and IAS (Insert As Select), the stats is gathered online so that it is available immediately.

05. Restore a Table easily through RMAN:

Earlier if you had to restore a particular table, you had to do all sorts of things like restoring a tablespace and or do Export and Import. The new restore command in RMAN simplifies this task.

06. Size Limit on Varchar2, NVarchar2, Raw Data Types increased:

The previous limit on these data types was 4K. In 12C, it has been increased to 32,767 bytes. Upto 4K, the data is stored inline. I am sure everyone will be happy with this small and cute enhancement.

07. Inline PL/SQL Functions and Procedures:

The in line feature is extended in Oracle 12C. In addition to Views, we can now have PL/SQL Procedures and Functions as in line constructs. The query can be written as if it is calling a real stored procedure, but however the functions do not actually exist in the database. You will not be able to find them in ALL_OBJECTS. I think this will be a very good feature for the developers to explore as there is no code that needs to be compiled.

08. Generated as Identity/Sequence Replacement:

You can now create a col with 'generated as identity' clause. Thats it. Doing this is equivalent to creating a separate sequence and doing a sequence.nextval for each row. This is another handy and a neat feature which will help developer community. This is also called No Sequence Auto Increment Primary Key.

09. Multiple Indexes on a Single Column:

Prior to 12C, a column cant be in more than one index. In 12C, you can include a column in B-tree index as well as a Bit Map index. But, please note that only one index is usable at a given time.

10. Online Migration of Table Partition or Sub Partition:

You can very easily migrate a partition or sub partition from one tablespace to another. Similar to how the online migration was achieved for a non-partitioned table in prior releases, a table partition or sub partition can be moved to another tablespace online or offline. When an ONLINE clause is specified, all DML operations can be performed without any interruption on the partition|sub-partition which is involved in the procedure. In contrast, no DML operations are allowed if the partition|sub-partition is moved offline.

11. Temporary UNDO:

Prior to 12C, undo records generated by TEMP Tablespace is stored in the undo tablespace. With Temp undo feature in 12C, temp undo records can be stored in temporary table instead of UNDO TS. The benefit is - reduced undo tablespace and reduced redo log space used.
SQL> ALTER SYSTEM SET PGA_AGGREGATE_LIMIT=2G;
SQL> ALTER SYSTEM SET PGA_AGGREGATE_LIMIT=0; --disables the hard limit

12. In Database Archiving:

This feature enables archiving rows within a table by marking them as inactive. These inactive rows are in the database and can be optimized using compression but are not visible to the application. These records are skipped during FTS (Full Table Scan).

Other Features:

Advanced Replication and Streams are Dead. It is being replaced with Oracle Golden Gate.
Invisible Columns. You can now have a invisible column in a table. When a column is defined as invisible, the column won’t appear in generic queries
PGA Aggregate Limit setting:
In 12c, you can set a hard limit on PGA by enabling the automatic PGA management, which requires PGA_AGGREGATE_LIMIT parameter settings. Therefore, you can now set the hard limit on PGA by setting the new parameter to avoid excessive PGA usage.
DDL Logging:
The DDL statements will automatically get recorded in xml/log file if ENABLE_DDL_LOGGING is set to True. ALTER SYSTEM|SESSION SET ENABLE_DDL_LOGGING=TRUE

2018/07/20

[명언] 군자삼계(君子三戒), 군자삼외(君子三畏), 군자삼락(君子三樂)

군자삼계(君子三戒) - 《논어》〈계씨편(季氏篇)〉


      원 문 해 설

子曰 君子有三戒 군자에게는 경계해야 할 일이 세 가지 있으니

少之時 血氣未定 戒之在色 젊을때는 혈기가 잡히지 않은지라 경계할 것이 여색이고

及其長也 血氣方剛 戒之在鬪 장성하여 혈기가 강해지면 경계할 것이 싸움이며

及其老也 血氣旣衰 戒之在得 나이가 들어 혈기가 쇠진하면 경계할 것이 물욕이다.

군자삼외(君子三畏) - 《논어》〈계씨편(季氏篇)〉


       원 문 해 설

子曰 君子有三畏 군자에게는 두려운 것이 세 가지 있으니

畏天命 하늘의 명을 두려워하고,

畏大人 대인(자신보다 학덕이 높은 사람)을 두려워하고,

畏聖人之言 성인의 말씀을 두려워한다.

군자삼락(君子三樂) - 《맹자(孟子)》〈진심편(盡心篇)〉


       원 문 해 설

君子有三樂 군자에게는 세 가지 즐거움이 있으니,

而王天下不與存焉 천하의 왕이 되는것은 여기에 넣지 않는다.

父母俱存 兄弟無故 一樂也 부모님이 모두 살아계시고 형제들이 무고한 것이 첫째 즐거움이요,

仰不愧於天 俯不怍於人 二樂也 하늘을 우러러 부끄럽지 않고, 사람들을 굽어보아 부끄럽지 않은것이 두 번째 즐거움이며,

得天下英才 而敎育之 三樂也 천하의 영재를 얻어 가르치는 것이 세 번째 즐거움이다.

2018/07/17

[python] 한글 wordcloud

%matplotlib inline
import matplotlib.pyplot as plt
from wordcloud import WordCloud
import numpy as np
from PIL import Image

cloud_mask = np.array(Image.open("cloud.png"))

text = """내 피 땀 눈물 내 마지막 춤을
다 가져가 가
내 피 땀 눈물 내 차가운 숨을
다 가져가 가
내 피 땀 눈물
내 피 땀 눈물도
내 몸 마음 영혼도
너의 것인 걸 잘 알고 있어
이건 나를 벌받게 할 주문
Peaches and cream
Sweeter than sweet
Chocolate cheeks
and chocolate wings
But 너의 날개는 악마의 것
너의 그 sweet
앞엔 bitter bitter
Kiss me 아파도 돼
어서 날 조여줘
더 이상 아플 수도 없게
Baby 취해도 돼 이제 널 들이켜
목 깊숙이 너란 위스키
내 피 땀 눈물 내 마지막 춤을
다 가져가 가
내 피 땀 눈물 내 차가운 숨을
다 가져가 가
원해 많이 많이 많이 많이
원해 많이 많이 많이 많이
많이 많이
원해 많이 많이 많이 많이
원해 많이 많이 많이 많이
많이 많이
아파도 돼 날 묶어줘
내가 도망칠 수 없게
꽉 쥐고 날 흔들어줘
내가 정신 못 차리게
Kiss me on the lips lips
둘만의 비밀
너란 감옥에 중독돼 깊이
니가 아닌 다른 사람 섬기지 못해
알면서도 삼켜버린 독이 든 성배
내 피 땀 눈물 내 마지막 춤을
다 가져가 가
내 피 땀 눈물 내 차가운 숨을
다 가져가 가
원해 많이 많이 많이 많이
원해 많이 많이 많이 많이
많이 많이
원해 많이 많이 많이 많이
많이 많이
나를 부드럽게 죽여줘
너의 손길로 눈 감겨줘
어차피 거부할 수조차 없어
더는 도망갈 수조차 없어
니가 너무 달콤해 너무 달콤해
너무 달콤해서
내 피 땀 눈물
내 피 땀 눈물"""

wordcloud = WordCloud(font_path="/Library/Fonts/AppleGothic.ttf", 
                                        background_color="white", 
                                        relative_scaling=0.2,
                                        mask=cloud_mask )
wordcloud.generate(text)

print("\t피땀눈물 - 방탄소년단\n")

plt.figure(figsize=(12,12))
plt.imshow(wordcloud, interpolation='bilinear')
plt.axis("off")
plt.show()
피땀눈물 - 방탄소년단
masking image
 

2018/07/16

[python] binary search tree

오름차순으로 정렬된 리스트에서 특정한 값의 위치를 찾는 알고리즘이다. 처음 중간의 값을 임의의 값으로 선택하여, 그 값과 찾고자 하는 값의 크고 작음을 비교하는 방식을 채택하고 있다. 처음 선택한 중앙값이 만약 찾는 값보다 크면 그 값은 새로운 최댓값이 되며, 작으면 그 값은 새로운 최솟값이 된다. 검색 원리상 정렬된 리스트에만 사용할 수 있다는 단점이 있지만, 검색이 반복될 때마다 목표값을 찾을 확률은 두 배가 되므로 속도가 빠르다는 장점이 있다.
def bsearch(items, key):
    # recursive function을 독립 시키기 위한 adapter function
    return bs_helper(items, key, -1, len(items))

def bs_helper(items, key, lower, upper):
    # Base condition : 값을 못 찾았을 경우
    if lower + 1 == upper:
        return None
    mid = (lower + upper) // 2
    # 값을 찾았을 경우 return
    if key == items[mid]:
        return mid
    # 아래 쪽에 위치할 경우 lower range 를 검색
    if key < items[mid]:
        return bs_helper(items, key, lower, mid)
    else:
        return bs_helper(items, key, mid, upper)


a = [1, 2, 4, 5, 7, 9, 10, 34, 45, 89, 345]
print(bsearch(a, 5))

[python] check parenthesis matching

import queue

class PaMatch():
    def __init__(self):
        super(PaMatch, self).__init__()
        self.lst = queue.LifoQueue()
        self.check = 0
    
    def push(self, a):
        self.lst.put(a)
        
    def pop(self):
        return self.lst.get()
    
    def checkMatch(self, string):
        for i in range(len(string)):
            if string[i] == "(":
                self.push(i)
            elif string[i] == ")":
                if self.lst.qsize() >= 1:
                    # 첫번째 출력이 아닐 경우 "," 추
                    if self.check > 0:
                        print(",", end="")
                    print("({},{})".format(self.pop(),i), end="")
                    self.check += 1
                # parenthsis가 맞지 않을 경우 남은 자리를 보여주고 종료
                else:
                    print("\nNot matched : {}".format(i), end="")
        # parenthsis가 맞지 않을 경우 남은 자리를 보여주고 종료
        for i in range(self.lst.qsize()):
            print("\nNot matched : {}".format(self.lst.get()), end="")

        print("")
   
#  Good Matching Case
string = "((((A+B)-C)*D)/S*A)"
A = PaMatch()
A.checkMatch(string)

# Not Good Matching Case 1
string2 = "(((((((A+B)-C)*D)/S*A"
B = PaMatch()
B.checkMatch(string2)

# Not Good Matching Case 2
string3 = "((((A+B)-C)*D)))/S*A))))"
C = PaMatch()
C.checkMatch(string3)

(3,7),(2,10),(1,13),(0,18)
(6,10),(5,13),(4,16)
Not matched : 3
Not matched : 2
Not matched : 1
Not matched : 0
(3,7),(2,10),(1,13),(0,14)
Not matched : 15
Not matched : 20
Not matched : 21
Not matched : 22
Not matched : 23

2018/07/14

[python] 공공 Data를 이용한 동네 예보 처리

공공 Data 활용을 위한 service_key 신청은 Link를 참조.

# -*- coding: utf-8 -*-
import datetime as dt
import requests as req
from bs4 import BeautifulSoup

w_items = {"POP":["강수확률", "%"], "PTY":["강수형태", ""], "R06":["6시간 강수량", "mm"], "REH":["습도", "%"], "S06":["6시간 신적설", "cm"], 
           "SKY":["하늘상태", ""], "T3H":["3시간 기온", "°C"], "TMN":["아침 최저 기온", "°C"], "TMX":["낮 최고 기온", "°C"], 
           "UUU":["풍속(동서성분)","m/s"], "VVV":["풍속(남북성분)","m/s"], "WAV":["파고", "m"], "VEC":["풍향", ""], "WSD":["풍속", "m/s"]}
wind_dict = {0:"N",1:"NNE",2:"NE",3:"ENE",4:"E",5:"ESE",6:"SE",7:"SSE",8:"S",9:"SSW",10:"SW",11:"WSW",12:"W",13:"WNW",14:"NW",15:"NNW",16:"N"}
rain_dict = {0:"없음", 1:"비", 2:"진눈깨비", 3:"눈"}

# 가장 최근의 기상청 예보 시간(02:10 이후 3시간 단위) get
def get_rpt_time():
    base_time = dt.datetime.now() - dt.timedelta(hours=2) - dt.timedelta(minutes=10)
    hour = int(base_time.strftime("%H"))
    rehour = str(hour//3*3 + 2).zfill(2)
    return [base_time.strftime("%Y%m%d"), rehour + "00"]

# 풍향 계산용
def get_wind_type(i):
    return wind_dict[(i + 22.5 * 0.5)//22.5]

def get_sky_status(i):
    if i >= 0 and i <= 2: return "맑음"
    elif i >= 3 and i <= 5: return "구름조금"
    elif i >= 6 and i <= 8: return "구름많음"
    elif i >= 9 and i <= 10: return "흐림"

def get_real_value(c, s):
    if c.string == "VEC":
        return get_wind_type(int(s.string))
    elif c.string == "SKY":
        return get_sky_status(int(s.string))
    elif c.string == "PTY":
        return rain_dict[int(s.string)]
    return s.string

# have to change with your service_key
service_key = "MJqwsP2VlmHlaRh0BMwMAtDvhfFu6k59h%2B1Svp2A%......."
nx = 60    # 서울 기준
ny = 127   # 서울 기준

date = get_rpt_time()

base_url = "http://newsky2.kma.go.kr/service/SecndSrtpdFrcstInfoService2/ForecastSpaceData?ServiceKey={}&base_date={}&base_time={}&nx={}&ny={}"
url = base_url.format(service_key, date[0], date[1], nx, ny)

contents = req.get(url)
weather = BeautifulSoup(contents.content, 'lxml-xml')

print("\t **************************************")
print("\t Report Time :", date[0], date[1])
print("\t **************************************")
for item in weather.find_all("item"):
    print("\t", w_items[item.category.string][0], " : ", get_real_value(item.category, item.fcstValue), end = "")
    if w_items[item.category.string][1] != "":
        print(w_items[item.category.string][1])
    else:
        print()
<결과>
         **************************************
         Report Time : 20180715 1100
         **************************************
         강수확률  :  10%
         강수형태  :  없음
         습도  :  50%
         하늘상태  :  맑음
         3시간 기온  :  31°C
         낮 최고 기온  :  33.0°C
         풍속(동서성분)  :  3.1m/s
         풍향  :  WSW
         풍속(남북성분)  :  1.3m/s
         풍속  :  3.4m/s

[python] get current datetime

from datetime import datetime
datetime.today()                # get current date
datetime.today().year        # get current year
datetime.today().month    # get current month
datetime.today().day         # get current day
datetime.today().hour        # get current hour
datetime.today().strftime("%Y/%m/%d %H:%M:%S")  # get current date with format yyyy/mm/dd hh24:mm:ss

[python] all markers in matplotlib.pypolot.scatter

import matplotlib.pyplot as plt
import numpy as np
import matplotlib

markers = {'.': 'point', ',': 'pixel', 'o': 'circle', 'v': 'triangle_down', '^': 'triangle_up', '<': 'triangle_left', '>': 'triangle_right', 
                    '1': 'tri_down', '2': 'tri_up', '3': 'tri_left', '4': 'tri_right', '8': 'octagon', 's': 'square', 'p': 'pentagon', '*': 'star', 
                    'h': 'hexagon1', 'H': 'hexagon2', '+': 'plus', 'x': 'x', 'D': 'diamond', 'd': 'thin_diamond', '|': 'vline', '_': 'hline', 
                    'P': 'plus_filled', 'X': 'x_filled', 0: 'tickleft', 1: 'tickright', 2: 'tickup', 3: 'tickdown', 4: 'caretleft', 5: 'caretright', 
                    6: 'caretup', 7: 'caretdown', 8: 'caretleftbase', 9: 'caretrightbase', 10: 'caretupbase', 11: 'caretdownbase', 
                    'None': 'nothing', None: 'nothing', ' ': 'nothing', '': 'nothing'}

N = 50
x = np.random.rand(N)
y = np.random.rand(N)
area = (30 * np.random.rand(N))**2 

for key, value in markers.items():
    plt.scatter(x, y, s=area, c="g", alpha=0.5, marker=key, label=value)
    plt.legend(loc=1)
    plt.show()







































[art] 백남준 작품 in Korea

어렸을 적 백남준은 매우 유복한 환경에서 자랐다. 집에는 피아노나 전축은 물론 당시에 서울에 딱 두 대 밖에 없었던 캐딜락도 있었고, 해방 전에 유치원(애국유치원)에 다녔으며 한국 전쟁의 그 아비규환 속에서도 파인애플을 먹을 정도의 부잣집이었다. 그의 어머니는 '돈은 물 쓰듯 쓰는 거다'라고 했다고 한다. 조부 백윤수는 청나라 비단을 독점 판매했던 거부로, 종로5가와 동대문시장 일대의 포목상 절반이 그의 것이었고, 국상 때 만조백관의 상복과 제복을 일체 도맡았을 정도로 섬유업계의 막강한 실력자였다. 후에 그는 직물, 대부업, 제약회사 등을 세웠고, 재산은 한성은행 자본금의 3배에 달했다.
백남준은 당시 상류층만 다니던 수송국민학교경기공립중학교를 다녔는데, 해방 전 그 시절에 학교에는 풀장과 영사기가 있어서, 당시 학부모였던 대한극장 사장이 학교에서 직접 영화를 상영하기도 했다고 한다. 또한 경기중학교 음악교사로, 후에 이대 음대학장을 지냈던 신재덕에게 피아노를, 작곡가 이건우에게 작곡을 배웠다. 1949년에는 이승만 대통령의 부탁으로 무기구입을 위해 홍콩으로 갔다는 설이 있는 부친 백낙승씨의 통역으로 따라가 홍콩의 로이덴 스쿨로 전학한다. 백남준은 이때 영어와 중국어를 배우게 된다.  - 나무위키

1. 단군


3. 거북선 


2018/07/13

[bash] while in one line

while true;do ls -l; echo "---------------------------"; sleep 5;done

useful links


Visual Studio Code - python
https://code.visualstudio.com/docs/python/python-tutorial


운영체제 - 경성대학교 양희재 교수

컴퓨터 구조 - 숭실대학교 김병기 교수

소프트웨어 공학 - 동국대학교 최은만 교수

알고리즘 - 명지대학교 이충기 교수

데이터베이스 - 이화여자대학교 용환승 교수

수리 통계학 - 국민대학교 강주성 교수

선형 대수 - 국민대학교 이옥연 교수

선형 대수 한양대학교 이상화 교수

확률 및 통계 - 한양대학교 이상화 교수

Deep Learning 정리 Blog

DataScience School

Python 연습 Site

Python Data Science Handbook

수학 관련 정리

Thinker with a Neutal Network

2018/07/08

docker Oracle 12c

Oracle Standard Edition 12c Release 1


Oracle Standard Edition 12c Release 1 on Ubuntu
This Dockerfile is a trusted build of Docker Registry.

Installation

docker pull sath89/oracle-12c
Run with 8080 and 1521 ports opened:
docker run -d -p 8080:8080 -p 1521:1521 sath89/oracle-12c
Run with data on host and reuse it:
docker run -d -p 8080:8080 -p 1521:1521 -v /my/oracle/data:/u01/app/oracle sath89/oracle-12c
Run with Custom DBCA_TOTAL_MEMORY (in Mb):
docker run -d -p 8080:8080 -p 1521:1521 -v /my/oracle/data:/u01/app/oracle -e DBCA_TOTAL_MEMORY=1024 sath89/oracle-12c
Connect database with following setting:
hostname: localhost
port: 1521
sid: xe
service name: xe
username: system
password: oracle
To connect using sqlplus:
sqlplus system/oracle@//localhost:1521/xe

Password for SYS & SYSTEM:
oracle
Connect to Oracle Application Express web management console with following settings:
http://localhost:8080/apex
workspace: INTERNAL
user: ADMIN
password: 0Racle$
Apex upgrade up to v 5.*
docker run -it --rm --volumes-from ${DB_CONTAINER_NAME} --link ${DB_CONTAINER_NAME}:oracle-database -e PASS=YourSYSPASS sath89/apex install
Details could be found here: https://github.com/MaksymBilenko/docker-oracle-apex
Connect to Oracle Enterprise Management console with following settings:
http://localhost:8080/em
user: sys
password: oracle
connect as sysdba: true
By Default web management console is enabled. To disable add env variable:
docker run -d -e WEB_CONSOLE=false -p 1521:1521 -v /my/oracle/data:/u01/app/oracle sath89/oracle-12c
#You can Enable/Disable it on any time
Start with additional init scripts or dumps:
docker run -d -p 1521:1521 -v /my/oracle/data:/u01/app/oracle -v /my/oracle/init/SCRIPTSorSQL:/docker-entrypoint-initdb.d sath89/oracle-12c
By default Import from docker-entrypoint-initdb.d is enabled only if you are initializing database (1st run).
To customize dump import use IMPDP_OPTIONS env variable like -e IMPDP_OPTION="REMAP_TABLESPACE=FOO:BAR"
To run import at any case add -e IMPORT_FROM_VOLUME=true
In case of using DMP imports dump file should be named like ${IMPORT_SCHEME_NAME}.dmp
User credentials for imports are ${IMPORT_SCHEME_NAME}/${IMPORT_SCHEME_NAME}
If you have an issue with database init like DBCA operation failed, please reffer to this issue
TODO LIST
  • Web management console HTTPS port
  • Add functionality to run custom scripts on startup, for example User creation
  • Add Parameter that would setup processes amount for database (Currently by default processes=300)
  • Spike with clustering support
  • Spike with DB migration from 11g
In case of any issues please post it here.

[c] Fibonacci

#include 

int main(){
    unsigned long a,b,cnt,i,n1,n2,n;

    scanf("%ld %ld",&a, &b);

    n2=1;
    n1=2;
    cnt=0;

    for(i=3;i=a && n<=b)
        {   
            cnt++;
            printf("cnt %ld : %ld\n", cnt, n );
        }   
        n2 = n1; 
        n1 = n;
    }   

    printf("%ld\n", cnt);
}

[c] Mine Sweep

#include 
#include 
#include 
#include 

#define debug_

char mine[100][100];
int nmax = 0, mmax = 0;

int getMin(int a, int b){ 
    if(a>b)   
        return b;
    else    
        return a;
}

int getMax(int a, int b){ 
    if(a>b)
        return a;
    else
        return b;
}

int getCnt(int x, int y){ 
    int i = 0, j = 0, cnt = 0;

    for(i=getMax(x-1, 0);i<=getMin(x+1, nmax);i++){
        for(j=getMax(y-1, 0);j<=getMin(y+1, mmax);j++){
            if(mine[i][j] == '*'){
                cnt ++; 
            }   
#ifdef debug
            printf("---- getCnt : i:%d, j:%d, cnt:%d\n", i, j, cnt); 
#endif
        }   
    }   
    return cnt;
}

int main(){
    char buf[101];
    int s, i, j, n, m;

    s = 1; /* Set counter */
    n = 0; /* Row counter in set */
    m = 0; /* Column counter in row */
    while(gets(buf)){

        if(strlen(buf) < 1)
            break;

        if(n == 0){ 
            nmax = buf[0] - '0';
            mmax = buf[2] - '0';
#ifdef debug
            printf("---- nmax : %d, mmax : %d\n", nmax, mmax);
#endif
            if(nmax == 0 && mmax == 0)
                break;
        }
        else{
            for(j=0;j < mmax;j++){
                mine[n-1][j] = buf[j];
#ifdef debug
                printf("---- n : %d, m : %d, char : %c\n", n, j, mine[n-1][j]);
#endif
            }
        }

        if(n == nmax){
            printf("Field #%d\n", s);
            for(i=0;i < nmax;i++){
                for(j=0;j< mmax;j++){
                    if(mine[i][j] == '*')
                        printf("%c",'*');
                    else
                        printf("%d",getCnt(i, j));

                    if(j == (mmax - 1))
                        printf("\n");
                }
            }
            s++;
            n = 0;
            memset(mine,'\0',sizeof(mine));
        }
        else{
            n++;
        }
    }

    return 0;
}

[c] Stack


#include 
#include 
#define MAXSIZE 100 

typedef struct stack{
    int stk[MAXSIZE];
    int top;
} STACK;


void Push(int x, STACK *s){
    int num;
    s->top ++; 
    printf("Push %d\n", s->top);
    s->stk[s->top] = x;
    return;
}

int Pop(STACK *s){
    int num;
    printf("Pop %d\n", s->top);
    num = s->stk[s->top];
    s->top --; 
    return num;
}

void Init(STACK *s){
    s->top = -1; 
    printf("Init %d\n", s->top);
    return;
}

int main(){

    STACK *s = (STACK *)malloc(sizeof(STACK));

    Init(s);

    Push(1, s); 
    Push(2, s); 
    Push(3, s); 

    printf("%d\n", Pop(s));
    printf("%d\n", Pop(s));
    printf("%d\n", Pop(s));

}

2018/07/07

[c] learn-c.org


Welcome

Welcome to the learn-c.org free interactive C tutorial.
Whether you are an experienced programmer or not, this website is intended for everyone who wishes to learn the C programming language.
There is no need to download anything - Just click on the chapter you wish to begin from, and follow the instructions. Good luck!


http://www.learn-c.org

2018/06/12

[python] text from url

import requests
import json
url = 'http://www.quotesondesign.com/wp-json/posts'
resp = requests.get(url)

# srting to Python data type
c_lst = json.loads(resp.text)

for txt in c_lst:
    # unpacking
    for key, value in txt.items():
        print(key, ' : ', value)

2018/06/11

[python] json

import json

# Json String to variable
sample = {
    "glossary": {
        "title": "example glossary",
        "GlossDiv": {
            "title": "S",
            "GlossList": {
                "GlossEntry": {
                    "ID": "SGML",
                    "SortAs": "SGML",
                    "GlossTerm": "Standard Generalized Markup Language",
                    "Acronym": "SGML",
                    "Abbrev": "ISO 8879:1986",
                    "GlossDef": {
                        "para": "A meta-markup language, used to create markup languages such as DocBook.",
                        "GlossSeeAlso": ["GML", "XML"]
                    },
                    "GlossSee": "markup"
                }
            }
        }
    }
}

# string to Json encoding with formatting
sample_json = json.dumps(sample, indent = 4)
print(sample_json)
print('')

# Decoding Json String to Python type
sample_structured_json = json.loads(sample_json)
print(sample_structured_json)
print('')

print(sample_structured_json['glossary']['title'])
print('')

for i in sample_structured_json['glossary']['GlossDiv']['GlossList']['GlossEntry']:
    print(i)

2018/06/08

[python] binary data write to file

# binary data generation
bdata = bytes(range(0, 256))

# check length and data
print('size :', len(bdata), '\ndata : ', bdata)

# set offset and chunk size, get data size
offset = 0
chunk = 10
size = len(bdata)

# write to file and get size
with open('bfile.bin', 'wb') as bf:
    while offset <= size:
        bf.write(bdata[offset:offset+chunk])
        offset += chunk

# check file
! cat bfile.bin

2018/05/04

MongoDB


SQL vs. NoSQL Solution
NoSQL data stores
  • Abandon SQL and ACID for simpler data and concurrency model
  • BASE semantics as opposed to ACID gaurantees
    • Basically Available
    • Sofe state - system state may change over time even without input
    • Eventually consistent
  • Key-value, document, column-family, graph


MongoDB
charateristics
A document is the basic uint of data
A collection can be thought of as a table with a dynamic schema
Single instance can host multiple independent databases
each of which can have its own colletions
comes with a Javascript shell
document is an ordered set of keys with associated values
type-sensitive and case-sensitive
documents cannot contain duplicate keys
key-value paris in documents are ordered

collections
is a group of documents
have dynamic schemas
a single collection have any number of different shapes

databases
groups collections into databases
can host several databases
each database is stored in separate files on disk
to store all data for a single application in the same database

shell
show dbs, use db_name, show collections
db.createCollection("collection_name")
db.collection_name.find()  
.findOne()
.find({"address.building":"386", "address.building":"381"})
==> 조건이 중복될 경우 마지막 381 조건에 만족하는 결과만 return
.find({$and:[{"address.street":"Canal Street"},{"address.building":"386"}]})
.find({$or:[{"address.building":"386"},{"address.building":"382"}]})
.find({"address.street":"Canal Street"},{"address.building":1, _id:0})
//0:column 제외, 1:조회 _id default 조회
.find({amount:{$lt:20, $gt:5}})

.insert({hello:'world'})
.insertOne({hello:'world'})
.insertMany({hello:'world'}, {good:'night'})

.update({title:'my blog'}, {title:'my blog name'})
.update({title:'my blog'}, {$set:{title:'my blog name'}})
.update({title:'my blog'}, {$unset:{title:''}})
attribute가 하나 였을 경우 record가 삭제됨
.update({title:'my blog'}, {$inc:{pageviews: 1}})
.update({title:'my blog'}, {$push:{name: "joe"}})
adds elements to the end of an array
.update({title:'my blog'}, {$push:{name: {$each:["bob", "kim", "lee"]}}})
use $addToSet to prevent duplicates
.update({title:'my blog'}, {$pop:{name: 1}})
removes it from the end, -1 from the begining
.update({title:'my blog'}, {$pull:{name: "lee"}})

.replaceOne({title:'my blog'},{header:'your blog'})

.remove()
if no parameter, remove all !
.remove({title:'my blog name'})
.deleteOne({title:'my blog name'})
.deleteMany({hello:'world'}, {good:'night'})

.drop()
deletes everyting, even the colletion

db.dropDatabase()

Data Types
Null : {"x" : null} 
Boolean : {"x" : true) 
Number : {"x" : 3.14}, {"x" : NumberLong(" 
0 
"foobar"} 
String : {"x" 
Date : {"x" : new Date()} 
• Objectld : {"x" : Objectld()} (a 12-byte ID f
  • Arrays can contain different data types
{"things":["pie", 3.14]}
  • embedded documents
"name" : "John Doe", 
"address" : { 
"123 Park 
"street" 
"city" 
"state" 
"Anytown't, 
t'NY'i
  • every documents stored in MongoDB must have an "_id" key
  • all documents must be smaller than 16MB

2018/03/25

for Data Scientist

Useful links

  1. scikit-learn [link]

Data Visualization


  1. Information Visualization
Scientific Visualization : 일상의 내용을 visualization
Information Visualization : abstract data visualization

  1. Definition
Provide tools that present data in a way to help understand and gain insight from it

  1. InfoVis is interdisciplinary
graphics
cognitive psychology
HCI : using users and tasks to guide design and evaluation

  1. Expressiveness and Effectiveness
Expressiveness : Vis idiom should express all of, and only, the information in the dataset attributes
Effectiveness : Most important attributes should be encoded with the most effective channels --> ranking of channels
correctness, accuracy, ant truth

  1. Stevens' Power Law
감각 자극과 감각 경험 간의 관계가 지수 함수로 표시된다는 공식화를 말한다. 감각의 종류에 따라 지수가 다르다
   , p : perceived magnitude, a : actual magnitude,
              length judgement  1
              area judgement     1
              volume judgement 1

  1. Relative vs. Absolute Judgements
perceptual system mostly operates with relative judgements, not absolute
Weber's Law : the perceived change in stimuli is proportional to the initial stimuli

  1. Preattentive Processing : cognitive operations done preattentively, without the need for focused attention
"pop out" of a display : easily detected regardless of the number of distractors
target detection, boundry detection, region tracking, counting

  1. Design Guidelines/Principles
Visual Information Seeking Mantra
Overview first, zoom and filter, details on demand

  1. Measuring Misrepresentation



  1. Design Principles
avoid chartjunk
use small multiples
utilize narratives of space and time

  1. Visualization Analysis and Design
    1. Definitions and Motivations
computer-based visualization systems provide visual representations of datasets designed to help people carry out (some) tasks more effectively
  1. Big picture
    1. VIS is suitable when there is a need to argument human capabilites
    2. design visual representations to help people perform task more effectively
    1. design space is HUGE!
    2. resource limitations
    1. analysis instance
WHY the user needs it, WHAT data is shown, HOW the idiom is designed
  1. Transitional use
gain a clear understanding of user's task --> purely computational solution --> monitoring automatic system is doing right
  1. Long-term use
    1. Exploratory analysis
    2. Vis tool for presentation
  2. Why use interactivity?
    1. impossible to show everything at once
    2. handling complexity and volume
  3. Visualization Idioms : distinct approach to creating and manipluating visual representations
a tool that serves well for one task can be poorly to another

  1. Analysis : Four Levels for Validation
so many possible ways.
Four Levels of vis design
  output of upstream level --> input to downstream level
    : upstream errors inevitably cascade down

Four kinds of threats to validate
  1. wrong problem : they don't do that
  2. wrong abstraction : showing wrong thing
  3. wrong encoding/interaction technique : way you show don't work
  4. wrong algorithm : code is too slow
--> proto-typing 통해서 미리 validation 있다.

  1. What : Data Abstraction
Datasets 
@ Data Types 
Items + Attributes 
@ Data and Dataset Types 
Tables 
Networks & 
Trees 
Links 
Fields 
Grids 
Åt-ttibJte' 
Networks 
Trees 
What? 
Positions 
Geometry 
Grids 
Clusters, 
Sets, Lists 
@ Dataset Types 
Tables 
Aru 
Multidimensional Fable 
+ Geometry {Spatial) 
fields (Continuous) 
Attributes 
Attribute Types 
Categorical 
Ordered 
-O Otdina/ 
Qoantitative 
Ordering Direction 
Sequential 
+ Diverging 
Cyclic

psexeo @

  • semantics : real-world meaning
  • attribute, item, link, grid, position
  • set : unordered group of items
  • list : ordered group of items
  • cluster : grouping based on attribute similarity
  • path : ordered set + links connecting nodes

  • data abstraction : domain-specific to GENERIC

  1. Why: Task Abstraction
    • task abstraction should guide data abstraction
    • Analyze > Search > Query
    • Discover, Present, Enjoy, Annotate, Record, Derive(경험이 많을 수록 사용 -> visualization idiom 사용의 폭이 넓어짐)

  1. Marks and Channels
    • idiom can be break down into Marks and Channels
    • Mark
      • basic graphical element : point(0D), line(1D), area(2D), volumn(3D)
      • Items / Nodes
      • Links
@ Containment 
@ Connection
  • Channel : a way to control the apperance of marks
@ Position 
Horizontal 
@ Shape 
@ Size 
Length 
Vertical 
Area 
Both 
@ Color 
@ Tilt 
volume
  • Expressiveness types and effectiveness rankings(1,2 순위는 외울것)

@ MaOnitude Channels&deted Attributes 
Position on common scale 
Position on unaligned scale 
Length (ID size) 
Tllt/angle 
@-identity Channels: Categorical Attributes 
Spatial region 
Color hue 
Motion 
Shape

 * Better encoding ?
Car 
Accord 
AMC Pacer 
Audi 5000 
BMW 320i 
Champ 
Chev Nova 
Civic 
Datsun 210 
Datsun 810 
Deville 
Le Car 
Linc Cont 
Horizon 
Mustang 
Peugeot 
Saab goo 
Subaru 
Volvo 260 
VW Dasher 
USA Japan Germany 
Car nationality for 1979 
France 
Sweden 
Nation
Bar size 인하여 국가 간의 우선순위 혹은 우열을 내제적으로 표현하고 있어 불필요한 정보를 전달하고 있.
Length를 변경하는데 Stevens' power law 따라 effectiveness ranking 높은 position으로 변경하여 이를 제거한다.
Car 
A xord 
AMC Pacer 
Audi 5000 
BMW 320i 
Champ 
Chev Nova 
Civic 
Datsun 210 
Datsun 810 
Deville 
Le Car 
Linc Cont 
Horizon 
Mustang 
Peugeot 
sub 900 
Subaru 
Volvo 260 
V-vv Dasher 
USA 
Japan Germany 
France 
Sweden 
Nation 
Car nationality for 1979

  • position dominates the user's mental model
  1. Preattentive processing
    1. cognitive operation done preattentively, without the need for focused attention
    1. popout, segmentation effects
      1. many channels : tilt, size, shape, proximity, shadow direction, but not parallel line.

  1. Gestalt Psychology
인간은 자신이 본 것을 조직화하려는 기본 성향을 가지고 있으며, 전체는 부분의 합 이상이라는 점을 강조하는 심리학.
  1. proximity : same spatial region
  2. similarity : same value as other categorical channels (color hue, motion, shape)
  3. connectedness : 모든 channel을 압도하는 가장 강력한 표현
  4. continuity : 물리적으로 가장 단순하고 이해하기 쉬운 방향으로 이해한다.
  5. common fate : things moving together
  1. luminance contrast : Perception of color and luminance is contextual, based on relative judgements

  1. Perception and Visual Patterns
    1. Gestalt Principles
      1. Grouping : avoid explicit grouping
        1. Proximity
        2. Similarity
        3. Continuity
        4. Common Fate

  1. Perception of Forms
    1. Closure : form complete, closed figures to increase regularity
    2. Area/Figure and Ground/Relative size : smaller one as figure, larger one as ground
    3. Symmetry : symmetry images are perceived collectively, even in spite of distance

  1. Fixation-Saccade Cycle
    1. Fixation : brief stationary period when detail information is acquired
    2. saccade : flicking rapidly to a new location
  2. postattentive amnesia

  1. Rule of Thumbs
    1. Overview
      1. no unjustified 2D / 3D
      2. eyes beats memory
      3. resolution over immersion
      4. function first, form next

  1. Interaction Design and Design Principles
    1. fundamental design goals is provide the right affordances, good mapping
      1. right affordance : perceived and actual properies
      2. right conceptual model
      3. good mapping : a relationship between controls and their movements or effects
      4. casuality : iterpesentation of feedback