なんかアプデで急に出なくなったので…
確認環境
Edge 129.0.2792.65
基本はこのコマンドを流せば行けるはず
sudo apt update
sudo apt upgrade
sudo apt full-upgrade
sudo do-release-upgrade
sudo do-release-upgradeの実行時に-dオプションを外す
自動起動していない場合、PowerShellなどからWSLを殺せば解決する
wsl --shutdown
コケてるリポジトリを消せばよい。以下は一例
ls -la /etc/apt/sources.list.d
sudo rm -Rf /etc/apt/sources.list.d/grafana.list*
無視してよい
WSL上のUbuntuで動作するnginxでHTTPSに対応したサーバーを作る方法。実機でも同様の手順でいける
| Env | Ver |
|---|---|
| nginx | nginx/1.18.0 (Ubuntu) |
| mkcert | v1.4.4 |
| Ubuntu | 20.04.6 LTS |
| Windows 11 | 22621.3880 |
mkcert sandbox.testsandbox.test.pemsandbox.test-key.pem/etc/nginx/conf.d/ssl/に移動する/etc/nginx/conf.d/sandbox.test.confを作成し、以下のような記述をする
server {
listen 443 ssl;
client_max_body_size 100m;
server_name sandbox.test;
ssl_certificate conf.d/ssl/sandbox.test+1.pem;
ssl_certificate_key conf.d/ssl/sandbox.test+1-key.pem;
access_log /var/log/nginx/sandbox.access.log;
error_log /var/log/nginx/sandbox.error.log;
# ファイルホスト用
# location / {
# root /usr/share/nginx/html/sandbox;
# index index.html;
# try_files $uri /index.html =404;
# }
# APサーバーへのリバプロ用
location ~ ^/.*$ {
rewrite ^/.*$ / break;
proxy_set_header X-Request-Path $request_uri;
proxy_set_header X-Host $host;
proxy_pass http://127.0.0.1:9999;
}
# fastcgi用
location ~ \.php$ {
root /usr/share/nginx/html/sandbox;
fastcgi_pass unix:/run/php/php8.0-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
}
sudo service nginx restartmkcertのRoot CAをエクスポートして他の端末に突っ込めば、他の端末でもpemが流用できる
ブラウザのタブがバックグラウンド状態になっているとJSの実行が止まることがあり、そうするとsetInterval()が死ぬので、これを回避する技。
結論としてはWeb Worker APIのWorkerインターフェースを使うことで解決できる。
| Env | ver |
|---|---|
| Microsoft Edge | 126.0.2592.87 |
/**
* @param {() => void} cb 実行するコールバック
* @param {number} interval 実行間隔
* @returns 停止用の関数
* */
const createWorkerInterval = (cb, interval) => {
const src = "self.addEventListener('message', (msg) => { setInterval(() => self.postMessage(null), msg.data) })";
const wk = new Worker(`data:text/javascript;base64,${btoa(src)}`);
wk.onmessage = () => cb();
wk.postMessage(interval);
return wk.terminate;
}
"hoge", "piyo", "fuga"のように綺麗なCSVであるという前提。CSVファイルが巨大なので行読み込みする。
<?php
$db = new PDO('sqlite:./hoge.db');
$db->beginTransaction();
$fp = fopen("hoge.csv", "r");
$idx = 0;
if($fp){
while ($line = fgets($fp)) {
$row = createRow($line);
$db->exec(
'INSERT INTO hogehoge (`foo`, `bar`, `baz`)'
. ' VALUES '
.'(' . '"' . $row['foo'] .'", ' . '"' . $row['bar'] .'", ' . '"' . $row['baz'] .'"' . ')'
);
$idx++;
echo $idx . "\n";
}
}
fclose($fp);
$db->commit();
function createRow($text) {
$r1 = preg_replace('/"/', '', $text);
$row = explode(',', $r1);
return [
'foo' => $row[0],
'bar' => $row[1],
'baz' => $row[2],
];
}
トランザクションを張りっぱなしだが、exec毎にトランザクションを張りなおすと劇的に遅くなるのでやめたほうがいい(恐らく毎回同期処理でWriteが走っているのだと思う)