django の使い方

$ python -m django –version
1.9.8

$ django-admin startproject mysite

$ python manage.py runserver
Performing system checks…

System check identified no issues (0 silenced).

You have unapplied migrations; your app may not work properly until they are applied.
Run ‘python manage.py migrate’ to apply them.

$ python manage.py startapp polls

次のファイルを編集
polls/viey.py
polls/urls.py
mysite/urls.py

http://localhost:8000/polls/

mysite/settings.py

LANGUAGE_CODE = ‘ja-jp’
TIME_ZONE = ‘Asia/Tokyo’
USE_TZ = False

Arch Linux で Docker

# pacman -S docker

# systemctl start docker
# systemctl status docker

# docker version
Client:
Version: 1.11.2
API version: 1.23
Go version: go1.6.2
Git commit: b9f10c9
Built: Tue Jun 21 00:43:14 2016
OS/Arch: linux/amd64

Server:
Version: 1.11.2
API version: 1.23
Go version: go1.6.2
Git commit: b9f10c9
Built: Tue Jun 21 00:43:14 2016
OS/Arch: linux/amd64

Arch Linux に CakePHP をインストール

cakephp-3.2.12.tar.gz をダウンロード

$ tar xvfz cakephp-3.2.12.tar.gz

# pacman -S composer

$ composer create-project –prefer-dist cakephp/app my_app_name

$ bin/cake server
PHP Fatal error: You must enable the intl extension to use CakePHP. in /home/www/tmp/my_app_name/config/bootstrap.php on line 23

# pacman -S php-intl

$ bin/cake server

http://localhost:8765/

config/app.php を編集する。

‘username’ => ‘scott’,
‘password’ => ‘tiger’,
‘database’ => ‘my_app’,

jQuery とPHPでファイルをアップロード

参考ページ
http://qiita.com/yasumodev/items/cffb735f46ffd489a4db

HTMLのフォーム

AL 

OR 



JavaScript のプログラム

function file_upload_proc ()
{
// フォームデータを取得
var formdata = new FormData(jQuery(‘#my_form’).get(0));

// POSTでアップロード
jQuery.ajax({
url : “ccc01.php”,
type : “POST”,
data : formdata,
cache : false,
contentType : false,
processData : false,
dataType : “html”
})
.done(function(data, textStatus, jqXHR){
jQuery(“.message”).html (data);
})
.fail(function(jqXHR, textStatus, errorThrown){
jQuery(“.message”).html (“*** fail ***

“);
});
}

PHP のプログラム

‘;
foreach ($files as $file)
{
echo $file . ‘
‘;
}
echo ‘*** calculate_proc *** end ***
‘;
}

function single_upload_proc ($file_in)
{
$file_tmp = $file_in[“tmp_name”];

// 正式保存先ファイルパス
$file_save = “uploads/” . $file_in[“name”];

// ファイル移動
$result = @move_uploaded_file($file_tmp, $file_save);
if ( $result === true ) {
echo $file_save . ”  UPLOAD OK

“;
} else {
echo “UPLOAD NG

“;
}

}

echo ‘*** start ***
‘;

echo ‘*** ppppp ***
‘;
echo “file_1 = ” . $_FILES[“file_1”][“name”] . “
“;
echo “file_2 = ” . $_FILES[“file_2”][“name”] . “
“;
echo ‘*** qqqqq ***
‘;
// var_dump ($_FILES);
echo ‘*** rrrrr ***
‘;
echo ‘
‘;

single_upload_proc ($_FILES[“file_1”]);
single_upload_proc ($_FILES[“file_2”]);

// echo ‘Here is some more debugging info:’;
// print_r($_FILES);

print “

“;

$files = array ();
$files[0] = “uploads/” . $_FILES[“file_1”][“name”];
$files[1] = “uploads/” . $_FILES[“file_2”][“name”];
calculate_proc ($files);

echo ‘*** end ***
‘;

?>

Arch Linux で django

# pacman -S python-django

$ python -m django –version
1.9.7

$ django-admin startproject mysite
$ python manage.py runserver
Performing system checks…

System check identified no issues (0 silenced).

You have unapplied migrations; your app may not work properly until they are applied.
Run ‘python manage.py migrate’ to apply them.

July 18, 2016 – 12:04:37
Django version 1.9.7, using settings ‘mysite.settings’
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.

$ python manage.py startapp polls

NumPy 行列の入れ替え

#! /usr/bin/python3
# -*- coding: utf-8 -*-
#
#
# Jul/15/2016
#
import sys
import numpy as np
#
# ——————————————————————–
print (“*** 開始 ***”)

src = [[1.3,2,3],[14,5,6],[17,8,9],[10,11,12.6],[19,8,7],[17,3,8]]
aa = np.array(src)
print (aa)
bb = aa.T
print (bb)
print (“ndim = “,aa.ndim,bb.ndim)
print (“size = “,aa.size,bb.size)
print (“shape = “,aa.shape,bb.shape)

print (“*** 終了 ***”)
# ——————————————————————–