Takuya71 のぶろぐ

外資系ソフトウェア会社で働いてます、認定スクラムマスター

emacs tips

emacs tips ちょっとしたemacs tips を書いていく

移動系

M-f 一単語次に進む
M-b 一単語前に戻る

C-n 次の行に移動
C-p 前の行に移動

C-a 行頭に移動
C-e 行末に移動

M-a 文頭に移動
M-e 文末に移動

M-< ファイルの先頭に移動
M-> ファイルの末尾に移動

保存

C-x s すべてのファイルを保存する
C-x C-w 別名で保存する
C-x i バッファに別ファイルを挿入する
C-x RET f 文字コード・改行コードを変換する
C-x RET r 文字コード・改行コードを変換して開き直す
C-x b バッファを切り替える
C-x k バッファを消去する

編集

M-; コメントする、コメントを解除する
C-q 特殊文字を入力する
C-/ アンドゥ
M-x replace-string <br> replacement string <br> new string <br>

文字数をカウントする

書いた文書の 文字数をカウントしたい時
M-x =

fish で複数のファイルを大量に作る

TL;DR

fish シェルで hogehoge1.txt, hogehoge2.txt…. のように連番のファイルを沢山作る bash だと touch hogehgoe{1..10}.txt と同じことをしたい

どうやる

Stack overflow にあった

seq 10

のように seq を使うと 1,2,3,4,5,6,7,8,9,10 のように連番がつくれます。

⋊> ~ seq 10                                                             22:47:18
1
2
3
4
5
6
7
8
9
10

これをつかい hogehoge1.txt から hogehoge10.txt を作ります。

touch hogehoge(seq 10).txt
> ls
hogehoge1.txt  hogehoge2.txt  hogehoge4.txt  hogehoge6.txt  hogehoge8.txt
hogehoge10.txt hogehoge3.txt  hogehoge5.txt  hogehoge7.txt  hogehoge9.txt

おまけ

作ったファイルに hogehoge を追加

for file in *.txt
    echo hogehoge >> $file
end

earhoox 買いました

iphone の純正のイヤフォンをお使いの皆様は、純正のイヤフォンって耳にフィットしてますでしょうか?

私は iphone のイヤフォンに限らないのですが、 なかなか耳にフィットするイヤがなく iphone のイヤフォンもすぐにずれてしまう、落ちてしまう状態でして、そういう状態ですと音量大きめでの使用になってしまっております。。。

先日の AirPod の発表を聞いて 欲しくはなったのですが 絶対これ 私の耳だと フィットしないのは見え見えですし 前からなにかいいカバーないかと考えていたのですが 、 これを気に 探してみて earhoox っていうのがよさそうなので 買ってみました。 amazon でも売ってますが、たまたま渋谷に行く機会があったので 渋谷のTSUTAYA内にある e-earphone で買ってきました。

LサイズとMサイズがついていますが、 私はLサイズを使いました。 Mサイズは 奥さん用にあげました。

装着感は ばっちりです、もっと早く買っておけばよかった。 頭振っても 落ちません。 今は家の中だけで試してますが、明日、明後日と外でも試してみたいと思います。

OSX 10.11 に gnuplot をインストール

gnuplot をインストール

homebrew でインストール

参照

qiita.com

aquaterm をインストール

インストール時にエラーでた

~  brew install gnuplot --with-aquaterm
==> Installing dependencies for gnuplot: libpng, freetype, fontconfig, jp
==> Installing gnuplot dependency: libpng
==> Downloading https://homebrew.bintray.com/bottles/libpng-1.6.19.el_capitan.bo
######################################################################## 100.0%
==> Pouring libpng-1.6.19.el_capitan.bottle.tar.gz
🍺  /usr/local/Cellar/libpng/1.6.19: 17 files, 1.2M
==> Installing gnuplot dependency: freetype
==> Downloading https://homebrew.bintray.com/bottles/freetype-2.6_1.el_capitan.b
######################################################################## 100.0%
==> Pouring freetype-2.6_1.el_capitan.bottle.tar.gz
🍺  /usr/local/Cellar/freetype/2.6_1: 60 files, 2.6M
==> Installing gnuplot dependency: fontconfig
==> Downloading https://homebrew.bintray.com/bottles/fontconfig-2.11.1.el_capita
######################################################################## 100.0%
==> Pouring fontconfig-2.11.1.el_capitan.bottle.4.tar.gz
Error: Permission denied - /usr/local/var
Warning: Bottle installation failed: building from source.
==> Downloading http://fontconfig.org/release/fontconfig-2.11.1.tar.bz2
==> Downloading from http://www.freedesktop.org/software/fontconfig/release/font
######################################################################## 100.0%
==> Patching

