Original
Napoleon`s penis was sold to an American Urologist for $40,000.
해석
나폴레옹의 음경은 4만 달러에 미국의 비뇨기과 의사에게 팔렸습니다.
단어
- Napoleon: 나폴레옹 (명사)
- penis: 음경 (명사)
- sold: 팔렸다 (과거 분사, 동사)
- American: 미국의 (형용사)
- Urologist: 비뇨기과 의사 (명사)
- $40,000: 4만 달러 (명사)

Napoleon`s penis was sold to an American Urologist for $40,000.
나폴레옹의 음경은 4만 달러에 미국의 비뇨기과 의사에게 팔렸습니다.
- Napoleon: 나폴레옹 (명사)
- penis: 음경 (명사)
- sold: 팔렸다 (과거 분사, 동사)
- American: 미국의 (형용사)
- Urologist: 비뇨기과 의사 (명사)
- $40,000: 4만 달러 (명사)

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
멋지지 않은가 ?
그냥 뭔가 삘 받아서 만들어둔 스크립트이니 이 세상 어딘가 이 스크립트가 필요한 사람이 있길 바라며..글을 마무리한다.
| minicom 키보드 입력 안되는 경우 (1) | 2024.09.24 |
|---|---|
| [bash] 파일 크기 순으로 검색 (0) | 2023.12.12 |
| [bash] 파일 탐색 (0) | 2023.09.10 |
| [bash] bash를 이용한 json 파일 파싱 (0) | 2022.08.11 |
| [bash] 특정 길이의 무작위 문자열 획득 (0) | 2022.08.11 |
로그를 남기다보면, 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;
}
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 : 새 세계 (명사)

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 : 시속 마일 (명사)

The symbol on the "pound" key (#) is called an octothorpe.
"파운드" 키(# ) 위에 있는 심볼은 옥토토르프라고 불립니다.
- symbol: 상징 (명사)
- pound key: 파운드 키 (명사)
- called: 불리는 (동사)
- octothorpe: 옥토토르프 (명사)

The name of the girl on the statue of liberty is Mother of Exiles.
자유의 여신상에 있는 소녀의 이름은 Mother of Exiles입니다.
- statue : 조각상 (명사)
- liberty : 자유 (명사)
- girl : 소녀 (명사)
- Mother of Exiles : 유배자의 어머니 (명사구)

The `Golden Arches` of fast food chain McDonalds is more recognized worldwide than the religious cross of Christianity.
패스트 푸드 체인 맥도날드의 '골든 아치'는 기독교의 십자가보다 전 세계적으로 더 잘 알려져 있다.
- Golden Arches: 맥도날드의 상징. (명사)
- fast food chain: 패스트 푸드 체인. (명사)
- McDonalds: 맥도날드. (명사)
- recognized: 인정받다. (동사)
- worldwide: 전 세계적으로. (부사)
- religious: 종교의. (형용사)
- cross: 십자가. (명사)
- Christianity: 기독교. (명사)

RSA의 공개키와 개인키를 XML 형식으로 생성하는 예제이다.
using System.Security.Cryptography;
public void CreateRSAKey()
{
using (RSA rsa = RSA.Create())
{
// 개인 키 추출
RSAParameters privateKeyParameters = rsa.ExportParameters(true);
// 개인 키를 TEXT 형식으로 출력
rsa.ImportParameters(privateKeyParameters);
string privateKeyText = rsa.ToXmlString(true);
Console.WriteLine("\n개인 키:\n" + privateKeyText);
// 공개 키 추출
RSAParameters publicKeyParameters = rsa.ExportParameters(false);
// 공개 키를 TEXT 형식으로 출력
rsa.ImportParameters(publicKeyParameters);
string publicKeyText = rsa.ToXmlString(false);
Console.WriteLine("공개 키:\n" + publicKeyText);
}
}
생성한 공개키를 이용해 암호화 하는 예제
public void Encrypt(string text)
{
RSACryptoServiceProvider rsa = new RSACryptoServiceProvider();
rsa.FromXmlString(publicKey);
byte[] utf = (new UTF8Encoding()).GetBytes(text);
byte[] encrypt = rsa.Encrypt(utf, false);
string result = Convert.ToBase64String(encrypt);
}
생성한 개인키를 이용해 복호화 하는 예제
public void Decrypt(string text)
{
RSACryptoServiceProvider rsa = new RSACryptoServiceProvider();
rsa.FromXmlString(privateKey);
byte[] base64 = Convert.FromBase64String(text);
byte[] decrypt = rsa.Decrypt(base64, false);
string dec = (new UTF8Encoding()).GetString(decrypt, 0, decrypt.Length);
string result = dec;
}
| gRPC DateTime C# 예제 (1) | 2023.09.14 |
|---|---|
| C# Convert TimeSpan to DateTime (1) | 2023.09.14 |