dotinstall:~ $ vi hello
dotinstall:~ $:q
タグ: programming
UNIX コマンド
dotinstall:~ $ ls -l /exc/shadow
ls: /exc/shadow: No such file or directory
dotinstall:~ $ ls -l /etc/shadow
-rw-r—– 1 root shadow 454 Sep 23 2020 /etc/shadow
dotinstall:~ $ cat /etc/shadow
cat: can’t open ‘/etc/shadow’: Permission denied
dotinstall:~ $ sudo !!
sudo cat /etc/shadow
root:!::0:::::
bin:!::0:::::
daemon:!::0:::::
adm:!::0:::::
lp:!::0:::::
sync:!::0:::::
shutdown:!::0:::::
halt:!::0:::::
mail:!::0:::::
news:!::0:::::
uucp:!::0:::::
operator:!::0:::::
man:!::0:::::
postmaster:!::0:::::
cron:!::0:::::
ftp:!::0:::::
sshd:!::0:::::
at:!::0:::::
squid:!::0:::::
xfs:!::0:::::
games:!::0:::::
cyrus:!::0:::::
vpopmail:!::0:::::
ntp:!::0:::::
smmsp:!::0:::::
guest:!::0:::::
nobody:!::0:::::
dotinstall:!:18528:0:99999:7:::
dotinstall:~ $ sudo
UNIX コマンド
dotinstall:~ $ ls
dotinstall:~ $ touch index.html
dotinstall:~ $ ls -l
total 0
-rw-r–r– 1 dotinsta wheel 0 Sep 8 21:06 index.html
dotinstall:~ $ rm -index.html
rm: unrecognized option: n
BusyBox v1.31.1 () multi-call binary.
Usage: rm [-irf] FILE…
Remove (unlink) FILEs
-i Always prompt before removing
-f Never prompt
-R,-r Recurse
dotinstall:~ $ ls
index.html
dotinstall:~ $ rm – index.html
rm: can’t remove ‘-‘: No such file or directory
dotinstall:~ $ rm – index.html
rm: can’t remove ‘-‘: No such file or directory
rm: can’t remove ‘index.html’: No such file or directory
dotinstall:~ $ ls
dotinstall:~ $
C# 変数
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class test3 : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
int a;
float b;
string c;
bool d;
a = 1;
b = 0.01f;
c = "勇者の登場";
d = true;
//コンソールに表示
Debug.Log(a);
Debug.Log(b);
Debug.Log(c);
Debug.Log(d);
}
}
GPT-2を使ってマルコフ連鎖で文章生成
mari.py
from flask import Flask, render_template, request
import random
import markovify
from transformers import GPT2LMHeadModel, GPT2Tokenizer
app = Flask(name)
GPT-2モデルのロード
tokenizer = GPT2Tokenizer.from_pretrained(“gpt2”)
model = GPT2LMHeadModel.from_pretrained(“gpt2”)
マルコフ連鎖用のテキストデータを格納するリスト
text_data = []
GPT-2による自由なテキスト生成
def generate_gpt2_text(prompt, max_length=100):
input_ids = tokenizer.encode(prompt, return_tensors=”pt”)
output = model.generate(input_ids, max_length=max_length, num_return_sequences=1)
response = tokenizer.decode(output[0], skip_special_tokens=True)
return response
マルコフ連鎖モデルを生成
def build_markov_model(data):
text_model = markovify.NewlineText(data)
return text_model
マルコフ連鎖を使って新しいテキストを生成
def generate_text_with_markov(model, num_sentences=3):
generated_text = model.make_sentence()
return generated_text
ウェブアプリケーションのルート
@app.route(“/”, methods=[“GET”, “POST”])
def chatbot():
user_input = “”
gpt2_response = “”
markov_response = “”
if request.method == "POST":
user_input = request.form["user_input"]
# ユーザーからの入力をGPT-2に送信し、生成されたテキストを取得
gpt2_response = generate_gpt2_text(user_input)
# GPT-2の生成テキストをリストに追加
text_data.append(gpt2_response)
# マルコフ連鎖モデルを使って新しいテキストを生成
markov_response = generate_text_with_markov(build_markov_model(text_data))
return render_template("chat.html", user_input=user_input, gpt2_response=gpt2_response, markov_response=markov_response)
if name == “main“:
app.run(debug=True)
templates
chat.html
Chatbot
Chatbot
ユーザー: 送信
ユーザーの入力:
{{ user_input }}
GPT-2生成テキスト:
{{ gpt2_response }}
マルコフ連鎖生成テキスト:
{{ markov_response }}
C# Unity Test
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class TestScript : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
string a;
string b;
a = “真理”;
b = “りんご”;
Debug.Log(a + “は” + b + “が好きです。”);
a = “マリアンヌ”;
b = “メロン”;
Debug.Log(a + “は” + b + “好きです。”);
}
// Update is called once per frame
void Update()
{
//Debug.Log(“連続表示”);
}
}
C++ 変数
include<iostream>
using namespace std;
int main()
{
int maou;
maou = 0;
cout << "maou = " << maou << endl;
maou = 5;
cout << "maou * 2 = " << maou * 2 << endl;
return 0;
}
C++ 計算
include<iostream>
using namespace std;
int main()
{
cout << “9 / 2 = ” << 9 / 2 << endl;
cout << “9 % 2 = ” << 9 % 2 << endl;
cout << “2 + 2 * 4 = ” << 2 + 2 * 4 << endl;
cout << “(1 – 5) / 2 = ” << (1 – 5) / 2 << endl;
return 0;
}
C# 値渡し
using System;
namespace Chap3
{
class RPGClass
{
public void TestFunc(ref int a)
{
a *= 3;
Console.WriteLine(a);
}
}
class MainClass
{
static void Main(string[] args)
{
RPGClass test = new RPGClass();
int a = 5;
test.TestFunc(ref a);
Console.WriteLine(a);
}
}
}
C# class
using System;
namespace TestNamespace
{
class TestClass
{
public void PrintName(int no, string name = “chodomeyuhei”)
{
Console.WriteLine(no + “→” + name);
}
}
class MainClass
{
static void Main()
{
TestClass test = new TestClass();
test.PrintName(10);
}
}
}
