アニメ!アニメ!

2022年12月27日火曜日

UNIX find

dotinstall:~ $ mkdir -p test/app{1..5} dotinstall:~ $ touch test/app{1..5}/app{1..3}{.jpg,.png,.gif} dotinstall:~ $ ls test/ app1 app2 app3 app4 app5 dotinstall:~ $ ls test/app1 app1.gif app1.png app2.jpg app3.gif app3.png app1.jpg app2.gif app2.png app3.jpg dotinstall:~ $ find test -name 'app3.png' test/app1/app3.png test/app2/app3.png test/app3/app3.png test/app4/app3.png test/app5/app3.png dotinstall:~ $ find test -name 'app1*' test/app1 test/app1/app1.jpg test/app1/app1.png test/app1/app1.gif test/app2/app1.jpg test/app2/app1.png test/app2/app1.gif test/app3/app1.jpg test/app3/app1.png test/app3/app1.gif test/app4/app1.jpg test/app4/app1.png test/app4/app1.gif test/app5/app1.jpg test/app5/app1.png test/app5/app1.gif dotinstall:~ $ find test -name 'app1*' -type f test/app1/app1.jpg test/app1/app1.png test/app1/app1.gif test/app2/app1.jpg test/app2/app1.png test/app2/app1.gif test/app3/app1.jpg test/app3/app1.png test/app3/app1.gif test/app4/app1.jpg test/app4/app1.png test/app4/app1.gif test/app5/app1.jpg test/app5/app1.png test/app5/app1.gif dotinstall:~ $ find test -name 'app1*' -type d test/app1 dotinstall:~ $ rm -r test/ dotinstall:~ $

UNIX ブレース展開

dotinstall:~ $ echo {a,b,c} a b c dotinstall:~ $ echo {1..10}{a..g} 1a 1b 1c 1d 1e 1f 1g 2a 2b 2c 2d 2e 2f 2g 3a 3b 3c 3d 3e 3f 3g 4a 4b 4c 4d 4e 4f 4g 5a 5b 5c 5d 5e 5f 5g 6a 6b 6c 6d 6e 6f 6g 7a 7b 7c 7d 7e 7f 7g 8a 8b 8c 8d 8e 8f 8g 9a 9b 9c 9d 9e 9f 9g 10a 10b 10c 10d 10e 10f 10g dotinstall:~ $ mkdir test && cd test dotinstall:~/test $ mkdir app{1..5} dotinstall:~/test $ ls app1 app2 app3 app4 app5 dotinstall:~/test $ touch app{1..5}/test{1..3}{.jpg,.png,.gif} dotinstall:~/test $ ls app2 test1.gif test1.png test2.jpg test3.gif test3.png test1.jpg test2.gif test2.png test3.jpg ]dotinstall:~/test $ ]rm app{1..5}/test{1..3}{.jpg,.gif} bash: ]rm: command not found dotinstall:~/test $ rm app{1..5}/test{1..3}{.jpg,.gif} dotinstall:~/test $ ls app2 test1.png test2.png test3.png dotinstall:~/test $ cd dotinstall:~ $ rm -r test/ dotinstall:~ $

UNIX パイプ

