반응형

Original

Q is the only letter in the alphabet that does not appear in the name of any of the United States!

해석

알파벳에서 Q라는 글자는 미국의 어떤 주 이름에도 포함되어 있지 않습니다!

단어

- letter: 편지 (명사)

- alphabet: 알파벳 (명사)

- appear: 나타나다 (동사)

- name: 이름 (명사)

- United States: 미국 (명사)

반응형
반응형

Original

Every year 11,000 Americans injure themselves while trying out bizarre sexual positions.

해석

매년 11,000명의 미국인들이 이상한 성적인 자세를 시도하는 동안 자신을 다치게 합니다.

단어

- Americans: 미국인들 (명사)

- injure: 다치게 하다 (동사)

- bizarre: 이상한 (형용사)

- sexual: 성적인 (형용사)

- positions: 자세들 (명사)

반응형
반응형

Original

A snail can sleep for three years.

해석

달팽이는 세 해 동안 잘 수 있습니다.

단어

- snail: 달팽이 (명사)
- sleep: 자다 (동사)
- three: 세 개의 (수사)
- years: 해 (명사)

반응형
반응형

Original

Napoleon`s penis was sold to an American Urologist for $40,000.

해석

나폴레옹의 음경은 4만 달러에 미국의 비뇨기과 의사에게 팔렸습니다.

단어

- Napoleon: 나폴레옹 (명사)

- penis: 음경 (명사)

- sold: 팔렸다 (과거 분사, 동사)

- American: 미국의 (형용사)

- Urologist: 비뇨기과 의사 (명사)

- $40,000: 4만 달러 (명사)

반응형
반응형

Original

Each king in a deck of playing cards represents a great king from history. Spades - King David, Clubs - Alexander the Great, Hearts - Charlemagne, and Diamonds - Julius Caesar.

해석

카드 덱의 각 킹은 역사 속의 위대한 왕을 나타냅니다. 스페이드 - 다윗 왕, 클로버 - 알렉산더 대왕, 하트 - 샤를마뉴, 다이아몬드 - 율리우스 시저.

단어

- Spades : 스페이드 카드 (명사)

- King David : 다윗 왕 (명사)

- Clubs : 클로버 카드 (명사)

- Alexander the Great : 알렉산더 대왕 (명사)

- Hearts : 하트 카드 (명사)

- Charlemagne : 샤를마뉴 (명사)

- Diamonds : 다이아몬드 카드 (명사)

- Julius Caesar : 율리우스 시저 (명사)

반응형
반응형

개발을 하다보면 하루 종일 터미널에서 빠져나오지 못하고 열심히 아주 열심히 삽질을 하고 있는 자신을 마주할 때가 있다.
그러한 삽질을 대신 해줄 수 있는 스크립트를 하나 가져왔다.

파라미터로 실행하고자 하는 명령어와 반복 횟수, 실행 주기를 설정하면 그에 맞게 명령어를 반복해주는 스크립트이다.
뭐 cron을 쓸 수도 있을 것이고 watch를 쓸 수도 있겠지만 횟수까지 설정할 수는 없기에 나름 유용할 수 있다. 
(글을 쓰다보니 watch를 쓰는게 더 나을 것 같기도 하다..)

아래의 스크립트 이며 파라미터는 다음과 같다. 
$1 명령어
$2 반복 횟수
$3 interval (ms) 

 

- 사용법 :

$ ./repeat_command.sh "echo 'Hello World'" 5 500
#!/bin/bash

# 사용법을 표시하는 함수
function usage() {
    echo "Usage: $0 [command] [repeat count] [delay in milliseconds]"
    exit 1
}

# 파라미터가 3개가 아닌 경우 사용법 표시
if [ "$#" -ne 3 ]; then
    usage
fi

command_to_run=$1
repeat_count=$2
delay_milliseconds=$3

# 밀리세컨드를 초로 변환
delay_seconds=$(echo "scale=3; $delay_milliseconds/1000" | bc)

# 반복해서 명령어 실행
for (( i=1; i<=$repeat_count; i++ )); do
    eval "$command_to_run"
    sleep $delay_seconds
done



쓰다보니 watch와 다른게 뭔가 싶어 기능을 추가해보았다.
무려 4번째 파라미터..!
$4 검색하고자 하는 문자열.

이 네번째 파라미터는 앞서 반복해서 뭔가를 실행하고 그 결과로 출력되는 내용 중에 이 파라미터가 포함되어있다면 'output_시간.log' 파일을 생성한다.

- 사용법 :

./repeat_command.sh "echo 'Hello World'" 5 500 "Hello"
#!/bin/bash

# 사용법을 표시하는 함수
function usage() {
    echo "Usage: $0 [command] [repeat count] [delay in milliseconds] [search string]"
    exit 1
}

# 파라미터가 4개가 아닌 경우 사용법 표시
if [ "$#" -ne 4 ]; then
    usage
fi

command_to_run=$1
repeat_count=$2
delay_milliseconds=$3
search_string=$4

# 밀리세컨드를 초로 변환
delay_seconds=$(echo "scale=3; $delay_milliseconds/1000" | bc)

output_file="output_$(date +%Y%m%d%H%M%S).log"

# 반복해서 명령어 실행
for (( i=1; i<=$repeat_count; i++ )); do
    result=$(eval "$command_to_run")
    
    if echo "$result" | grep -q "$search_string"; then
        echo "$result"
        echo "$(date): $result" >> $output_file
    fi
    
    sleep $delay_seconds
done


멋지지 않은가 ? 
그냥 뭔가 삘 받아서 만들어둔 스크립트이니 이 세상 어딘가 이 스크립트가 필요한 사람이 있길 바라며..글을 마무리한다.

반응형
반응형

로그를 남기다보면, vector 내부의 모든 원소를 출력해야 하는 일이 생길 수 있다.
보통 이런 일은 주로 디버깅을 할 때 발생하긴 하지만 알아두면 로그 공해도 줄일 수 있고 나름 쓸모가 많기에 그 방법을 소개한다.

- standard out으로 바로 출력하는 방법

#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>

int main() {
    std::vector<float> vec = {1.2f, 3.4f, 5.6f, 7.8f};

    std::copy(vec.begin(), vec.end(), std::ostream_iterator<float>(std::cout, " "));
    std::cout << std::endl;

    return 0;
}



- stringstream에 담아 출력하는 방법 

#include <iostream>
#include <vector>
#include <sstream>
#include <algorithm>
#include <iterator>

int main() {
    std::vector<float> vec = {1.2f, 3.4f, 5.6f, 7.8f};
    std::stringstream ss;

    std::copy(vec.begin(), vec.end(), std::ostream_iterator<float>(ss, " "));

    std::string result = ss.str();
    std::cout << result << std::endl;

    return 0;
}

 

반응형
반응형

Original

It costs more to buy a new car today in the United States than it cost Christopher Columbus to equip and undertake three voyages to and from the New World.

해석

미국에서 새 차를 구입하는 비용은 오늘날 크리스토퍼 콜럼버스가 새 세계로의 세 차여행을 준비하고 수행하는 데 든 비용보다 더 많이 듭니다.

단어

- cost : 비용 (동사)
- buy : 사다 (동사)
- new : 새로운 (형용사)
- car : 자동차 (명사)
- today : 오늘 (부사)
- United States : 미국 (명사)
- Christopher Columbus : 크리스토퍼 콜럼버스 (명사)
- equip : 준비하다 (동사)
- undertake : 수행하다 (동사)
- voyage : 여행 (명사)
- New World : 새 세계 (명사)

반응형
반응형

Original

The first automobile race ever seen in the United States was held in Chicago in 1895. The track ran from Chicago to Evanston, Illinois. The winner was J. Frank Duryea, whose average speed was 71/2 miles per hour.

해석

미국에서 최초로 본 자동차 경주가 1895년에 시카고에서 개최되었습니다. 이 경주는 시카고에서 일리노이 주 에반스턴까지의 트랙을 따라서 열렸습니다. 우승자는 J. Frank Duryea로, 평균 속도는 시속 7 1/2 마일이었습니다.

단어

- automobile : 자동차 (명사)

- race : 경주 (명사)

- United States : 미국 (명사)

- held : 개최되었다 (동사)

- Chicago : 시카고 (명사)

- track : 트랙 (명사)

- Evanston : 에반스턴 (명사)

- Illinois : 일리노이 (명사)

- winner : 우승자 (명사)

- average : 평균 (명사)

- speed : 속도 (명사)

- miles per hour : 시속 마일 (명사)

반응형
반응형

Original

The symbol on the "pound" key (#) is called an octothorpe.

해석

"파운드" 키(# ) 위에 있는 심볼은 옥토토르프라고 불립니다.

단어

- symbol: 상징 (명사)

- pound key: 파운드 키 (명사)

- called: 불리는 (동사)

- octothorpe: 옥토토르프 (명사)

반응형

+ Recent posts