brew doctor を実行

  ~  brew doctor
Please note that these warnings are just used to help the Homebrew maintainers
with debugging if you file an issue. If everything you use Homebrew for is
working fine: please don't worry and just ignore them. Thanks!

Warning: The /usr/local is not writable.

You should probably change the ownership and permissions of /usr/local
back to your user account.
  sudo chown -R $(whoami) /usr/local

Warning: The /usr/local directory is not writable.
Even if this directory was writable when you installed Homebrew, other
software may change permissions on this directory. Some versions of the
"InstantOn" component of Airfoil are known to do this.

You should probably change the ownership and permissions of /usr/local
back to your user account.
  sudo chown -R $(whoami):admin /usr/local

Warning: Broken symlinks were found. Remove them with `brew prune`:
    /usr/local/bin/N1
    /usr/local/etc/fonts/conf.d/10-scale-bitmap-fonts.conf
    /usr/local/etc/fonts/conf.d/20-unhint-small-vera.conf
    /usr/local/etc/fonts/conf.d/30-metric-aliases.conf
    /usr/local/etc/fonts/conf.d/30-urw-aliases.conf
    /usr/local/etc/fonts/conf.d/40-nonlatin.conf
    /usr/local/etc/fonts/conf.d/45-latin.conf
    /usr/local/etc/fonts/conf.d/49-sansserif.conf
    /usr/local/etc/fonts/conf.d/50-user.conf
    /usr/local/etc/fonts/conf.d/51-local.conf
    /usr/local/etc/fonts/conf.d/60-latin.conf
    /usr/local/etc/fonts/conf.d/65-fonts-persian.conf
    /usr/local/etc/fonts/conf.d/65-nonlatin.conf
    /usr/local/etc/fonts/conf.d/69-unifont.conf
    /usr/local/etc/fonts/conf.d/80-delicious.conf
    /usr/local/etc/fonts/conf.d/90-synthetic.conf

Warning: Homebrew's sbin was not found in your PATH but you have installed
formulae that put executables in /usr/local/sbin.
Consider setting the PATH for example like so
    echo 'export PATH="/usr/local/sbin:$PATH"' >> ~/.zshrc

Warning: Your Homebrew is outdated.
You haven't updated for at least 24 hours. This is a long time in brewland!
To update Homebrew, run `brew update`.

Intellij IDEA plugin がダウンロード出来ない

Intellij IDEA で plugin のインストールを行おうとすると、 ダウンロードに非常に時間がかかり ネットワークが不調というメッセージがでてプラグインのダウンロードが出来ない状態になりました。

当初、一時的なネットワークの不調と考えていましたが、数日たっても改善せず。 試しに携帯電話のテザリング経由で接続したところ問題なくすぐにダウンロードができることがわかり、これは ネットワーク側の問題だと思うわけで ネットワークのサポートに問い合わせを行いました。

当初は ネットワークには問題無いということでしたが、 携帯経由だと うまくいくことから ネットワーク側になにか原因があるということで、 食い下がって調べてもらいました。

結果的には うちのネットワークは プロパイダーからは各機器にプライベートアドレスが割り当てられている タイプなのですが どうも そのNATとの相性が悪いのではということになりました。 Global のIPを割り当てる 有料のオプションがあるのですが、それを使うと NAT経由ではなくなるために改善するかもしれないということなので試してみたところ 現象は改善され、さらに 通常のスピードも向上しました。