dotinstall:~ $ ls -l /etc/ total 208 -rw-r--r-- 1 root root 7 May 29 2020 alpine-release drwxr-xr-x 1 root root 4096 Sep 23 2020 apk drwxr-xr-x 3 root root 4096 Sep 23 2020 ca-certificates -rw-r--r-- 1 root root 5613 Jun 18 2020 ca-certificates.conf drwxr-xr-x 2 root root 4096 May 29 2020 conf.d drwxr-xr-x 2 root root 4096 May 29 2020 crontabs -rw-r--r-- 1 root root 89 May 29 2020 fstab -rw-r--r-- 1 root root 693 Sep 23 2020 group -rw-r--r-- 1 root root 682 May 29 2020 group- -rw-r--r-- 1 root root 13 Dec 27 18:11 hostname -rw-r--r-- 1 root root 178 Dec 27 18:11 hosts drwxr-xr-x 2 root root 4096 May 29 2020 init.d -rw-r--r-- 1 root root 570 May 29 2020 inittab -rw-r--r-- 1 root root 1748 Feb 9 2020 inputrc -rw-r--r-- 1 root root 54 May 29 2020 issue -rw-r--r-- 1 root root 309 Aug 9 2020 localtime drwxr-xr-x 2 root root 4096 May 29 2020 logrotate.d drwxr-xr-x 2 root root 4096 May 29 2020 modprobe.d -rw-r--r-- 1 root root 15 May 29 2020 modules drwxr-xr-x 2 root root 4096 May 29 2020 modules-load.d -rw-r--r-- 1 root root 283 May 29 2020 motd lrwxrwxrwx 1 root root 12 Dec 27 18:11 mtab -> /proc/mounts drwxr-xr-x 8 root root 4096 May 29 2020 network drwxr-xr-x 2 root root 4096 May 29 2020 opt -rw-r--r-- 1 root root 164 May 29 2020 os-release -rw-r--r-- 1 root root 1233 Sep 23 2020 passwd -rw-r--r-- 1 root root 1172 May 29 2020 passwd- drwxr-xr-x 7 root root 4096 May 29 2020 periodic -rw-r--r-- 1 root root 238 May 29 2020 profile drwxr-xr-x 1 root root 4096 Sep 23 2020 profile.d -rw-r--r-- 1 root root 1865 May 29 2020 protocols -rw-r--r-- 1 root root 54 Dec 27 18:11 resolv.conf -rw-r--r-- 1 root root 65 May 22 2020 securetty -rw-r--r-- 1 root root 14464 May 29 2020 services -rw-r----- 1 root shadow 454 Sep 23 2020 shadow -rw-r----- 1 root shadow 422 May 29 2020 shadow- -rw-r--r-- 1 root root 48 Sep 23 2020 shells drwxr-xr-x 1 root root 4096 May 29 2020 ssl -rw-r--r-- 1 root root 3941 May 25 2020 sudo.conf -rw-r--r-- 1 root root 6169 May 25 2020 sudo_logsrvd.conf -rw-r--r-- 1 root root 3228 Sep 23 2020 sudoers drwxr-x--- 2 root root 4096 Sep 23 2020 sudoers.d -r--r----- 1 root root 3174 May 25 2020 sudoers.dist -rw-r--r-- 1 root root 53 May 29 2020 sysctl.conf drwxr-xr-x 2 root root 4096 May 29 2020 sysctl.d drwxr-xr-x 13 root root 4096 Sep 23 2020 terminfo -rw-r--r-- 1 root root 5306 May 22 2020 udhcpd.conf dotinstall:~ $ ls -l /etc/ | grep 'sudo' -rw-r--r-- 1 root root 3941 May 25 2020 sudo.conf -rw-r--r-- 1 root root 6169 May 25 2020 sudo_logsrvd.conf -rw-r--r-- 1 root root 3228 Sep 23 2020 sudoers drwxr-x--- 2 root root 4096 Sep 23 2020 sudoers.d -r--r----- 1 root root 3174 May 25 2020 sudoers.dist dotinstall:~ $ ls -l /etc/ | grep 'sudo' | wc -l 5 dotinstall:~ $ ls -l /etc/ | grep 'sudo' | wc -l > results.txt dotinstall:~ $ cat results.txt 5 dotinstall:~ $ rm results.txt dotinstall:~ $

UNIX リダイレクション

date dotinstall:~ $ echo 'cal' > commands.txt dotinstall:~ $ cat commands.txt cal dotinstall:~ $ echo 'date' >> commands.txt dotinstall:~ $ cat commands.txt cal date dotinstall:~ $ /bin/ash < commands.txt December 2022 Su Mo Tu We Th Fr Sa 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 Tue Dec 27 20:04:43 JST 2022 dotinstall:~ $ /bin/ash < commands.txt > results.txt dotinstall:~ $ cat results.txt December 2022 Su Mo Tu We Th Fr Sa 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 Tue Dec 27 20:05:01 JST 2022 dotinstall:~ $ rm ' >

C# 変数の型

