- stream, filter, predicate 사용 예제

import java.util.Arrays;
import java.util.List;
import java.util.function.Predicate;
import java.util.stream.Collectors;

public class Playground {
    
    public static List<String> friends = Arrays.asList("taewon", "brian", "timmy", "turner", "ed", "edd", "eddy", "samuel", "jackson", "miranda", "Samantha", "sarah");
    
    public static void main(String[] args) {
        List<String> startsWithT = friends.stream()
                .filter(checkIfStartsWith("t"))
                .collect(Collectors.toList());

        List<String> startsWithE = friends.stream()
                .filter(checkIfStartsWith("e"))
                .collect(Collectors.toList());
    }
    
    public static Predicate<String> checkIfStartsWith(String letter) {
        return name -> name.startsWith(letter);
    }
}

 

- 총 길이 찾기 

import java.util.Arrays;
import java.util.List;

public class Playground {
    
    public static List<String> friends = Arrays.asList("taewon", "brian", "timmy", "turner", "ed", "edd", "eddy", "samuel", "jackson", "miranda", "Samantha", "sarah");
    
    public static void main(String[] args) {
        int sum = friends.stream()
                .mapToInt(name -> name.length())
                .sum();
    }
    
}

 

- 긴 이름 기준 조건으로 이름 찾기, optional 

import java.util.Arrays;
import java.util.List;
import java.util.Optional;

public class Playground {
    
    public static List<String> friends = Arrays.asList("taewon", "brian", "timmy", "turner", "ed", "edd", "eddy", "samuel", "jackson", "miranda", "Samantha", "sarah");
    
    public static void main(String[] args) {
        Optional<String> longestName = friends.stream()
                .reduce((name1, name2) -> name1.length() >= name2.length() ? name1 : name2);
        
        longestName.ifPresent(System.out::println);
    }
    
}

 

 

 

 

출처 : 

https://tomining.tistory.com/48

'Java' 카테고리의 다른 글

자바 예외 계층  (0) 2023.01.31

<!DOCTYPE html>

<html lang="en">

<head>

    <meta charset="UTF-8">

    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <title>Document</title>

</head>

<body>

<div id="app">

    {{str}} parent instance === {{num}}

    <app-header v-bind:child="num"></app-header>

    <app-content v-on:what="child_to_parent"></app-content>

</div>    

<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>

<script>

    var appHeader = {

        template: '<div>child component === {{child}}</div>',

        props: ['child']

    }

    var appContent = {

        template: '<div>content<button v-on:click="passem">pass</button></div>',

        methods: {

            passem: function(){

                this.$emit('what', 10);

            }

        }

    }

    new Vue({

        el: '#app',

        data: {

            str: 'hi',

            num: 0,

        },

        components: {

            'app-header'appHeader,

            'app-content'appContent,

        },

        methods: {

            child_to_parentfunction(e){

                console.log(e);

                this.num = e;

            }

        }

    })

</script>

</body>

</html>

'ETC' 카테고리의 다른 글

Linux study  (0) 2020.04.17
Linux commands  (0) 2020.04.02
프로세스 (chapter 2)  (0) 2020.03.13
운영체제(chapter 1)  (0) 2020.03.13
시스템 소프트웨어  (0) 2020.03.12

 

DELIMITER $$
DROP PROCEDURE IF EXISTS loopInsert$$
CREATE PROCEDURE loopInsert() 

BEGIN

DECLARE i INT DEFAULT 1;



WHILE i <= 500 DO 

insert into test.whisky(name, origin) values('asdfasdf', 'asdfasdf');

SET i = i + 1;

END WHILE;

END$$

DELIMITER $$

CALL loopInsert;

'데이터베이스' 카테고리의 다른 글

Various queries 1  (4) 2019.12.03

https://docs.google.com/presentation/d/1CrOcTTrRRHlredMRwie9WKSo7ChIF4bRylvUxhinRYU/edit#slide=id.g4010bbe41f_0_86

demian 계열은 .profile, redhat은 .bash_profile를 유저 선택시 실행 

'ETC' 카테고리의 다른 글

Vue notes  (0) 2020.07.01
Linux commands  (0) 2020.04.02
프로세스 (chapter 2)  (0) 2020.03.13
운영체제(chapter 1)  (0) 2020.03.13
시스템 소프트웨어  (0) 2020.03.12

