Tip/Android2025. 9. 11. 01:38

1. Termux에서 sshd  실행 및 IP 확인

예제에서는 192.168.0.20이 Termux가 설치된 휴대폰의 IP 이다.

2. CLion 실행

3. SFTP 구성

도구 -> 배포 -> 구성

SSH 설정
 

4. CLion에서 휴대폰으로 접속하기

도구 -> 배포 -> 원격 호스트 찾아보기 실행

그럼 우측에 아래와 같이 화면이 뜨면, 위에서 설정한 SFTP 의 이름을 선택한다.

그리고 작업하려는 폴더를 선택한다.

5. CLion 에서 SSH 세션 실행

Posted by chobocho
Tip/Linux2025. 9. 9. 00:46

WordCount 예제

%{
    unsigned int charCount = 0, wordCount = 0, lineCount = 0;
%}

word [^ \t\n]+
eol  \n

%%
{word} { wordCount++; charCount += yyleng; }
{eol}  { charCount++; lineCount++; }
.      { charCount++; }
%%

int main(int argc, char **argv) {
        yylex();
        printf(" %d %d %d\n", lineCount, wordCount, charCount);
        return 0;
}

WordCount 예제 2 (파일에서 읽기)

%{
    unsigned int charCount = 0, wordCount = 0, lineCount = 0;
%}

word [^ \t\n]+
eol  \n

%%
{word} { wordCount++; charCount += yyleng; }
{eol}  { charCount++; lineCount++; }
.      { charCount++; }
%%

int main(int argc, char **argv) {
        FILE *file = NULL;
        if (argc > 1) {
                file = fopen(argv[1], "r");
                if (!file) {
                        fprintf(stderr, "Could not open %s\n", argv[1]);
                        exit(1);
                }
                yyin = file;
        }
        yylex();
        printf(" %d %d %d %s\n", lineCount, wordCount, charCount,
                        (file == NULL ? "" : argv[1]));
        return 0;
}

Posted by chobocho
Tip/Linux2025. 9. 2. 01:30

1. Lex파일 만들기 (calc.l)

%{
%}

%%
"quit"    { exit(0); }
[0-9]+    { yylval = atoi(yytext); return NUMBER; }
"+"       { return PLUS; }
"-"       { return MINUS; }
"*"       { return TIMES; }
"/"       { return DIVIDE; }
"("       { return '('; }
")"       { return ')'; }
[ \t]     ;
"\n"      { return '\n'; }
.         ;

2. Yacc 파일 만들기 (calc.y)

%{
#include <stdio.h>
extern int yylex();
void yyerror(const char *s);
%}

%token NUMBER
%token PLUS MINUS TIMES DIVIDE
%left  PLUS MINUS
%left  TIMES DIVIDE

%%
stat_list:
		 | stat_list stat
		 ;
stat: expr '\n' { printf("= %d\n", $1); }
	;

expr: NUMBER           { $$ = $1; }
	| expr PLUS   expr { $$ = $1 + $3; }
	| expr MINUS  expr { $$ = $1 - $3; }
	| expr TIMES  expr { $$ = $1 * $3; }
	| expr DIVIDE expr { 
	    if ($3 == 0) yyerror("Divide by zero");
	    else $$ = $1 / $3;
	}
	| MINUS expr %prec MINUS {$$ = -$2; }
	| '(' expr ')'     { $$ = $2; }
	;

%%

#include "lex.yy.c"

void yyerror(const char *s){
    fprintf(stderr, "Error: %s\n", s);
}

int main() {
    printf("Chobocho'c Calc V0.1\n");
    return yyparse();
}

3. Make파일 만들기

CC = gcc
LIBS = -lfl
LEX = flex
YACC = yacc

all: calc2

calc2: y.tab.c lex.yy.c
	$(CC) -o calc2 y.tab.c $(LIBS)

y.tab.c: calc.y
	$(YACC) -dv calc.y

lex.yy.c: calc.l
	$(LEX) calc.l

clean:
	rm y.tab.h
	rm y.tab.c
	rm y.tab.h.pch
	rm lex.yy.c
	rm calc2

4. 빌드 & 실행

'Tip > Linux' 카테고리의 다른 글

Lex & Yacc로 간단한 사칙연산 계산기 만들기2  (0) 2025.09.12
LEX 기초  (0) 2025.09.09
컴파일러 관련 기초 서적 정리 (한글판만)  (0) 2025.01.18
Posted by chobocho
Tip/Android2025. 5. 8. 01:03