Google 等もQUIC使った通信だと パケットロスしまくりで、すごく遅かったので オフにしていたのですが GlobalIPにしてから QUICをオンにしたところ 今までの不調が嘘のように 高速化しました。

うちの環境に限った話となりますが、どうもNATとの相性がよくない時があったようです。

blogsync 使って はてなブログの内容を github にアップ

blogsync 使って はてなブログの内容を github にアップ

12月に blogsync という はてなブログを markdown 形式でローカルに保存したり、 ローカルの markdown に加えた変更を はてなブログに反映させることができる ツールがあることを知りました。

motemen.hatenablog.com

これを使えば GitHub でブログの内容を管理することができるなとおもい、 試してみました。

やりたいこととしては

はてなブログ 
--> blogsync で ローカルレポジトリへ同期
--> GitHub へ push

というような流れを考えています。

ブログを書くのは モバイルつかって書くことが最近多いので、はてなブログ側で書くことを想定。

まずは blogsync のインストール。

インストールした後は

~/.config/blogsync/config.yml ファイルを作成し、はてなブログのユーザ名、パスワード、ローカルのパスを設定します。

takuya71.hatenablog.com:
  username: takuya71
  password: xxxxxxxx
default:
  local_root: /home/takuya/src/takuya71_hatenablog

設定後 まずは ローカルにPULL します。

> blogsync pull takuya71.hatenablog.com

あとは ローカルの内容を github へ push します。

git push github  master

私は 以下のような シェルスクリプトを 用意しておいて cron で毎日定時にローカルに持ってきてその後 GitHubへPUSH するようにしています。

#!/bin/bash

echo -e "\033[0;32mDeploying updates to GitHub...\033[0m"

cd ~/src/takuya71_hatenablog

blogsync pull takuya71.hatenablog.com

# Add changes to git.
git add -A

# Commit changes.
msg="Updated Hatenablog site `date`"
if [ $# -eq 1 ]
  then msg="$1"
fi
git commit -m "$msg"

# Push source and build repos.
git push github  master

cron の設定

ATH=/usr/local/rbenv/shims:/usr/local/rbenv/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/usr/local/go/bin:/home/takuya/.local/bin:/home/takuya/bin:/home/takuya/.go/bin

GOPATH=/home/takuya/.go/

30 8 * * * /home/takuya/src/takuya71_hatenablog/deploy.sh > /tmp/cron_err.log 2>&1

注意

下書きも ローカルに同期されるので GitHub のパブリックな レポジトリにプッシュすると 下書きも公開されます。

gitignore を作ってくれる gibo

qiita.com

こんな 便利そうな ツールがあったなんて。

homebrew でインストールして すぐに gibo を実行すると、

fatal: Cannot change to '/Users/takuya/.gitignore-boilerplates': No such file or directory

こんなエラーが。。

まずは update が必要なのかな。 -u をつけてアップデートを実行。

gibo -u
fatal: Cannot change to '/Users/takuya/.gitignore-boilerplates': No such file or directory
Cloning https://github.com/github/gitignore.git to /Users/takuya/.gitignore-boilerplates
Cloning into '/Users/takuya/.gitignore-boilerplates'...
remote: Counting objects: 5211, done.
remote: Compressing objects: 100% (7/7), done.
remote: Total 5211 (delta 2), reused 0 (delta 0), pack-reused 5204
Receiving objects: 100% (5211/5211), 1.12 MiB | 40.00 KiB/s, done.
Resolving deltas: 100% (2607/2607), done.
Checking connectivity... done.

この後で実行すると うまく行きました。

> gibo scala
### https://raw.github.com/github/gitignore/be3333655bffe9507d66cc864aee95ed6052b4ed/scala.gitignore

*.class
*.log

# sbt specific
.cache
.history
.lib/
dist/*
target/
lib_managed/
src_managed/
project/boot/
project/plugins/project/

# Scala-IDE specific
.scala_dependencies
.worksheet