Project

General

Profile

Wiki » History » Version 1

keiji ono, 04/07/2025 09:56 AM

1 1 keiji ono
REPL起動   jlファイルを開いた状態で Shift+Enter または、"julia"と入れる
2
REPL終了 exit()を入れる
3
4
    bashからの実行
5
    jlファイル先頭に 「#!/usr/local/bin/julia」を記述しファイルのchmodをして実行権限を与えてから
6
7
    ./test.jl
8
9
python,php風だな
10
11
    REPLからの実行
12
13
    include("path to test.jl")
14
15
この場合、「#!/usr/....」はいらない
16
17
REPLで"pkg"プロントにするには"]"をタイプ。出るには"^C"で。
18
REPLでjlファイルをコンパイルするには
19
20
   include("file name")
21
22
23
一度コンパイルに成功するとそれがキャッシュにずっとあるので困る。以前はworkspace()というコマンドがあったみたいだが今は廃止されている。なので、replを再起動するしかないみたい。
24
2023/4/25現在
25
 repl起動でコンパイルされるが、repl起動後 include(..)で再コンパイルするとサクッと置き換えられるのでreplの再起動は必要ないみたい。
26
27
DataFramesの説明 ちょっと古いけど
28
https://sinhrks.hatenablog.com/entry/2015/12/23/003321
29
* Genieはこっちを見る
30
https://genieframework.com/docs/?
31
Genieのroute設定を削除するのはチュートリアルは古いので下記を実行する
32
33
  julia>routes()
34
4-element Vector{Genie.Router.Route}:
35
 [POST] /posttest1 => #31 | :post_posttest1
36
 [GET] /test1 => #11 | :get_test1
37
 [GET] /hello => #9 | :get_hello
38
 [GET] / => #7 | :get
39
40
  julia>Router.delete!(:post_posttest1)    ←delete!の引数がチュートリアルと違うから要注意
41
42
Genieアプリの起動とストップ
43
44
 起動
45
  >cd (app dir)   ex. cd Watchtonight
46
  >bin/repl    or julia
47
  >up()                 ←shプロンプトでbin/serverでもサーバ起動はするが、Watchtonightサンプルの様に設定を読み込んだりする分にはup()でないといけないみたい
48
49
 ストップ
50
  ><ctrl+d> (windows/linux)
51
  ><cmd+d> (macos)
52
53
Genieで起動するサーバの設定は./config/env/*.jlだが、変更したらイニシャライズが必要なので以下を再実行する必要がある。←down()/up()だけでは反映されない。
54
55
別のやり方
56
https://genieframework.com/docs/genie/tutorials/Loading-Genie-Apps.html
57
58
    juliaプロンプトでアプリの場所にcd("...")で移動する
59
    pkgプロンプトにして "activate ."を実行する
60
    juliaプロンプトに戻って "using Genie"を実行する
61
    次に "Genie.loadapp()"を実行する
62
    最後に"up()"でサーバが起動する
63
64
APIKEYやpassword等は、.config/secrets.jlに書く。ここはgitignoreだから だそうだ。
65
ここに記載されたデータはアプリケーション名でアクセスできるそうだ。 ex. MyGenieApp.pass とかかな?
66
https://genieframework.com/docs/genie/tutorials/The-Secrets-File.html
67
* Genie Tips: How to get the serverresponse on Genie
68
https://stackoverflow.com/questions/68127425/how-to-collect-http-response-status-using-genie-jl-in-julia
69
70
julia> using HTTP
71
72
julia> response = HTTP.get("http://127.0.0.1:8000/try")
73
HTTP.Messages.Response:
74
"""
75
HTTP/1.1 200 OK
76
Content-Type: application/json; charset=utf-8
77
Server: Genie/1.18.1/Julia/1.6.1
78
Transfer-Encoding: chunked
79
80
{"message":"Welcome"}"""
81
82
julia> response.status
83
200
84
85
開発環境のもろもろ
86
PostgreSQL * sudo -u postrges psql
87
88
version確認方法
89
     sudo apt info postgresql
90
91
  またはpsqlで接続後、下記を実行
92
       select version();
93
94
  現状(2023/11/13)の開発マシンでは
95
       PostgreSQL 14.9 (Ubuntu 14.9-0ubuntu0.22.04.1) on x86_64-pc-linux-gnu, compiled by gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0, 64-bit
96
97
ubuntu22ではsocketが/var/run/postgres配下に作成される。libPQ.jlからは/tmp配下にあることが期待されているようなので、postgresql.confを変更する必要がある。
98
/etc/postgresql/14/main/postgresql.conf
99
100
# 2022/10/11 changed here from /var/run/postgresql -> /tmp
101
#unix_socket_directories = '/var/run/postgresql'        # comma-separated list of directories
102
unix_socket_directories = '/tmp'        # comma-separated list of directories
103
104
105
pg_ivmのインストールのために、postgresの各.hファイルが必要になるが、postgresのソース場所をライブラリリンク設定するのがめんどくさいときは、postgres-serverをインストールすると自動的に入るからいい感じ。
106
その後、pg_ivmをmakeすればいい
107
108
sudo apt install postgresql-server-dev-16
109
make USE_PGXS=1
110
sudo make USE_PGXS=1 install
111
112
113
pg_ivmインストール後の設定は下記参照
114
https://qiita.com/nuko_yokohama/items/0ae59f5d797bc79dcc06
115
116
onoke@onoke-OptiPlex-990:~$ su - postgres
117
パスワード:
118
postgres@onoke-OptiPlex-990:~$ whoami
119
postgres
120
postgres@onoke-OptiPlex-990:~$ which createdb
121
/usr/bin/createdb
122
postgres@onoke-OptiPlex-990:~$ createdb ivm
123
postgres@onoke-OptiPlex-990:~$ psql ivm -c "create extension pg_ivm"
124
CREATE EXTENSION
125
postgres@onoke-OptiPlex-990:~$ psql ivm -c "\dx pg_ivm"
126
                          インストール済みの拡張一覧
127
  名前  | バージョン |  スキーマ  |                    説明                    
128
--------+------------+------------+--------------------------------------------
129
 pg_ivm | 1.7        | pg_catalog | incremental view maintenance on PostgreSQL
130
131
mysql
132
133
    root pw: aterui0
134
    start/stop: sudo systemctl start(stop) mysql
135
    デフォルトではutf8mb4になっていて「補助文字」も扱える
136
137
mysql> show variables like "chara%";
138
+--------------------------+----------------------------+
139
| Variable_name            | Value                      |
140
+--------------------------+----------------------------+
141
| character_set_client     | utf8mb4                    |
142
| character_set_connection | utf8mb4                    |
143
| character_set_database   | utf8mb4                    |
144
| character_set_filesystem | binary                     |
145
| character_set_results    | utf8mb4                    |
146
| character_set_server     | utf8mb4                    |
147
| character_set_system     | utf8mb3                    |
148
| character_sets_dir       | /usr/share/mysql/charsets/ |
149
+--------------------------+----------------------------+
150
151
killはpid指定で