using System; class MyApp { static void Main() { // 変数: 再代入が可能 // 定数: 再代入が不可能 string s = "hello"; char c = 'a'; int i = 100; double d = 52342.34; float f = 23.3f; //論理 bool flag = true; var x = 5; var y = "world"; } }

2022年8月14日日曜日

WIN32API メッセージBOX

#include int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR lpCmdLine, int nCmdShow) { MessageBox(NULL, TEXT("勇者の攻撃!"), TEXT("スライムが現れた!"), MB_OK); return 0; }

2022年7月23日土曜日

WindowsAPI 終了処理

#include LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp) { switch (msg) { case WM_DESTROY: MessageBox(hwnd, TEXT("魔王を倒した"), TEXT("勇者の攻撃"), MB_ICONINFORMATION); PostQuitMessage(0); return 0; } return DefWindowProc(hwnd, msg, wp, lp); } int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR lpCndLine, int nCmdShow) { HWND hwnd; MSG msg; WNDCLASS winc; winc.style = CS_HREDRAW | CS_VREDRAW; winc.lpfnWndProc = WndProc; winc.cbClsExtra = winc.cbWndExtra = 0; winc.hInstance = hInstance; winc.hIcon = LoadIcon(NULL, IDI_APPLICATION); winc.hCursor = LoadCursor(NULL, IDC_ARROW); winc.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH); winc.lpszMenuName = NULL; winc.lpszClassName = TEXT("勇者"); if (!RegisterClass(&winc))return 0; hwnd = CreateWindow( TEXT("勇者"), TEXT("勇者の攻撃!"), WS_OVERLAPPEDWINDOW | WS_VISIBLE, 100, 100, 200, 200, NULL, NULL, hInstance, NULL ); if (hwnd == NULL)return 0; while (GetMessage(&msg, NULL, 0, 0))DispatchMessage(&msg); return msg.wParam; }

2022年6月4日土曜日

C++ 標準入出力

#include int main(){ int x = 0; std::cout << "整数を入力してください:"; if(std::cin >> x){ std::cout << "入力した整数は" << x << "です。" << std::endl; }else{ std::cout << "不正な入力" << std::endl; } return 0; }

2022年5月25日水曜日

JavaScriptBasics

JavaScript Basics index.html 'use strict'; console.log('Hello World from main.js'); main.js

2022年5月22日日曜日

C言語 インクリメントデクリメント

#include int main(void) { int value; value = 10; printf("%d\n", value); value++; printf("%d\n", value); value--; printf("%d\b", value); return 0; }

2022年4月2日土曜日

PHP 関数

WindowsAPI コマンドライン引数

#include int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR pCmdLine, int nCmdShow) { MessageBox(NULL, GetCommandLine(), TEXT("勇者の攻撃!"), MB_ICONINFORMATION); return 0; }

2022年3月30日水曜日

WindowsAPI メッセージボックス

#include int WINAPI WinMain( HINSTANCE hInstance , HINSTANCE hPrevInstance , PSTR lpCmdLine , int nCmdShow ) { MessageBox(NULL , TEXT("Kitty on your lap") , TEXT("メッセージボックス") , MB_OK); return 0; } http://wisdom.sakura.ne.jp/system/winapi/win32/win5.html

PHP 変数の返り値

PHP 可変長引数

PHP 配列

 <?php


$moreScores = [

  55,

  72,

  'perfect',

  [90, 42, 88],

];


$scores = [

  90,

  40,

  ...$moreScores,

  100,

];


// print_r($scores);


echo $scores[5][2] . PHP_EOL;

2022年3月28日月曜日

PHP foreach

 <?php


$scores = [

  'first'  => 90, 

  'second' => 40, 

  'third'  => 100,

];


// foreach ($scores as $value) {

// foreach ($scores as $score) {

//   echo $score . PHP_EOL;

// }


foreach ($scores as $key => $score) {

  echo $key . ' - ' . $score . PHP_EOL;

}

2022年3月26日土曜日

PHP 配列

 <?php


$scores = [

  'first'  => 90, 

  'second' => 40, 

  'third'  => 100,

];


// var_dump($scores);

// print_r($scores);


echo $scores['third'] . PHP_EOL;

2022年3月24日木曜日

PHP 配列

 <?php


// $score1 = 90;

// $socre2 = 40;

// $score3 = 100;


$scores = [

  90,

  40,

  100,

];


$scores[1] = 60;

echo $scores[1] . PHP_EOL;

2022年3月21日月曜日

PHP null

 ~ $ php main.php

Gold Medal


Fatal error: Uncaught TypeError: Return value of getAward() must be of the type string, null returned in /home/dotinstall/main.php:7

Stack trace:

#0 /home/dotinstall/main.php(11): getAward(40)

#1 {main}

  thrown in /home/dotinstall/main.php on line 7

~ $ php main.php

Gold Medal


~ $ php main.php

Gold Medal


~ $ 



<?php


declare(strict_types=1);


function getAward(?int $score): ?string

{

  return $score >= 100 ? 'Gold Medal' : null;

}


echo getAward(150) .PHP_EOL;

echo getAward(40) .PHP_EOL;

2022年3月18日金曜日

PHP 引数の型

 <?php


declare(strict_types=1);


function showInfo(string $name, int $score): void

{

  echo $name . ': ' . $score . PHP_EOL;

}


// showInfo('taguchi', 40);

// showInfo('taguchi', 'dotinstall');

showInfo('taguchi', '4');


2022年3月17日木曜日

PHP 条件演算子

 <?php


function sum($a, $b, $c) 

{

  $total = $a + $b + $c;

  

  // if($total < 0){

  //   return 0;

  // }else{

  //   return $total;

  // }

  return $total < 0 ? 0 : $total;

}


echo sum(100, 300, 500) .PHP_EOL; //900

echo sum(-1000, 300, 500) .PHP_EOL; //0

PHP 無名関数

 <?php


// function sum($a, $b, $c)

// {

//   return $a + $b + $c;

// }


$sum = function ($a, $b, $c){ //無名関数

  return $a + $b + $c;

};


echo $sum(100, 300, 500) .PHP_EOL;

2022年3月16日水曜日

PHP スコープ

 <?php


$rate = 1.1; //グローバルスコープ


function sum($a, $b, $c)

{

  // global $rate;

  $rate = 1.08; //ローカルスコープ

  return ($a + $b + $c) * $rate;

}


echo sum(100, 200, 300) + sum(300, 400, 500) . PHP_EOL; //1944

2022年3月15日火曜日

PHP return

 <?php


function sum($a, $b, $c)

{

  // echo $a + $b + $c . PHP_EOL;

   return $a + $b + $c;

   echo 'Here!' .PHP_EOL;

}


sum(100, 200, 300);//600

sum(300, 400, 500);//1200


echo sum(100, 200, 300) + sum(300, 400, 500) .PHP_EOL;//1800

2022年3月14日月曜日

PHP 引数

 <?php


function showAd($message = 'Ad') //仮引数

{

  echo '----------' . PHP_EOL;

  echo '--- ' . $message . ' ---' . PHP_EOL;

  echo '----------' . PHP_EOL;

}


showAd('Header Ad'); //実引数

echo 'Tom is great!' . PHP_EOL;

echo 'Bob is great!' . PHP_EOL;

// showAd('Ad');

showAd();

echo 'Steve is great!' . PHP_EOL;

echo 'Bob is great!' . PHP_EOL;

showAd('Footer Ad');


MSB8020 v142 (プラットフォーム ツールセット = 'v142') のビルド ツールが見つかりません。

 https://scrapbox.io/gosyujin/MSB8020_v142_(%E3%83%97%E3%83%A9%E3%83%83%E3%83%88%E3%83%95%E3%82%A9%E3%83%BC%E3%83%A0_%E3%83%84%E3%83%BC%E3%83%AB%E3%82%BB%E3%83%83%E3%83%88_=_'v142')_%E3%81%AE%E3%83%93%E3%83%AB%E3%83%89_%E3%83%84%E3%83%BC%E3%83%AB%E3%81%8C%E8%A6%8B%E3%81%A4%E3%81%8B%E3%82%8A%E3%81%BE%E3%81%9B%E3%82%93%E3%80%82

PHP 関数

 <?php


function showAd()

{

  echo '----------' .PHP_EOL;

  echo '--- Ad ---' . PHP_EOL;

  echo '----------' .PHP_EOL;

}


showAd();

echo 'Tom is great!' . PHP_EOL;

echo 'Bob is great!' . PHP_EOL;

showAd();

echo 'Steve is great!' . PHP_EOL;

echo 'Bob is great!' . PHP_EOL;

showAd();

2022年1月21日金曜日

ゲームクラス

#include <iostream>

using namespace std;


#define ELEM(array)  (sizeof (array) / sizeof *(array))


class GameClass

{

public:

    char title[16];

    int  music;

    int  graphic;

    int  Viewoftheworld;


    void Disp();

};


void GameClass::Disp()

{

    cout << "ゲームタイトル : "   << title    << endl

         << " 音楽 : " << music << " 点, "

            "グラフィック : "   << graphic     << " 点, "

            "世界観 : "   << Viewoftheworld << " 点" << endl;

}


int main()

{

    GameClass Gametitle[] = {

        { "原神",   73, 98, 95, },

        { "バイオハザード4", 85, 95, 90, },

        { "FF14",   76, 98, 90, },

    };

    int      i;


    for(i = 0; i < ELEM(Gametitle); i++)

        Gametitle[i].Disp();


    return 0;

}


2022年1月10日月曜日

ポケモン

 #include <iostream>

using namespace std;


void pokemon1()

{

    cout << "ポッチャマを選ぶ" << endl;

cin >> a;

}


void pokemon2()

{

    cout << "ナエトルを選ぶ" << endl;

}


void pokemon3()

{

    cout << "ヒコザルを選ぶ" << endl;

}


int main()

{

    pokemon1();

    pokemon2();

    pokemon3();

    return 0;

}