Homoacademycus

  • Installation
  • TechOpinion
  • TroubleShooting
  • Develop Scripts

static build as root

March 29, 2021

Situation

  1. docker volume 으로 연동된 static 디렉토리 : root 소유
  2. react 컨테이너는 root가 아닌 container user 권한으로 개발 중
Continue reading

react TypeError map function

March 27, 2021

Symtoms

Continue reading

nginx proxy pass VS proxy redirect

March 27, 2021

Symtoms

"proxy_redirect default" cannot be used with "proxy_pass" directive 
with variables in /etc/nginx/sites-enabled/myapp.conf
Continue reading

nginx proxy django 502

March 27, 2021

symtom

client <-http-> nginx(proxy) <-http-> was
Continue reading

dockerfile nginx permission

March 27, 2021

Symtoms

Cannot start service nginx-container: OCI runtime create failed: container_linux.go:370: starting container process caused: exec: "/path": permission denied: unknown
Continue reading

docker vscode nonexistent

March 27, 2021

symtoms

vscode remote container with docker

[379 ms] Start: Run in container: cat /etc/passwd
[382 ms] Start: Run in container: test -d /nonexistent/.vscode-server
[383 ms] Exit code 1
[384 ms] Start: Run in container: set -o noclobber ; mkdir -p '/nonexistent/.vscode-server/data/Machine' && { > '/nonexistent/.vscode-server/data/Machine/.writeMachineSettingsMarker' ; } 2> /dev/null
[386 ms] mkdir: cannot create directory '/nonexistent': Permission denied
Continue reading

docker disk full

March 27, 2021

Symtoms

disk space is almost full
Continue reading

react timeout useRef

March 25, 2021

Symtoms

setTimeout in useEffect doesn't work properly
Continue reading

react prop types

March 25, 2021

Symtoms

props type string
Continue reading

react TypeError map function

March 25, 2021

Symtoms

``` Uncaught TypeError: someState.map is not a function

Continue reading

nginx proxy django 502

March 25, 2021

symtom

client <-http-> nginx(proxy) <-http-> was
Continue reading

django unhashable type OrderedDict

March 25, 2021

Symtoms

unhashable type: 'collections.OrderedDict'
Continue reading

django self recursive

March 25, 2021

N:M recursive 관계

the class to which the model is related, which works exactly the same as it does for ForeignKey, including recursive and lazy relationships.
  • 하나의 모델 안에서 ManyToManyField 사용
    class Person(models.Model):
      friends = models.ManyToManyField("self")
    
  • symmetrical=True 속성
    ManyToManyFields on self 에서만 사용 가능(default True)
    Person 모델에 person_set 속성을 추가 안하고 symmetrical 필드로 여겨짐
    intermediary 모델에서도 가능
    
  • Through 모델 : 연관을 위해 DB 테이블로 암시적으로 생성됨
  • Through 모델을 통한 필드는 시리얼라이저에서 Read-only 필드 ``` class Person(models.Model): name = models.CharField(max_length=50)
Continue reading

django rest response content type

March 25, 2021

Symtoms

django rest response object should return correspond content type with request. ``` REST framework supports HTTP content negotiation by providing a Response class which allows you to return content that can be rendered into multiple content types, depending on the client request.

Continue reading

django invalid HTTP HOST header

March 25, 2021

Symtoms

Invalid HTTP_HOST header: 'web_backend_1:22222'. 
The domain name provided is not valid according to RFC 1034/1035.
Continue reading

django instance expected got OrderedDict

March 25, 2021

Symtoms

'Rule' instance expected, got OrderedDict([('title', 'sdfsd'), ('body', 'sdfsdf')])
Continue reading

django direct assignment to reverse related set

March 25, 2021

Symtoms

Direct assignment to the reverse side of a related set is prohibited.
Use related.set() instead.
Continue reading

django create takes 1 positional argument

March 25, 2021

Symtom

create() takes 1 positional argument but 2 were given
Continue reading

create react app reinstall node modules

March 25, 2021

Symtom

  1. installed create-react-app as global module
    npm install -g create-react-app
    
Continue reading

axios TypeError relativeURL

March 25, 2021

Symtoms

``` TypeError: relativeURL.replace is not a function

Continue reading

vscode clear history

March 24, 2021

Symtoms

after removing vscode remote container,
vscode still tried to connect removed remote container
whenever I tried to open new vscode window.
Continue reading

react undefined map function

March 24, 2021

Symtoms

Uncaught TypeError: *** is not a function in a React component
or
someState.map is undefined
Continue reading

react route

March 24, 2021

history stack - HTML5 history API (pushState, replaceState)

Home > One > Two
Continue reading

react local installation not found

March 24, 2021

eslint

installed as Global dev modules

RUN npm install -y -g --save-dev eslint prettier eslint-config-prettier

must install ESLint in Local? ``` eslint –init

Continue reading

react image upload

March 24, 2021

form

  • native html 폼에서 제출 버튼을 누르면 현상태의 input값들을 data 전송 + 페이지 이동
  • react에서는 핸들러 함수로 axios 통신 처리+페이지 이동
  • react는 폼에서도 화면전환없이 데이터를 전달하기 위해서 FormData를 사용
Continue reading

react history push replace

March 24, 2021

Home > Item > Login > Item 순으로 페이지를 이동했을 때 Login 페이지에서 history.push를 사용할 때와 history.replace를 사용할 때의 차이점은 다음과 같다. Push

Continue reading

react fetch axios

March 24, 2021

fetch

let url = 'https://someurl.com';
let options = {
            method: 'POST',
            mode: 'cors',
            headers: {
                'Accept': 'application/json',
                'Content-Type': 'application/json;charset=UTF-8'
            },
            body: JSON.stringify({
                property_one: value_one,
                property_two: value_two
            })
        };
if (response && response.ok) {
    let jsonData = await fetch(url, options).json(); //responseObj.json()
}
  • included in react by default (don’t have to care about module update issue)
  • no response timeout API provided
  • not supported with some browser
  • whend error catched –> always execute .then()
Continue reading

react change port

March 24, 2021

Symtom

react's default dev port is 3000.
I'd like to use another port(80).
Continue reading

react TypeError map function

March 24, 2021

Symtoms

Uncaught TypeError: someState.map is not a function
Continue reading

nginx request options

March 24, 2021

Symtoms

request as POST
response as OPTIONS
Continue reading

nginx proxy pass VS proxy redirect

March 24, 2021

proxy_redirect

changing the Location response header in a 3xx status message.

Continue reading

nginx proxy django 502

March 24, 2021

symtom

```