“Images are Immutable and Containers are Ephemeral”

-i = interactively

-t = terminal

 

services

swarm

containers(Dockerfile)

'Devops' 카테고리의 다른 글

Docker  (0) 2020.04.03

delete previous docker before installing :

sudo yum remove docker docker-engine docker.io containerd runc

 

download docker convenience script : 

curl -fsSL https://get.docker.com -o get-docker.sh

sudo sh get-docker.sh

 

docker whael : 

sudo docker run docker/whalesay cowsay hello!

 

running container : 

docker ps 

 

remove a container : 

docker rm #name#

 

list images :

docker images

 

remove image :

docker rmi #ngnix#

 

download an image :

docker pull #ngnix#

(only downloads the image)

 

execute command : 

docker exec #distracted_mcclintock cat /etc/hosts

 

attach and detach :

docker run kodekloud/simple-webapp

docker run -d kodekloud/simple-webapp (background mode)

docker attach a034d (add images id)

 

Run a container with the nginx:1.14-alpine image and name it webapp:

docker run --name webapp nginx:1.14-alpine

 

tag :

docker run redis:4.0 (4.0 is the tag)

 

-i : interative mode

-t : terminal

inspect container : 

docker inspect #name#

 

container logs : 

docker logs #name#

 

How to create my own image? :

 

cmd vs terminal 

 

netwokr : 

 

 

 

 

docker compose : 

ONLY FOR SINGLE DOCKER HOST

 

Sample application - vote : 

 

docker registry : 

docker engine : 

 

docker swarm : 

kubernetes 쿠벌네틱스:

 

'Devops' 카테고리의 다른 글

Docker tutorial(2020/04)  (0) 2020.04.06

Linux provides CLI(command line interface) to communicate with the OS.

 

Set root user:

  sudo passwd root

  sudo passwd -u root

 

ls -laS : list all files in long format, all hidden, by memory size sequence

'ETC' 카테고리의 다른 글

Vue notes  (0) 2020.07.01
Linux study  (0) 2020.04.17
프로세스 (chapter 2)  (0) 2020.03.13
운영체제(chapter 1)  (0) 2020.03.13
시스템 소프트웨어  (0) 2020.03.12

01. 프로세스의 정의

- 실행중인 프로그램

- 디스크에 존재하는 프로그램 파일이 주기억장치에 적재되어 cpu에 의해서 실행 과정에 있을 때 프로세스라고 한다. 

- 프로세서는 cpu

- dispatch는 준비에서 실행 상태

 

02. 프로세스 상태 전이도 

- 준비, 실행, 대기 3가지 나누어진다 

submit, dispatch, i/o요구 , wake-up 

보조기억장치에서 메모리 들어가기 직전 부분이 spool

 프로세스 메모리 영역

텍스트 영역 - hex 또는 bin파일

데이터 영역 - 전역변수, 정적변수 배열 구조체 등이 저장

힙 영역 - 메모리를 할당하는 영역

스택 영역 - 지역 변수, 매개변수, 리턴 값등 잠시 사용 했다가 사라지는 데이터를 저장

 

03. 인터럽트 처리 

프로세스 진행 중에 어떤 요소 때문에 중단해야되는 상황. 

 

04. pcb process control block

process를 관리하는 블록

 

05. context switching 문맥 교환

프로세스들의 시간할당량에 따라 프로세스들 간의 교환을 하는 역할을 맡은게 context swithcing. cpu는 한 가지의 프로세스를 관리 할 수 있으며 나머지 프로세스들은 pcb table 안에 넣는다. 

 

06 비선점형 방식과 선점형 방식

 

비선점형 방식 non preemption- 프로세스 실행중에 중단 시킬 수 없다. 

fifo, sjf, hrn

fifo - first in first out, queue 방식 

선점형 preemption - 중간에 중단 시킬 수 있다. 빠른 응답시간을 필요로 하는 실시간 처리에 적합하다. 

rr, srt, mfq

 

혼합은 mlq mq 가 있다

 

'ETC' 카테고리의 다른 글

Linux study  (0) 2020.04.17
Linux commands  (0) 2020.04.02
운영체제(chapter 1)  (0) 2020.03.13
시스템 소프트웨어  (0) 2020.03.12
운영체제의 계층 구조  (0) 2020.03.12

+ Recent posts