firefoxに続いてgoogle-chromeでも日本語入力の挙動がおかしくなった.最初は問題なく動いていたのに... 以下のサイトを参考にしたら,とりあえず動いた.
やったことは,以下のことのみ.あとは,chromeのプロセスをキルして,立ち上げ直したら動いた.
sudo apt reinstall xkb-data
環境はubuntu23.10. firefoxを立ち上げるとこんなエラーが出てきて日本語入力(fcitx5)が出来ない.
[Parent 19490, Main Thread] WARNING: Create input context failed: GDBus.Error:org.freedesktop.DBus.Error.AccessDenied: An AppArmor policy prevents this sender from sending this message to this recipient; type="method_call", sender=":1.277" (uid=1000 pid=19490 comm="/snap/firefox/3728/usr/lib/firefox/firefox" label="snap.firefox.firefox (enforce)") interface="org.freedesktop.IBus" member="CreateInputContext" error name="(unset)" requested_reply="0" destination="org.freedesktop.IBus" (uid=1000 pid=2289 comm="fcitx5" label="unconfined").: 'glib warning', file /build/firefox/parts/firefox/build/toolkit/xre/nsSigHandlers.cpp:187 (firefox:19490): IBUS-WARNING **: 14:31:23.240: Create input context failed: GDBus.Error:org.freedesktop.DBus.Error.AccessDenied: An AppArmor policy prevents this sender from sending this message to this recipient; type="method_call", sender=":1.277" (uid=1000 pid=19490 comm="/snap/firefox/3728/usr/lib/firefox/firefox" label="snap.firefox.firefox (enforce)") interface="org.freedesktop.IBus" member="CreateInputContext" error name="(unset)" requested_reply="0" destination="org.freedesktop.IBus" (uid=1000 pid=2289 comm="fcitx5" label="unconfined"). [Parent 19490, Main Thread] WARNING: Create input context failed: GDBus.Error:org.freedesktop.DBus.Error.AccessDenied: An AppArmor policy prevents this sender from sending this message to this recipient; type="method_call", sender=":1.277" (uid=1000 pid=19490 comm="/snap/firefox/3728/usr/lib/firefox/firefox" label="snap.firefox.firefox (enforce)") interface="org.freedesktop.IBus" member="CreateInputContext" error name="(unset)" requested_reply="0" destination="org.freedesktop.IBus" (uid=1000 pid=2289 comm="fcitx5" label="unconfined").: 'glib warning', file /build/firefox/parts/firefox/build/toolkit/xre/nsSigHandlers.cpp:187 (firefox:19490): IBUS-WARNING **: 14:31:23.241: Create input context failed: GDBus.Error:org.freedesktop.DBus.Error.AccessDenied: An AppArmor policy prevents this sender from sending this message to this recipient; type="method_call", sender=":1.277" (uid=1000 pid=19490 comm="/snap/firefox/3728/usr/lib/firefox/firefox" label="snap.firefox.firefox (enforce)") interface="org.freedesktop.IBus" member="CreateInputContext" error name="(unset)" requested_reply="0" destination="org.freedesktop.IBus" (uid=1000 pid=2289 comm="fcitx5" label="unconfined").
ubuntuのfirefoxはsnap版を入れるらしい.解決できそうな感じのページを見つけたが時間をかけたくないので,手っ取り早く解決するために,snap版を捨てて,バイナリをダウンロードした. 以下のページからlinux用のバイナリをダウンロードする. www.mozilla.org ダウンロードして,/opt に入れて,リンクしておけば良い.
tar xjf firefox-xx.x.tar.bz2 sudo mv firefox /opt/ sudo ln -s /opt/firefox/firefox /usr/local/bin/firefox
g++-9 -m64 -g -o mip1_c++ ../c++/mip1_c++.cpp -I/opt/gurobi1003/linux64/include -L/opt/gurobi1003/linux64/lib -lgurobi_c++ -lgurobi100 -lm
とすると
/usr/bin/ld: /tmp/ccF9f4Jr.o: in function `main': /home/tom/Dropbox/research/gurobi/examples/c++/../c++/mip1_c++.cpp:22:(.text+0xac): undefined reference to `GRBEnv::set(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)' /usr/bin/ld: /home/saito/Dropbox/research/gurobi/examples/c++/../c++/mip1_c++.cpp:29:(.text+0x169): undefined reference to `GRBModel::addVar(double, double, double, char, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)'
というエラーが出た. g++のバージョンが新しい場合,libgurobi_g++5.2.a を使うらしい.上記で指定している libgurobi_c++.a はlibgurobi_g++4.8.a のリンク.
ls -l /opt/gurobi1003/linux64/lib/libgurobi_c++.a
lrwxrwxrwx 1 5075 501 20 Sep 6 11:15 /opt/gurobi1003/linux64/lib/libgurobi_c++.a -> ./libgurobi_g++4.8.a
以下,設定をメモ .barhrcに書いたこと.
export GUROBI_HOME=/opt/gurobi1003/linux64 export PATH=$GUROBI_HOME/bin:$PATH export LD_LIBRARY_PATH=$GUROBI_HOME/lib:$LD_LIBRARY_PATH export GRB_LICENSE_FILE=/home/tom/gurobi.lic
Distinction2000でダウンロードしてきた単語が単語,例文ごとに細かく分けられていたので,結合してみた.ffmpegが使える環境が必要.以下は,ubuntu22.04で実行.
プログラムの中身
ChatGPTにお願いして作成したpythonコード
import os import re import subprocess import eyed3 def embed_tags(file_path, title, artist="atsu", album="Distinction2000"): audiofile = eyed3.load(file_path) if not audiofile.tag: audiofile.initTag() audiofile.tag.title = title audiofile.tag.artist = artist audiofile.tag.album = album audiofile.tag.save() def merge_and_tag(prefix): # カレントディレクトリ内の該当するMP3ファイルを取得 mp3_files = [f for f in os.listdir() if f.endswith('.mp3') and f.startswith(f'{prefix}.')] # prefix の後に続く英単語を抽出 word_match = next((re.search(f'{prefix}\.0 (\w+)', f) for f in mp3_files if f.startswith(f'{prefix}.0 ')), None) if not word_match: print(f"No matching file found for prefix {prefix}!") return word = word_match.group(1) # prefix の後に続く数字でソートするための関数 def sorting_key(filename): match = re.search(f'{prefix}\.(\d+)', filename) if match: return int(match.group(1)) return float('inf') # 数字がない場合、最後になるようにする # ソート files_to_merge = sorted(mp3_files, key=sorting_key) # 出力ディレクトリとファイル名 output_dir = "output" output_file = os.path.join(output_dir, f"{prefix}_{word}.mp3") # 出力ディレクトリが存在しない場合、作成 if not os.path.exists(output_dir): os.makedirs(output_dir) # ffmpeg コマンドを構築 input_files_str = " ".join([f"-i \"{f}\"" for f in files_to_merge]) cmd = f"ffmpeg {input_files_str} -filter_complex concat=n={len(files_to_merge)}:v=0:a=1 -acodec libmp3lame {output_file}" # コマンドの実行 subprocess.call(cmd, shell=True) # タグ埋め込み embed_tags(output_file, f"{prefix}_{word}") # 0004 から 0007 までの処理 for i in range(1, 2001): merge_and_tag(str(i).zfill(4))
質問:
インクルードガードとしてprogram onceが使われていますが,こちらを使うメリットはなんですか?ifでガードするのは時代遅れですか?
ChatGPTの答え:
#pragma once
と #ifndef
/#define
ガードの両方には、それぞれのメリットとデメリットがあります。#pragma once
は新しい形式であり、多くの現代のコンパイラでサポートされていますが、#ifndef
/#define
ガードもまだ広く使われています。以下に、それぞれのメリットとデメリットを示します。
#pragma once
のメリット:#define
ガードを使う場合、マクロ名がユニークであることを確認する必要がありますが、#pragma once
にはその心配はありません。#pragma once
の方が微妙に高速に動作すると言われています。#ifndef
/#define
ガードのメリット:#pragma once
は非標準であり、すべてのコンパイラやプラットフォームでサポートされているわけではありません(ただし、現代の主要なコンパイラはサポートしています)。#ifndef
/#define
ガードが時代遅れであるとは言えません。実際、多くのプロジェクトやライブラリではまだこれを使用しています。しかし、新しいプロジェクトやコードベースで#pragma once
を使用することが増えてきており、これには上記のようなメリットが影響しています。
最終的に、どちらの方法を使用するかはプロジェクトの要件、対象となるコンパイラやプラットフォーム、そしてチームの好みによるでしょう。
発音の勉強に役に立ちそうなyoutubeのリンクのまとめ
Rachel's English はElsa Speak からリンクされてる動画とだいたい一緒.
American English - AA [æ] Vowel - How to make the AA Vowel - YouTube American English - AH [ɑ] Vowel - How to make the AH Vowel - YouTube American English - UH [ʌ] Vowel - How to make the UH Vowel - YouTube American English Sounds - UH [ə] Vowel - How to make the SCHWA Vowel - YouTube American English - EH [ɛ] Vowel - How to make the EH Vowel - YouTube American English - IH [ɪ] Vowel - How to make the IH Vowel - YouTube American English - EE [i] Vowel - How to make the EE Vowel - YouTube
English Pronunciation: Sit /ɪ/ vs Seat /i:/ - YouTube English Pronunciation: Bat /æ/ vs But /Ʌ/ - YouTube English Pronunciation: Bad /æ/ vs Bed /ɛ/ - YouTube