howto/その他tips

一行メモ

  • 自分自身のコピーを書き出すプログラム -- 2019-10-03 (木) 09:39:16
    main(a){printf(a,34,a="main(a){printf(a,34,a=%c%s%c,34);)",34);}
    [ref] Henry S.Warren,Jr., "ハッカーのたのしみ", 株式会社星雲社 (2004), まえがき
  • Postscript プログラミングメモ http://ruby.kyoto-wu.ac.jp/~konami/Documents/ps/psmemo.html -- 2019-12-11 (水) 11:37:06
  • 正規化文字列の変更 -- 2019-12-13 (金) 10:59:23
    $ nkf --ic=utf8-mac charcorr.text  #oka
    
    $ iconv -f utf8-mac -t utf8 charcorr.text  #?
    $ convmv -f utf8 --nfc   -t utf8 --nfd     --notest  charcorr.text  #?
    
    emacs 正規化コマンド  #未確認
    ucs-normalize-NFC-region
    ucs-normalize-NFD-region
  • bashスクリプトで set -euo pipefail -- 2020-02-25 (火) 10:19:49
  • (理由不明)ファイル名やディレクトリ名にスペースが入っていると、絶対パスの場合は正しいが、相対パスだと多くのファイルがリストアップされない。という現象が Ubuntu 18.04.5 LSTの ls, du, tarでみられた。 -- 2020-10-31 (土) 12:27:21
  • URLエンコード・デコードをする https://tech-unlimited.com/urlencode.html -- 2021-01-21 (木) 12:28:09
  • URLエンコード・デコードをする https://www.tagindex.com/tool/url.html -- 2022-04-14 (木) 10:36:58
  • gcc -S hoge.c #アセンブラコード hoge.sを出力する -- 2021-04-01 (木) 21:11:24
  • 端末文字の色付け(8色ANSIエスケープシーケンス) https://qiita.com/hidai@github/items/1704bf2926ab8b157a4f -- 2021-08-29 (日) 09:56:09
  • 動的にプロンプト(PS1)を変える例 https://qiita.com/key-amb/items/de671b42e90a87146bed http://archive.linux.or.jp/JF/JFdocs/Bash-Prompt-HOWTO-9.html -- 2021-08-29 (日) 12:12:09
  • bash関数内でエイリアス展開させない($aや¥hogeのところ)、など -- 2021-08-29 (日) 13:50:22
    $ type -a hoge
    hoge is aliased to `echo alias-hoge'
    hoge is a function
    hoge () 
    { 
        echo func-hoge
    }
    hoge is ~/bin/hoge
    $ cat ~/bin/hoge 
    echo command-hoge
    $ hoge          #エイリアスが動く
    alias-hoge
    $ command hoge  #明示的に、外部コマンドを動かす
    command-hoge
    $ a="hoge"; $a  #関数が動く。エイリアス展開しない。関数は外部コマンドよりが優先する
    func-hoge       #関数内ではローカル変数 local a="hoge"; $a にするとよい
    $ ¥hoge
    func-hoge       #関数が動く。エイリアス展開しない。関数は外部コマンドよりが優先する
  • ls -l でパーミッションの最後に付く + や @ -- 2021-10-12 (火) 15:44:04
    @ : 拡張メタデータがある(MacOSの場合?)
    + : 拡張ACLデータがある(user,group,other以外のアクセス制御が付与されている)
    あまり気にする必要は無い。
  • bash: 関数のエイリアスがあり、エイリアス名で関数を定義すると、もとの関数が再定義される場合がある。 -- 2021-12-18 (土) 14:37:33
    function junk { echo junk; }  #もとの関数定義
    alias hoge=junk               #その関数のエイリアス
    があるとき、
    
    hoge() { echo hoge; }
    をすると、
    junk() { echo hoge; }
    と解釈され もとの関数 junkが定義し直される。
    
    一方で、
    function hoge { echo hoge; }
    とする場合、
    もとの関数 junkはそのままで、
    hoge() { echo hoge; }
    が定義される。\hogeでこの関数を実行可能。hogeだとjunkのエイリアスとして実行される。
  • conda環境をactivateしたあとで、サブシェルbashを起動後、deactivateやactivateなどできないようだ。? -- 2021-12-18 (土) 14:55:20
    • 当然か? -- 2021-12-18 (土) 15:07:30
    • activateなら再度 eval "$(/share/apps/anaconda3/bin/conda shell.bash hook)" する -- 2021-12-18 (土) 15:04:42
  • 未フォーマットの外付けUSB接続のSSDのフォーマットなど -- 2022-02-25 (金) 10:08:51
    • Windows10: コントロールパネル→管理ツール→コンピュータの管理→記憶域の、ディスクの管理でする
    • Ubuntu:
      $ lsblk -p  #認識された名前を確認する、マウントはされてないはず。例えば /dev/sdc となる。
      $ sudo fdisk /dev/sdc  #MBRで作るとき
          n->p->1->First, Last sectorsはデフォルトで最大容量->w
          (プライマリパーティションをひとつ最大容量で作る)
      $ sudo mkfs.ext4 /dev/sdc1  #パーティションをフォーマット
          終了後、自動で /media以下にマウントされる。
      
      増設したときはこのままでは使いずらいので umountして、
      cd /
      sudo mkdir nvme
      sudo mount /dev/nvme0n1 nvme
      そして、
      lsblk -pf  #UUIDも表示
      /etc/fstabにまねて以下を追加
        /dev/disk/by-uuid/cf6b2f5e-c7f8-4cd0-8cf5-3eaae174a8a2 /nvme ext4 defaults 0 1
      などとする。
  • なんか、グラフが書けるwebサービス https://www.desmos.com/calculator?lang=ja -- 2022-03-07 (月) 16:04:43
  • 短縮URL作成? https://kuku.lu/ -- 2022-03-08 (火) 18:47:13
  • bash履歴の削除 -- 2022-05-20 (金) 17:53:56
    先頭にスペースを入れて
     history -d NUM
    で履歴を削除。パスワードを履歴に入れてしまった場合もこれで削除可。
    しかし .bash_history内のものは HISTSIZE, HISTFILESIZEの兼ね合いで消えない場合が
    往々にしてあるので、エディタで削除か。
    
    まとめていくつか削除したいとき、
    $ for i in `seq 904 918`; do history -d 904; done
    904から918番まで、15個の履歴を削除する。
    (注)904からひとつずつ削除しているが、削除すると後半の番号は詰められてずれる。
  • bashプロンプトに使える特殊文字 https://atmarkit.itmedia.co.jp/flinux/rensai/linuxtips/002cngprmpt.html -- 2022-07-09 (土) 20:50:56
  • bashシェル変数 PROMPT_COMMAND='printf "\033]0;%s:%s\007" "${HOSTNAME%%.*}" "${PWD/#$HOME/¥~}"' これがあると、プロンプトを出す前に実行される(この例では端末ウィンドウのタイトルに、ホスト名:カレントディレクトリのパス名が設定される)。 -- 2022-07-09 (土) 21:08:09
    • 古いbashのバージョンだと、¥~ とエスケープする必要はない。 -- 2022-07-09 (土) 21:21:13
    • emacs内でbashを走らすときは(M-x shell, M-x ansi-term, or M-x term)、PROMPT_COMMANDを定義しない方がよい。次のように .bashrcに入れるとよい。 -- 2022-07-14 (木) 22:27:30
      # set the title of the terminal window, if INSIDE_EMACS is not defined
      if [ ${INSIDE_EMACS:-x} == x ]; then
          PROMPT_COMMAND='printf "\033]0;%s:%s\007" "${HOSTNAME%%.*}" "${PWD/#$HOME/\~}"'
      fi
  • IMEで変換候補が2つしか表示されないとき: タスクバー→IME→設定→全般→以前のバージョンのMicrosoft IMEを使う、をオンにするとよい。 -- 2022-09-29 (木) 15:59:16
  • スクリプト例 -- 2022-12-24 (土) 21:36:15
    # 01~12のディレクトリ内の01~31ディレクトリ/hoge/hoge.hogファイルを移動してから
    # ディレクトリを削除する(イレギュラーな場合はエラーメッセージが出る)。
    pwd; for d in ?? ; do cd $d; echo === $d ===; mv [0-9][0-9]/*/*.* . ; rmdir [0-9][0-9]/* ; rmdir [0-9][0-9]; cd ..; done
  • ssh ホスト名 コマンド名 #このとき、コマンドがエイリアスのとき実行されない(CentOS7,Ubuntu16,18);ファンクションのときCentOS7は実行、Ubuntu16,18は実行されない。どこの設定か? -- 2023-03-03 (金) 21:48:26
  • watch -n 180 diff chsB30cfem4RC1Xg120Ndt2-c07a.out chsB30cfem4RC1Xg120Ndt2-c06.out -- 2023-03-09 (木) 17:27:39
  • chromeのプラグイン Superpower ChatGPT は微妙? -- 2023-04-10 (月) 22:30:29
  • bashのヒアドキュメント -- 2023-06-09 (金) 14:01:37
    cat << EOF などでは、パラメータ置換 $val とコマンド置換 $(command) が行われる。
    "EOF" や 'EOF' では行われない。
  • Ubuntu 22.04のインストール https://smdn.jp/softwares/ubuntu/installation-lts-desktop/ -- 2023-07-01 (土) 11:31:44
  • 画像の解像度を上げる https://waifu2x.udp.jp/ -- 2023-07-08 (土) 12:32:27
  • インターネット・ホットラインセンター https://www.internethotline.jp/ -- 2023-09-25 (月) 11:33:43
  • CSSの対応状況を調べる https://caniuse.com/ -- 2023-12-21 (木) 11:54:26
  • CSSリファレンス https://www.tohoho-web.com/css/index.htm -- 2023-12-21 (木) 11:56:28
  • Qt関係のソフトがエラーで起動しない場合、環境変数 QT_DEBUG_PLUGINS=1 を設定すると原因がわかる(ライブラリ不足などの)。 -- 2024-05-10 (金) 18:59:16

ThumbnailAlbumの使い方

・読み込み
画像の入ったフォルダをドラッグドロップで読み込ませる(デフォルトでjpgとtiff、
ツール→オプション→表示 で指定可らしい)。

・出力
ツール→オプション→出力の階層、
  フォトで、サイズ: 小640のまま、項目表示とメモ表示のチェックを外す、
  サムネイルで、レイアウトを 5列30行、
→OK
操作→実行→OK(デフォルトでドキュメント内のThumbnailAlbumフォルダに作成される)
→OK→webブラウザで自動的に開かれる(ThumbnailAlbumフォルダは移動可、index.htmlで開ける)。

・整理など
a) 出力をそのまま利用する場合には、サイズ小640 だと解像度悪いので大きくした方がよい(サイズ原寸大に
して、htmlを手修正するとよいかもしれない)。
b) サムネイルなどを利用して、不要なオリジナル画像を削除して整理するのがよさそう。

Ubuntu16.04LTSのユーザ環境に無理やりchromeをインストールして動かす

chromeを検索してダウンロードし、debファイルを保存する
# https://www.google.com/intl/ja_jp/chrome/ からchromeをダウンロードした。
# ファイル名は google-chrome-stable_current_amd64.deb (2022/10/20にダウンロードした)
# このdebで以下を試した。

$ pwd
/home/uhoge/bin  #uhogeはユーザ名
$ mkdir chrome_deb
$ cd chrome_deb
$ ar vx ../google-chrome-stable_current_amd64.deb  #dpkgはroot権限が必要なため使用せず
$ tar xvfJ control.tar.xz
$ tar xvfJ data.tar.xz
$ cd opt/google/chrome
$ ./chrome  #これでchrome webブラウザが動いた(デフォルトにはしないで様子見する)

つぎの内容のファイルを保存すると、それをGUIからダブルクリックしてchromeを起動させる
ことができる。予め、このアイコン上で右クリック→プロパティ→アクセス権→プログラムとして
実行可能、にチェックを入れておくこと。また、アイコンはドラッグしてランチャーに登録可。

ファイル名 chrome.desktop  #フォルダにはchromeと表示される
                           #(chrome_debディレクトリに置いた)
--------------------------------------------------
Desktop Entry]
Name=chrome
Comment=chrome
Exec=/home/uhoge/bin/chrome_deb/opt/google/chrome/chrome
Icon=/home/uhoge/bin/chrome_deb/opt/google/chrome/product_logo_48.png
Terminal=false
Type=Application
--------------------------------------------------

[ref]
https://tech.withsin.net/2017/03/27/dpkg-ar/
https://plaza.rakuten.co.jp/tshinoza/diary/201407250000/
https://jitaku.work/it/os/linux/ubuntu/desktop-shortcut/

Ubuntu 22.04 LTS にchromeをインストール

$ sudo sh -c 'echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list'
$ sudo wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add -
$ sudo apt-get update
||#binary-i386あたりでエラーが出たら、次のようにgoogle.listを修正する
||$ sudo vi /etc/apt/sources.list.d/google.list
||deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main 
$ sudo apt-get install google-chrome-stable
$ google-chrome

rootによるパッケージのインストールはこちら http://it.simasuke.net/2020/06/14/post-646/

LANG、UTF-8 BOM

macOSの端末で、ギリシャ文字や矢印などの文字の表示が変なのを直す(文字の表示幅と、カーソルの移動幅が一致しない)

ターミナル→環境設定→"Pro" (使っているプロファイル)→詳細
→Unicode東アジアA(曖昧)の文字幅W(広)にする、をチェックする。

文字の表示幅は変わらないが、カーソル移動が一致する。
なお、副作用で表示が崩れるケースもあるとのこと。

Ubuntu18, CentOS7 でスクリーンショットをとる

スクリーンショットを撮るウィンドウをアクティブにしておいて、Alt+PrintScreenを押す。画像ファイルは ~/Picturesに保存される。

bash

.bashrcに入れたらよいもの

export HISTFILESIZE=200000
export HISTSIZE=200000
shopt -s histappend
alias rm='rm -i'
alias mv='mv -i'
alias cp='cp -pi'

IFSをデフォルトにもどす

$ IFS=$' \t\n'

プロセス置換; <(command) , >(command)

$ cat <(ls -1)
    <(command)の結果をファイルとして catが読み込む感じ
$ ls -1 > >(wc)
    >(command)のファイルに lsがリダイレクションで書き込む感じ。
$ a.out >(wc)
    ファイルに出力する a.outが、直接、出力を別のコマンドに渡すことができる。
    a.out thefile ; cat thefile | wc と同じだろう

設定した方がよい shopt(シェルオプション)

shopt [-p] #with no options or -p, a list options is displayed
# -sはon -uはoff
shopt -s histappend   # append to the history file
shopt -s checkwinsize # checks the window size after each command

shopt -u huponexit  #デフォルト, send SIGHUP to all jobs by logout

Parameter Expansion

変数variableの値について、部分的な削除や置換をする場合、次のようにできる。

${variable#pattern}     先頭からもっとも短く一致した部分を削除
${variable##pattern}    先頭からもっとも長く一致した部分を削除

${variable%pattern}     末尾からもっとも短く一致した部分を削除
${variable%%pattern}    末尾からもっとも長く一致した部分を削除

${variable/pattern/string}   もっとも長く一致した部分をstringに置換(最初のひとつだけを置換)
${variable//pattern/string}  もっとも長く一致した部分をstringに置換(一致したすべてを置換)

コマンド履歴の検索

Ctrl-rを押したのち、検索文字をタイプするとインクリメントサーチが行われる。
次のものを検索したい場合は、文字をタイプせずに、Ctrl-rを押す。
Ctrl-rを押しすぎて、前にもどる場合には、Ctrl-sでもどれる。
(emacsの操作法と同じである)

なお、通常、端末はCtrl-sでスクロールロックが掛かる(解除はCtrl-q)。
スクロールロックを無効にするために、
$ stty stop undef
を一度しておく。もしくは、.bash_profileに記載しておく。

ふたつの .bash_historyを結合させる

あらかじめ .bashrcに例えばデフォルトで
HISTSIZE=1000
HISTFILESIZE=2000
とあったらコメントアウトするか(後方で再設定している場合)、両方とも200000くらいにする。
(後方で、HISTSIZE,HISTFILESIZEを大きく再設定していても、この段階で履歴数が切り詰められるようなので)

ログイン後、
cat .bash_history1  .bash_history2  > temphis
history -a
history -c
history -r temphis           #memo: cat ... > temphis や history -a が含まれない、完ぺきではない。なぜ?
history -w .bash_history1+2  #確認
history -w
ログアウト
(うまくいかなかたらログアウト後に .bash_history1+2を WinSCPなどで .bash_historyにファイル変更するなどする)

シグナル

キャッチしたときの挙動は、プログラムの実装次第と思われる

              # man 7 signal から。数字はシグナル番号
INT (ctrl+C)  #  2, interrupt, キーボードからの割り込み
QUIT          #  3, quit, キーボードによる中止
TERM          # 15, termmination, 終了
KILL          #  9, kill(キャッチされなく、問答無用で終了)

winscp

winscpで接続先の .pngファイルをダブルクリックしたときにペイントソフトで開く設定

歯車アイコン→エディタ→追加→外部エディタをチェックして C:\Windows\System32\mspaint.exeを
参照で選ぶ、起動条件として *.pngにする→OK→エディタの設定のリストで、*.*よりも *.pngを
上に移動しておく。

(注) 何か書き込んで上書き保存すると、接続先のファイルが書き換えられるだろう。
     個人的には、ペイントソフト以外のものを選びたい。

ドットファイルを表示する

表示→環境設定→パネル→隠しファイルを表示する、をチェックする

ファイル名を文字化けさせない設定 (windows7)

WinSCPを立ち上げて最初の画面で、保存したセッション→選んで、編集ボタン→環境→
ファイル名をUTF-8でエンコード、を自動はダメで、オンにする。
(接続先がUTF-8やSJISでもちゃんと表示されるようになる)

拡大鏡(windows7)

すべてのプログラム→アクセサリ→コンピュータの簡単操作→拡大鏡
又は、
Windowsロゴキー+プラス(+) 

Windowsロゴキー+ESC で終了する。

画面キャプチャによる動画記録

AGDRecを利用した動画の作成方法

Windowsで、AGDRec64.exeを起動(コーデック:設定を変更しない、エンコードモード:バッファリング
を選ぶ。後で変更可)
→ インディケータのアイコンを右クリックし、
   1) 領域指定録画 で、キャプチャ領域を指定する
   2) 設定 で、コーデックを無圧縮、オーディオ入力デバイスを使用しない、を選択しておく。
      バッファリングエンコーディングを選ぶ(カクカクしないように)。
   3) 録画開始・録画停止
→ Adobe Premiere elementsで mp4に変換する(縦横の画面サイズ比で不足分は黒背景になり、クロップ
   できないようだ。特に縦長の動画はそのまま編集できなく(Premiere Proなら可能らしい)、左右に黒帯が
   できる。これらの黒帯は AviUtlでクリッピングして削除できる。)
   # 単にファイルを読み込む → 右上の書き出し・配信 → 携帯電話・携帯プレイヤ
   # → 種類はApple TV,iPad,iPhone4の720p 29.97で良い

動画16分のAviutlによるクリッピングは Core i5で約40分かかる。
動画16分のPremiereによる変換は Core i5で約90分かかる。

AviUtlでのクリッピングの仕方

aviutl.exeを立ち上げる。ファイル→開く→動画ファイルを選択する。
そして、
表示→ツールウインドウの表示→クリッピング&リサイズ、にチェック
→設定ボタンで、クリッピングをする(偶数サイズにしなければならないらしい)→ウィンドウは閉じてよい
(注) クリッピングの情報は次回aviutl起動時にも引き継がれている。
つぎに、
ファイル→プラグイン出力→拡張x264出力(GUI)Ex→ビデオ圧縮ボタン
→プロファイルでyoutubeを選ぶなど(iphone4sがよさげ)
→OK→ファイル名を入れて、保存

(クリッピングの仕方) http://chie.exp.jp/140731test1.htm
(プロファイルを若干参考) https://rigaya34589.blog.fc2.com/blog-entry-256.html

(AviUtlとは) https://aviutl.info/
(いろいろなクリッピング・マスクの方法) https://aviutl.info/toriminngu-efekuto/
(基本的なこと )https://aviutl.info/intro/
(AviUtlのお部屋) http://spring-fragrance.mints.ne.jp/aviutl/

Adobe Premiere elementsの操作

  • クリップするには
    Adobe Premiere elementsのツール → パンとズーム → 内側のフォーカスフレームを消す。外側のは
    クリップしたいように配置する → 完了
  • 再生速度の変更(タイムストレッチの変更による方法) http://blogs.adobe.com/elementsjp/tips/19136
    タイムラインにあるビデオクリップについて、
    時間クリップを再生速度を変更したい先頭に移動し、鋏マークをクリック
    →終わりに移動し、鋏をクリック(範囲を指定)→その範囲をクリックして選択
    →右クリック→タイムストレッチ→100%を200%にすると2倍速くなる。
  • トランジション https://douga-tec.com/?p=14358
    トランジションのアイコン(右側列のアイコンから)→ディゾルブのクロスディゾルブや、回転などを選び、
    動画間にドラッグドロップ →1秒、左のクリップ、などを選び→完了
  • テキストテロップ https://douga-tec.com/?p=14308
    上のテキストメニュー→新規テキスト→初期設定のテキスト
    →テキストを入力。
    (色は、テキストを選択しておき、カラープロパティで変更可)
  • 動画を90°回転
    ビデオクリップの上で右クリック→90°回転
    →適宜、拡大縮小可(適用エフェクト、でも回転や拡大縮小が可)

どうしようもないWebページの印刷

縦にとても長い画像ファイルを、複数の紙に分割して印刷する

アクセサリ→ペイント→画像ファイルを開く→印刷→ページ設定→上下の余白をゼロに設定
→拡大縮小の合わせるのところで、ページ数を、1 x N にして、左のプレビューを見ながら
左右の余白が少なくなるように Nの大きな数字を決める→OK→印刷する
[ref] https://cocomachi.tokyo/print-paint-1

ペイントが一番よさげ。

Webサービス(微妙?)

[ref] https://webnaut.jp/markup/1125.html

なんとも印刷できないwebページ(背景黒で白文字)の印刷方法

1) chromeの拡張機能 GoFullPage (Full Page Screen Capture) で、webページの画像を保存する。

2) photoshop elementsで、
   レイヤ->新規調整レイヤ->階調の反転->OK
   ファイル->別名で保存->png画像などで保存

3) excelで
   空白のブック->挿入->画像->このデバイスから、保存したpng画像を貼り付ける。
   いったん、ファイル->印字->戻る(「←」)をし、ページ境界を表示させる。
   貼り付けた画像を、適当に拡大等して、印刷する。

ファイルサイズを調べる

du -s -SG ディレクトリ名  #Gbyte単位でディレクトリ階層の合計サイズが得られる

dateコマンドの出力を使った引き算をしたい。

  • dateで -dオプションで時刻の文字列を渡し、+%sで1970/01/01からの経過秒を表示させて、それをexprで引き算する
    (例)
    $ expr `date -d"Fri Dec 15 12:50:43 JST 2017" +%s` - `date -d"Fri Dec 15 12:45:06 JST 2017" +%s`
    337

Youtubeプレーヤーのショートカット

  • 再生/停止 K or Enter
  • 10秒早送り/10秒巻戻し L / J
  • 5秒早送り/5秒巻戻し →/←
  • 再生時間の10%〜90%の位置にジャンプ 1〜9
  • 先頭の位置にジャンプ 0
  • フルスクリーン/その解除 F
  • ミュート/その解除 M
  • 再生速度の変更 > と <

Wacomに関すること

  • 各種スタンドの取扱説明 http://wacom.com/start/stand (モバイルスタンドの場合は、劣化したはめ込みの交換部品があるらしい。)

HP Pavilion 15s-du1008TUに関すること

Acer ASPIRE5750に関すること

  • タッチパットの有効・無効の切り替え  Fn+F7
  • isoファイルをDVDに書き込む(NTI Media Maker 9を使う)
    起動後→データ→データディスク→ファイル→ISOディスクイメージファイルからディスク作成
    →isoファイルを選択→スタート(書き込みする)→DVDを入れる
    →書き込み後に記録データとソースデータを確認してください、にチェックを入れる

重送していないのに重送エラーが発生するときの解決法(Canon ImageFORMULA DR-150 )

スキャナの電源を切る、PCを再起動する。(他の手段もあり。) キャノンのQ&A

ASUS U24Eに関すること

  • 右側のUSB3.0ポートが調子悪い・認識しない場合の解決法
    コントロールパネル→デバイスマネージャーでみると、不具合が出ていた。
    asus_u24e_ASMediaUSB3.0、デバイスマネージャ.png

    ここで、不具合の出ているASMedia USB 3.0 ... のデバイスをアンインストールする →一覧から消える→操作→ハードウェア更新のスキャン、をする。 すると、自動的にドライバーが再度入れられ、右側のポートが復活した。

    [ref] https://egg.5ch.net/test/read.cgi/notepc/1509064508/459-n の0539

    nowrap

ノートPCなどLi Ionバッテリに関すること

  • バッテリ残量を0%にしない(充電でき無くなる可能性がある)。
  • AC電源につなぎっぱなしで利用する場合、バッテリの寿命を短くしないためにはバッテリ残量は例えば80%程度で使い続けるのがのが良い。
  • 長期保存の場合は、例えばバッテリ残量を80%でバッテリを本体から外す。
  • その他情報

windowsのzipをlinuxで解凍するとエラーになる場合に、修復して解凍できる

windowsで作られたzip(おそらく)が、次のエラーでlinuxで解凍できないとき。
$ unzip hoge.zip
Archive:  hoge.zip
warning [hoge.zip]:  zipfile claims to be last disk of a multi-part archive;
  attempting to process anyway, assuming all parts have been concatenated
  together in order.  Expect "errors" and warnings...true multi-part support
  doesn't exist yet (coming soon).
error [hoge.zip]:  missing xxxxx bytes in zipfile
  (attempting to process anyway)
error [hoge.zip]:  attempt to seek before beginning of zipfile
  (please check that you have transferred or created the zipfile in the
  appropriate BINARY mode and that you have compiled UnZip properly)
以下の修復を試すと解凍できるようだ。zipのバージョンはなるべく新しいものを使う。
$ zip -F hoge.zip --out hoge_mod.zip
$ unzip hoge_mod.zip

RPMパッケージから特定のファイルを取り出す

$ rpm2cpio パッケージファイル名 | cpio -im 取り出したいファイル名

mailコマンドの使い方(mailxもコマンドの実体は同じ)

  • mailコマンドのプロンプト > に対するコマンド
    m メールアドレス  メール送信。メッセージの終わりは . である
    h                 /var/mail/ユーザ名 にあるメール一覧。カレントの選択は >印 である
    q                 終了
    x                 何もせず終了
    数字              数字で示されているメールを表示。ただのenterでは >印 を表示
    d [数字]          数字で示されているメールを削除。ただのenterでは >印 を削除
    help              コマンド一覧
    list              コマンド一覧(沢山)
  • /.mailrc 起動時に実行するコマンドを記載できる。例えば、

    set nohold
    が有用である。>O印 (既読マーク)のメールを q終了時に~/mboxに保存する設定である。
    システム共通に使われるものは、/etc/nail.rcにある(/etc/mail.rcではない)。

.htpasswdのパスワードを作る

$ htpasswd -nb username hogehogepassword

ssh

リモートログインするときにパスワードを入力しない方法

RSA鍵ペアを作る。どこでもよいので hostAで、
$ ssh-keygen
   o ファイル名はデフォルトで ~/.ssh/id_rsa
   o パスフレーズは設定しない
をすると ~/.sshディレクトリに id_rsa と id_rsa.pub が作られる。
( id_rsaは秘密鍵、id_rsa.pubは公開鍵である。秘密鍵は取り扱いに注意すること。)
次に、id_rsa.pub をリモートログインするhostBの ~/.ssh/authorized_keys に
追加する(無ければ新規に作る)。

以上により、hostAからhostBへ sshするときに -i オプションをつけて
パスワードを入力しなくてもログインできるようになる。
$ ssh user@mhostB -i ~/.ssh/id_rsa

すべてのホストの.sshディレクトリに id_rsaをコピーして、id_rsa.pubを含む
authorized_keysも同様に用意すれば、相互にホスト間でパスワード入力をしなくても
sshログインできるようになる。

sshの接続設定(自動的に渡す引数)

ssh接続ホストするときに、ポートを2234を使い、また認証用秘密鍵ファイルid_rsaを使うとき、 毎回 sshコマンドの引数でid_rsaを指定しない方法。~/.ssh/configに次の事柄を書いておくと自動的に使われる。 scpやsftpでも使われる。

# see man ssh_config

Host *.ac.jp
  Port           2234
  IdentityFile   ~/.ssh/id_rsa

ssh接続が2時間程度操作していないと切断されることの回避法

/etc/ssh/ssh_config で、
Host *
のところに
  ServerAliveInterval  600  #デフォルト0(しない)から 600秒毎にheartbeatを送る。
  ServerAliveCountMax    3  #デフォルトの値(600*3=10minサーバーから応答が無いと切断する)
を追加する。

ユーザ毎に、~/.ssh_configに設定もできるはず。

sshのX11転送で .Xauthority does not existと出たときの対処法

cygwin$ ssh user@host.eit.hirosaki-u.ac.jp -Y
Warning: No xauth data; using fake authentication data for X11 forwarding.
/usr/bin/xauth:  file /home/user/.Xauthority does not exist
host$ logout
cygwin$ xauth add :0 . `mcookie`  #←これをする
xauth:  file /home/user/.Xauthority does not exist  #気にしない
cygwin$ xauth list
cygwin/unix:0  MIT-MAGIC-COOKIE-1  edf222c5df4c5c2ae777776555a7382c
cygwin$ ssh user@host.eit.hirosaki-u.ac.jp -Y
hoge$

git fetchなどで、Warning: untrusted X11 forwarding setup failed: xauth key data not generatedと出たときの対処法

git fetchなどで、URLが sshで指定したリポジトリになっているとき ssh絡みで出る。
.ssh/config に
ForwardX11  no
を加える(デフォルトでフォワーディングしないようにする)。

ubuntu12上の pukiwiki 1.4.7 (EUC版) -> ubuntu18上の 1.5.1 (UTF-8) へのコンテンツの変換

コンテンツとしてのページは、ページ名がEUCエンコードされた ファイル名.txt となって
wikiディレクトリに保存されている。ファイル名をUTF-8エンコードのファイル名に変換する。
ツールencls.phpを使用( https://pukiwiki.osdn.jp/dev/?BugTrack/2186 で説明されている
https://ja.osdn.net/cvs/view/pukiwiki/devel/encls.php?view=log からダウンロードする。
実行には php7.2-mbstring のパッケージが必要なのでインストールしておく。)

(注) attachディレクトリの添付ファイルは、数が少なく、英語のファイル名だったものは
そのまま利用可能である。日本語のファイル名だったものは、文字化けするがページ上の
ファイルアイコンをクリックしてダウンロードができる。そのため、手動で適宜復旧すること
とした。その他 backup, cache, counter, diffディレクトリは初期状態のまま(リセット
されたような状態)としすることとした。
なお、ダウンロードするとattachの .logファイルが更新される。日付が新しくなるので、
ファイルしたファイルが、attach上のどのファイルなのかの対応がわかる。

以下、手順

$ cd wiki  #1.4.7のwikiディレクトリ

EUCエンコードされたファイル名をUTF-8エンコードのものに変更する。
なお、encls.phpによって出力されるファイル名の先頭には UTF-8 が付く。
$ for f in *.txt; do mv $f `./encls.php $f`; done

ファイルの中身をEUCからUTF8に変更
$ for f in UTF-8*.txt ; do nkf -Ew $f > EUC$f; done

オリジナルのファイルを別ディレクトリtmpに移動、あとで削除する。
作業途中のファイルリストをtempファイルに作成する。
$ mkdir tmp; mv [0-9A-F]*.txt tmp
$ ls -1 EUCUTF-8*.txt > temp

ファイル名とファイルの中身をUTF-8に変換したファイルについて、ファイル名の先頭に
付いている EUCUTF-8 を削除する。
$ for f in `cat temp` ; do echo $f | sed 's/EUCUTF-8//'; done          #事前確認
$ for f in `cat temp` ; do mv $f `echo $f | sed 's/EUCUTF-8//'`; done  #削除

以上のように作った wikiディレクトリを、1.5.1のwikiディレクトリとする。

pukiwiki 1.5.1で KaTexを動かす

katex.inc.phpファイルを puluginフォルダに置く。 filekatex.inc.php (ver 0.13.0)

skin/pukiwiki.css.php と skin/tdiary.css.php にある span.size[1-7]内の、font-size:hogehoge; を font-size:hogehoge :not(.katex); に変更する。

利用方法

KaTexを使うページに、#katex をいちどだけ書いておき、$と$ または $$と$$ の間に式を書く。

#katex
$y=ax^2+bx+c$
や
$$
y=ax^2+bx+c ~(センタリングされる)
$$
別の例、$ \int_0^\infty \bigl\{rR_n{}^l(r)\bigr\}^*\bigl\{rR_{n'}{}^l(r)\bigr\}\,dr=\delta_{nn'}
$

とすると、

$y=ax^2+bx+c$ や $$ y=ax^2+bx+c ~(センタリングされる) $$ 別の例、$ \int_0^\infty \bigl\{rR_n{}^l(r)\bigr\}^*\bigl\{rR_{n'}{}^l(r)\bigr\}\,dr=\delta_{nn'} $

となる。

なお、式にエラーがあると、整形されないまま表示される。

リンク

TeXclip (webアプリ)

https://texclip.marutank.net/

\int_0^\infty \bigl\{rR_n{}^l(r)\bigr\}^*\bigl\{rR_{n'}{}^l(r)\bigr\}\,dr=\delta_{nn'}

などと入れ、左のGenerateボタンを押すと整形結果を表示する。結果の画像のダウンロードも可。

サーバー証明書の確認方法(ブラウザで表示できないとき)

https://ssltools.digicert.com/checker/views/checkInstallation.jsp にURLを入れる。 証明書のタイプは、EV, OV, DV の種類がある。

gccのオプション

以下の情報に関する gccのバージョン

allium$ cat /etc/redhat-release
CentOS Linux release 7.4.1708 (Core)
allium$ gcc --version
gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-16)
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

gccで何のオプションがつくか

allium$ echo | gcc -O3 -E -v - 2>&1 | grep cc1
 /usr/libexec/gcc/x86_64-redhat-linux/4.8.5/cc1 -E -quiet -v - -mtune=generic -march=x86-64 -O3

allium$ echo | gcc -Ofast -E -v - 2>&1 | grep cc1
 /usr/libexec/gcc/x86_64-redhat-linux/4.8.5/cc1 -E -quiet -v - -mtune=generic -march=x86-64 -Ofast

allium$ echo | gcc -Ofast -march=native -E -v - 2>&1 | grep cc1
 /usr/libexec/gcc/x86_64-redhat-linux/4.8.5/cc1 -E -quiet -v - -march=core-avx2 -mcx16 -msahf -mmovbe -maes
 -mpclmul -mpopcnt -mabm -mno-lwp -mfma -mno-fma4 -mno-xop -mbmi -mbmi2 -mno-tbm -mavx -mavx2 -msse4.2 -msse4.1
 -mlzcnt -mno-rtm -mno-hle -mrdrnd -mf16c -mfsgsbase -mno-rdseed -mno-prfchw -mno-adx -mfxsr -mxsave -mxsaveopt
 -mno-pku --param l1-cache-size=32 --param l1-cache-line-size=64 --param l2-cache-size=3072 -mtune=core-avx2 -Ofast

man gcc, man gfortran から

-Ofast
    Disregard strict standards compliance.  -Ofast enables all -O3 optimizations.  It also enables optimizations
    that are not valid for all standard-compliant programs.  It turns on -ffast-math and the Fortran-specific
    -fno-protect-parens and -fstack-arrays.


    -ffast-math
        Sets -fno-math-errno, -funsafe-math-optimizations, -ffinite-math-only, -fno-rounding-math,
        -fno-signaling-nans and -fcx-limited-range.

        This option causes the preprocessor macro "__FAST_MATH__" to be defined.

        This option is not turned on by any -O option besides -Ofast since it can result in incorrect output for
        programs that depend on an exact implementation of IEEE or ISO rules/specifications for math functions. It
        may, however, yield faster code for programs that do not require the guarantees of these specifications.

        -fno-math-errno
             Do not set "errno" after calling math functions that are executed with a single instruction, e.g., "sqrt".  A
             program that relies on IEEE exceptions for math error handling may want to use this flag for speed while
             maintaining IEEE arithmetic compatibility.

             This option is not turned on by any -O option since it can result in incorrect output for programs that
             depend on an exact implementation of IEEE or ISO rules/specifications for math functions. It may, however,
             yield faster code for programs that do not require the guarantees of these specifications.

             The default is -fmath-errno.

             On Darwin systems, the math library never sets "errno".  There is therefore no reason for the compiler to
             consider the possibility that it might, and -fno-math-errno is the default.

        -funsafe-math-optimizations
             Allow optimizations for floating-point arithmetic that (a) assume that arguments and results are valid and
             (b) may violate IEEE or ANSI standards.  When used at link-time, it may include libraries or startup files
             that change the default FPU control word or other similar optimizations.

             This option is not turned on by any -O option since it can result in incorrect output for programs that
             depend on an exact implementation of IEEE or ISO rules/specifications for math functions. It may, however,
             yield faster code for programs that do not require the guarantees of these specifications.  Enables
             -fno-signed-zeros, -fno-trapping-math, -fassociative-math and -freciprocal-math.

             The default is -fno-unsafe-math-optimizations.

         -ffinite-math-only
             Allow optimizations for floating-point arithmetic that assume that arguments and results are not NaNs or
             +-Infs.

             This option is not turned on by any -O option since it can result in incorrect output for programs that
             depend on an exact implementation of IEEE or ISO rules/specifications for math functions. It may, however,
             yield faster code for programs that do not require the guarantees of these specifications.

             The default is -fno-finite-math-only.

        -frounding-math
             Disable transformations and optimizations that assume default floating-point rounding behavior.  This is
             round-to-zero for all floating point to integer conversions, and round-to-nearest for all other arithmetic
             truncations.  This option should be specified for programs that change the FP rounding mode dynamically, or
             that may be executed with a non-default rounding mode.  This option disables constant folding of floating-
             point expressions at compile time (which may be affected by rounding mode) and arithmetic transformations
             that are unsafe in the presence of sign-dependent rounding modes.

             The default is -fno-rounding-math.

             This option is experimental and does not currently guarantee to disable all GCC optimizations that are
             affected by rounding mode.  Future versions of GCC may provide finer control of this setting using C99's
             "FENV_ACCESS" pragma.  This command-line option will be used to specify the default state for "FENV_ACCESS".

         -fsignaling-nans
             Compile code assuming that IEEE signaling NaNs may generate user-visible traps during floating-point
             operations.  Setting this option disables optimizations that may change the number of exceptions visible with
             signaling NaNs.  This option implies -ftrapping-math.

             This option causes the preprocessor macro "__SUPPORT_SNAN__" to be defined.

             The default is -fno-signaling-nans.

             This option is experimental and does not currently guarantee to disable all GCC optimizations that affect
             signaling NaN behavior.

         -fcx-limited-range
             When enabled, this option states that a range reduction step is not needed when performing complex division.
             Also, there is no checking whether the result of a complex multiplication or division is "NaN + I*NaN", with
             an attempt to rescue the situation in that case.  The default is -fno-cx-limited-range, but is enabled by
             -ffast-math.

             This option controls the default setting of the ISO C99 "CX_LIMITED_RANGE" pragma.  Nevertheless, the option
             applies to all languages.

    -fno-protect-parens
        By default the parentheses in expression are honored for all optimization levels such that the compiler does
        not do any re-association. Using -fno-protect-parens allows the compiler to reorder "REAL" and "COMPLEX"
        expressions to produce faster code. Note that for the re-association optimization -fno-signed-zeros and
        -fno-trapping-math need to be in effect. The parentheses protection is enabled by default, unless -Ofast is

    -fstack-arrays
        Adding this option will make the Fortran compiler put all local arrays, even those of unknown size onto stack
        memory.  If your program uses very large local arrays it is possible that you will have to extend your
        runtime limits for stack memory on some operating systems. This flag is enabled by default at optimization
        level -Ofast.

添付ファイル: fileasus_u24e_ASMediaUSB3.0、refの0539.png 129件 [詳細] fileasus_u24e_ASMediaUSB3.0、デバイスマネージャ.png 122件 [詳細] filekatex.inc.php 555件 [詳細]

トップ   編集 凍結 差分 バックアップ 添付 複製 名前変更 リロード   新規 一覧 単語検索 最終更新   ヘルプ   最終更新のRSS
Last-modified: 2024-05-10 (金) 18:59:17 (9d)