ULTRA 워드 앱은 어떠한 개인 정보도 수집하지 않습니다. 
ULTRA Word does not collect any personal information.

다운로드 링크:

https://play.google.com/store/apps/details?id=com.chobocho.wordmaster&pcampaignid=web_share

 

UltraWord - Google Play 앱

초 간단 단어장 입니다

play.google.com

 

Posted by chobocho
Tip/Linux2025. 1. 18. 20:48

'Tip > Linux' 카테고리의 다른 글

Lex & Yacc로 간단한 사칙연산 계산기 만들기2  (0) 2025.09.12
LEX 기초  (0) 2025.09.09
Lex & Yacc로 간단한 사칙연산 계산기 만들기  (0) 2025.09.02
Posted by chobocho
Tip/Windows2024. 11. 13. 22:06

제어판에서 프로그램 삭제를 했는데도, 시작 프로그램에 찌꺼기가 남아 있는 경우가 있다.

이럴 땐 다음과 같이 아래 폴더로 가서, 그 프로그램 바로가기 파일을 지우면 된다.

C:\Users\[사용자계정]\AppData\Roaming\Microsoft\Windows\Start Menu\Programs

Posted by chobocho
Tip/Android2024. 10. 9. 12:45

Posted by chobocho
Tip/Android2024. 10. 9. 12:44

Posted by chobocho
Tip/Windows2023. 9. 22. 01:02

 C#을 배우면서 간단한 이미지 뷰어를 만들어 보았다.

기능:

 Drag & Drop 

R / L  키로 이미지 회전

Left, Right 화살표 키로 이미지 전환 (같은 폴더내)

Up 화살표키: 첫번째 이미지 (알파벳 순)

Down 화살표키: 마지막 이미지 (알파벳 순)

 

전체 소스코드:

https://github.com/chobocho/choboImageViewer

 

GitHub - chobocho/choboImageViewer: Simple image view by c#

Simple image view by c#. Contribute to chobocho/choboImageViewer development by creating an account on GitHub.

github.com

 

실행파일:

- 경고: 사용시 발생하는 어떤 이슈도 책임 지지 않습니다.

ImageViewer_32bit.zip
0.16MB

구현 관련

1. 메모리릭 이슈

-  PictureBox 에 이미지를 바꿀 때에는 반드시, dispose() 메서드 호출 후 null을 대입해야 한다.

            if (pictureBox.BackgroundImage != null)
            {
                pictureBox.BackgroundImage.Dispose();
                pictureBox.BackgroundImage = null;
            }

2. 파일을 읽어서, 파일이 위치한 폴더의 모든 이미지 파일 읽기. (Chat GPT 형님의 도움을 받았다)

    public void setFileName(string? filename)
    {
        if (filename == null || !File.Exists(filename)) return;
        string[] imageExtensions = { ".jpg", ".jpeg", ".png", ".gif", ".bmp", "ico" }; 
        
        // 이 부분 입니다.
        _filesList = Directory.GetFiles(Path.GetDirectoryName(@filename) ?? string.Empty)
            .Where(file => imageExtensions.Contains(Path.GetExtension(file).ToLower()))
            .Select(Path.GetFullPath).ToArray();

        Array.Sort(_filesList);
        _index = Array.IndexOf(_filesList, filename);
    }

3. 이미지 회전

- 여기서는 dispose() 메서드 호출 하지 않는다. 호출 하면 이미지 객체가 삭제된다.

- 마지막에 pictureBox.Refresh() 메소드를 꼭 호출해 주어야 회전한 이미지로 업데이트 된다.

        void rotateImage(System.Drawing.RotateFlipType angle)
        {
            var LoadedImage = pictureBox.BackgroundImage;
            LoadedImage.RotateFlip(angle);

            pictureBox.BackgroundImage = LoadedImage;

            var width = LoadedImage.Width > minimumSize ? LoadedImage.Width : minimumSize;
            width = LoadedImage.Width > maximumSize ? maximumSize : width;

            var height = LoadedImage.Height > minimumSize ? LoadedImage.Height : minimumSize;
            height = LoadedImage.Height > maximumSize ? maximumSize : height;

            this.Width = width;
            this.Height = height;

            pictureBox.Refresh();
        }
Posted by chobocho
Tip/Android2023. 8. 30. 23:03

Hexa Game 앱은 어떠한 개인 정보도 수집하지 않습니다.

Hexa Game does not collect any personal information.

Posted by chobocho