Continue reading

docker container user

March 24, 2021

Symtoms

when volume is mounted between host and container,
if container user is root, if you work in container,
all file's permission is root.
so you can't access that files on host as non-root user.
Continue reading

django invalid HTTP HOST header

March 24, 2021

Continue reading

create react app reinstall node modules

March 24, 2021

Symtom

  1. installed create-react-app as global module
    npm install -g create-react-app
    
Continue reading

textarea with db br

March 12, 2021

DB 데이터를 불러와서 노출하거나 textarea로 부터 입력받은 데이터를 DB에 저장하려 할 때

var str = document.getElementById("textarea").value;
str = str.replace(/(?:\r\n|\r|\n)/g, '<br />');
document.getElementById("result").value = str;
Continue reading

UnicodeDecodeError

March 12, 2021

Symtoms

UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc6 in position 4: invalid continuation byte
Continue reading

vscode IBUS

March 10, 2021

symtoms

한영 전환키가 vscode 에서만 동작 안함
Continue reading

invoked sed

March 10, 2021

Symtoms

tried to permit sed command only with root permission

chmod 750 /usr/bin/sed

then when use commands ls, mv … related with file operation ``` $ ls .

Continue reading

docker containeruser

March 9, 2021

Container user

Continue reading

react operation

March 8, 2021

map is available with Array, not Set!

const tags = Array(8).fill(0).map((value, index) => (
        <StyledInput
            key={index}
            name={"binary_ip_2_"+index}
        />
)
  • typeof( index ) == int
  • typeof( string+int ) == string
Continue reading

react-gitpage-404

March 8, 2021

증상

react로 빌드해서 배포했는데 index.html에서 react 컴포넌트가 안뜸 gitpage_only_show_index

Continue reading

npm module not found

March 7, 2021

symtoms

when running scripts with create-react-app,
MODULE_NOT_FOUND ~~ ./node_modules/react-scripts/bin/ ~~
Continue reading

nodejs segmentationFault

March 7, 2021

Segmentation fault (core dumped)

Continue reading

jekyll typeTheme

March 7, 2021

초기화

chmod -R a+w /srv/jekyll
bundle install
jekyll build
jekyll serve
Continue reading

jekyll chirpy

March 7, 2021

수정할 점

  • 검색창 엔터 동작 안함
  • 페이지네이션 ul 점으로 뜸
  • 탭 아래에 스크롤바 생기며 블로그 타이틀이 overflow 시 hidden 됨
  • 탭 메뉴에 카테고리 메뉴를 클릭해서 들어가야 카테고리가 보임
Continue reading

django3 postgre

March 7, 2021

  • psycopg2 is required as postgre-client
    File "/usr/local/lib64/python3.6/site-packages/django/db/backends/postgresql/base.py", line 25, in <module>
      import psycopg2 as Database
    ModuleNotFoundError: No module named 'psycopg2'
    
Continue reading

react develop

March 6, 2021

eslint

installed as Global dev modules

RUN npm install -y -g --save-dev eslint prettier eslint-config-prettier

must install ESLint in Local? ``` eslint –init

Continue reading

CSS property difference

March 5, 2021

  • 차이
    align-items: center; //가운데 높이에 배치
    justify-content: center;
    text-align: center;
    
Continue reading

CSS

March 5, 2021

  • 차이
    align-items: center; //가운데 높이에 배치
    justify-content: center;
    text-align: center;
    
Continue reading

django3 sqlite version

March 2, 2021

sypmtoms

``` Django 3.1.7.

Continue reading

django3 pip3 mysqlclient

March 2, 2021

pip3 install mysqlclient

Continue reading

nodejs fileWatcher

February 27, 2021

symtom

Error: ENOSPC: System limit for number of file watchers reached
Continue reading

nginx deploy

February 25, 2021

Firefox에서는 https:// 에서 ws:// 로 이동하는 것이 Firefox에서는 불가능하다고 되어있다고 한다. (https://stackoverflow.com/questions/11768221/firefox-websocket-security-issue/12042843#12042843)

Continue reading

dockerfile

February 25, 2021

  • interactive shell will cause error : must put -y option on package installation
  • Entrypoint can’t point to /bin/bash : can override in docker-compose
Continue reading

docker compose

February 25, 2021

Exit state code

Exited(0) : 
Exited(1) : 
Exited(2) : 
Exited(125) : 
Exited(126) : 
  • Entrypoint can’t point to /bin/bash
  • where there is nothing to run, entrypoint “npm run” cause exited. use “sleep 99”
Continue reading

vscode CPU

February 24, 2021

vscode CPU 점유율 너무 높음

https://github.com/Microsoft/vscode/wiki/Performance-Issues

Continue reading

python2 vs python3

March 23, 2020

파이썬 3 버전

  • print를 일반 함수처럼 표현(괄호 필요 있음)
    print ("Hello Python")
    
Continue reading

Copyright with Homoacademycus