먼저 nodejs 가 설치되어 있어야 한다.

프로젝트 디렉토리를 생성 한다. ( 예 : pjtest )

visual studio code 를 실행 후 폴더를 연다.

nodejs 나 electron 개발 시 visual studio code 가 좀 더 편한거 같다.

터미널을 연다.

터미널에서

~> npm init
This utility will walk you through creating a package.json file.
It only covers the most common items, and tries to guess sensible defaults.

See `npm help init` for definitive documentation on these fields
and exactly what they do.

Use `npm install <pkg>` afterwards to install a package and
save it as a dependency in the package.json file.

Press ^C at any time to quit.
package name: (pjtest)
version: (1.0.0)
description: Test Project
entry point: (index.js)
test command: start
git repository:
keywords:
author:
license: (ISC) MIT
About to write to C:\dev\vstudio\workspace\pjTest\package.json:
{
  "name": "pjtest",
  "version": "1.0.0",
  "description": "Test Project",
  "main": "index.js",
  "scripts": {
    "test": "start"
  },
  "author": "",
  "license": "MIT"
}


Is this OK? (yes) y

package.json 이 생성되었으면 반은 성공

일렉트론을 설치해 보자

~> npm install --save-dev electron

added 87 packages, and audited 88 packages in 21s

6 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities

설치완료 스타트(start) 스크립트 설정

package.json 을 열고 script 부분을 아래와 같이 변경한다.

  "scripts": {
    "start": "electron ."
  },

{
  "name": "pjtest",
  "version": "1.0.0",
  "description": "Test Project",
  "main": "index.js",
  "scripts": {
    "start": "electron ."
  },
  "author": "",
  "license": "MIT",
  "devDependencies": {
    "electron": "^13.1.9"
  }
}

설정은 끝났다. 실행할 파일을 만든다. ( index.js , main.html )

index.js

const { app, BrowserWindow } = require('electron')
const path = require('path')

function createWindow() {
    const mainWindow = new BrowserWindow({
        width: 800,
        height: 600
    })

    mainWindow.loadFile('main.html')

}

app.whenReady().then(() => {
    createWindow()

    app.on('activate', function () {
        if (BrowserWindow.getAllWindows().length === 0) createWindow()
    })
})

app.on('window-all-closed', function () {
    if (process.platform !== 'darwin') app.quit()
})

main.html 을 만든다.

<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8">
    <!-- https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP -->
    <meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self'">
    <meta http-equiv="X-Content-Security-Policy" content="default-src 'self'; script-src 'self'">
    <title>Hello World!</title>
  </head>
  <body>
    <h1>Hello World!</h1>
    We are using Node.js <span id="node-version"></span>,
    Chromium <span id="chrome-version"></span>,
    and Electron <span id="electron-version"></span>.
  </body>
</html>

터미널에서 실행해 본다.

~> npm start

 

끝...

자세한 공부는 아래에서 하자.

https://www.electronjs.org/docs/tutorial/quick-start

Posted by 비니미니파
Python2021. 8. 5. 17:53

시작일~종료일 까지 반복 하는 Python 코드

datetime, timedelta

 

from datetime import datetime, timedelta

# 시작일,종료일 설정
start = "2021-08-01"
last = "2021-08-04"

# 시작일, 종료일 datetime 으로 변환
start_date = datetime.strptime(start, "%Y-%m-%d")
last_date = datetime.strptime(last, "%Y-%m-%d")

# 종료일 까지 반복
while start_date <= last_date:
    dates = start_date.strftime("%Y-%m-%d")
    print(dates)

    # 하루 더하기
    start_date += timedelta(days=1)

 

Posted by 비니미니파

기존 방식 


function sum(a,b) {
   var c = a + b;
   return c;
}

sum(1,2); // 3

 


var sum = function (a,b) {
   var c = a + b;
   return c;
}

sum(1,2); // 3

ES6 화살표 함수

function 생략(삭제) (a,b) {  사이에 화살표를 삽입 (a,b) => {


let sum = (a,b) => {
   let c = a + b;
   return c;
};

sum(1,2); // 3

참 쉽죠 ^^

객체 함수(?) 뭔가 복잡해 보이지만 있어 보이는 함수

const  calc = { 
  sum: (a,b) => { 
    return a+b;
  }, 
  sub: (a,b) => {
    return a-b;
  } 
};

calc.sum(1,2); // 3

calc.sub(4,1); // 3

 

w3scholos.com

https://www.w3schools.com/js/js_arrow_function.asp

Posted by 비니미니파
Server(Windows&Linux)2021. 3. 4. 10:55

date 란 명령어를 사용할 수 있습니다.

date - 시스템 시간과 날짜를 출력/설정한다.

~]# date
2021. 03. 04. (목) 10:50:59 KST

date +'%Y-%m-%d' 형식으로 포맷을 설정 할 수 도 있습니다.

~]# date +'%Y-%m-%d'
2021-03-04

 

 

쉘스크립트(shell script)에서 사용할 때는 $를 붙여서 사용 합니다.

~]# vi date.sh
echo $(date +'%Y-%m-%d')

~]# chmod +x date.sh

~]# ./date.sh
2021-03-04

* chmod 는 권한을 설정하는 명령어 입니다.

+x (excute) 실행 권한

Posted by 비니미니파
Server(Windows&Linux)2021. 3. 4. 10:48

리눅스에서는 rdate 라는 명령어로 시간을 동기화 합니다.

 rdate - get the time via the network

~]# rdate -s time.kriss.re.kr

한국표준과학연구원(KRISS) 에서 운영하는 time server 인데 잘 안되네요.

~]# rdate -s time.bora.net

보라넷 시절부터 운영하는 (현재 LG U+) time server 인데 잘 됩니다.

보통은 시간 동기화시 하드웨어(cmos) 까지 세팅을 해야 하기 때문에

 hwclock - query or set the hardware clock (RTC)

명령어를 조합해서 사용합니다.

결론은 아래 와 같이 사용하면 시간동기화 cmos 설정 까지 같이 됩니다.

~]# time -s time.bora.net | hwclock -w
Posted by 비니미니파