@peccul is peccu

(love peccu '(emacs lisp cat outdoor bicycle mac linux coffee))

標準入力の内容をチャットに投稿する1 (bash, curl版)

長時間かかるコマンドの実行結果をチャットに通知したくなったので、スクリプトを書きました。 (コマンド実行後の定型文通知や引数に指定した文字列の通知はすでに利用していたが、結果を通知したくなった)

続きを読む

プロキシ環境下でdocker buildするときのコマンドオプション

プロキシ環境下でapt-get update等を含むDockerfileを docker build するときは --build-arg でプロキシの設定を渡す。

docker build --build-arg HTTP_PROXY=$HTTP_PROXY --build-arg http_proxy=$http_proxy --build-arg HTTPS_PROXY=$HTTPS_PROXY --build-arg https_proxy=$https_proxy .

docs.docker.com

snake_case->PascalCase->camelCase->snake_case->...に変換するコマンド

id:IMAKADOさんの実装を参考に、以下を追加した。

  • リージョンだけでなくカーソルの置いているシンボル(thing-at-point)も変換対象とした
  • snake_case<->PascalCaseだけでなくcamelCaseを加えて循環するようにした

d.hatena.ne.jp

続きを読む

Slackのフィード一覧をOPMLファイルに書き出す

Feedlyでは読みきれないのでSlackでフィードを購読(/feed subscribe URL)すれば目について読めるのではないか。と思った私は甘かった。

結局フィードが増えて追いつけなくなったので feedreader に移行することにした。

流れ

実行するJS

かなり雑に書いた

(function(){
  var opml = '';
  var name = document.querySelector('.team_switcher.menu_launcher').innerText.trim();
  opml += `<?xml version="1.0" encoding="UTF-8"?>

<opml version="1.0">
  <head>
    <title>${name}'s RSS feeds</title>
  </head>
  <body>
    <outline text="slack" title="slack">
`;

  var outline = function(_title, _url){
    var title = _title.replace(/&/g, '&amp;');
    var url = _url.replace(/&/g, '&amp;');
    return `      <outline type="rss" text="${title}" title="${title}" xmlUrl="${url}"/>\n`;
  };

  document.querySelectorAll('#feeds div[id^=feed] a[class=""]').forEach((e)=>{
    var href=e.href;
    var title=e.title;
    opml += outline(title, href);
  });

  opml += `    </outline>
  </body>
</opml>
`;
  console.log(opml);
})();

Node.jsでメールを送る。mailコマンドやSMTPサーバー不要。

github.com

npm i sendmail

const sendmail = require('sendmail')();

sendmail({
  from: 'from@example.com',
  to: 'to@exampl.com',
  subject: '件名も化けなかった',
  text: 'これは本文'
}, function(err, reply) {
  console.log(err && err.stack);
  console.dir(reply);
});

実態は送信先メールアドレスに対して直接SMTPを喋っている様子。 ローカルのmailコマンドやSMTPサーバーに依存しない。