2017年6月19日月曜日

CentOS7 phpMyAdminのインストール

以前にやってうまくいかなかったので、改めて書いておきます。

1.リポジトリepelの利用
# yum install epel-release

2.phpMyAdminのインストール
 yum --enablerepo=epel install phpMyAdmin php-mysql php-mcrypt

3.phpMyAdminの設定
vi /etc/phpMyAdmin/config.inc.php
14行目を修正します。
次に一旦rootでパスワード無しでログインできるようにします。
[root, パス無しログイン可]
84 $cfg['Servers'][$i]['AllowNoPassword']             
// Allow logins without a password. Do not change the FALSE
85                                      = FALSE; 

84 $cfg['Servers'][$i]['AllowNoPassword']             
// Allow logins without a password. Do not change the FALSE
85                                      = TRUE;

 次にアクセス設定をします。
# vi /etc/httpd/conf.d/phpMyAdmin.conf
今回は当面全てからアクセスを許可します。
追加
Require all granted




# systemctl restart httpd.service
http://localhost:10080/phpmyadmin/index.php
にアクセスします(10080はVirtualbox利用)
root、パスワード無しでログインし、パスワードを設定します。
ユーザ->root localhost を編集 ->パスワードを変更する
もう一度パスワード無しでログインを無効にします。
vi /etc/phpMyAdmin/config.inc.php
# systemctl restart httpd.service

参考
http://blog.k-kansei.com/?p=1444
https://www.server-world.info/query?os=CentOS_7&p=mariadb&f=2
http://kidatti.livedoor.biz/archives/37547860.html
http://qiita.com/nwsoyogi/items/c8eb1fedef3c00c5fbac

2017年6月9日金曜日

Unity5 (2) 数当てゲーム

1から10までの数字を当てるゲームです。
プロジェクト名:Unity02、2Dを選択
背景を白くします。
Textを生成して、Canvas内に入れておきます。
Textを Width 400, Height 50とし「1〜10の数字を推測」文字列をセンタリングしておきます。

動かすと
Textに対し、TextControllerというスクリプトを作成します。
コードを開いて、
変数の追加
public Text objText;
int intRandomNumber;
int intGuessedNumber;
 

関数の追加
private void InitializeGame()
    {
        // Pick a random number
        intRandomNumber = Random.Range(1, 10);
        // Set the text to start the game
        objText.text = "1〜10の数字を推測";
    }


関数呼び出し
// Use this for initialization
    void Start () {
        InitializeGame ();
    }


ここまでで、スクリプトとTextを紐付けし、実行
何もできないので、入力できるようにする。update関数に追加
void Update () {
        if (Input.anyKeyDown)
        {
            // Test to see if the keystroke was a number
            if (int.TryParse(Input.inputString, out intGuessedNumber))
            {
                if (intRandomNumber > intGuessedNumber)
                {
                    objText.text = 
                        string.Format("You guessed {0}. You are too low"
                            , intGuessedNumber);
                }
                if (intRandomNumber < intGuessedNumber)
                {
                    objText.text = 
                        string.Format("You guessed {0}. You are too high"
                            , intGuessedNumber);
                }
                if (intRandomNumber == intGuessedNumber)
                {
                    objText.text = 
                        string.Format("You guessed {0}. \n You are correct! \n (press spacebar to continue)"
                            , intGuessedNumber);
                }
            }
        }
    }

数値を入れると判定ができる
スペースを押した時に、リスタートする。 void Update () {
        if (Input.GetKeyDown(KeyCode.Space))
        {
            InitializeGame();
        }
        if (Input.anyKeyDown)
        {
            // Test to see if the keystroke was a number
            if (int.TryParse(Input.inputString, out intGuessedNumber))


ソースコード全体


参考
http://hololenshelpwebsite.com/Blog/EntryId/4/Beginner-Tutorial-A-Unity-5-Number-Guessing-Game

Unity5 (1) Hello World!!

UnityのHello Worldです。
テキストにを用意し、画面に出した後、スクリプトで表示内容を変更します。

1.プロジェクト作成
プロジェクト名:Unity01、2Dを選択します。
2.テキストを配置し、表示してみる
GameProject -> UI -> TEXT を選択し、配置する
Canvasの中にTextができた。EventSystemも追加されている。
配置されたテキストがどこにあるか確認(Altを押しながらマウスで探す)
見つけたら、Canvasの中に入れておく。文字列を「Hello World!!」に変更
動かしてみる
3.スクリプト作成
Text -> Add Component -> New Script -> Name を「TextController」に変更、C#を確認し、Create and Add
コードを作成
インスタンスとして、
public Text Textbox;
 とすると、Textクラスのインポートをしないといけない。この場合右クリック->resolveで必要なものをインポート
 update関数に追加
  Textbox.text = "Hello World! (From Code)";
全体

保存してみるとTextboxという項目が追加されている
隣の小さなボタンを押して紐付けします。
これで動かしてみると、コードで書いた文字列が表示されます
参考
 http://hololenshelpwebsite.com/Blog/EntryId/3/Unity-5-Hello-World