Skip to content

Instantly share code, notes, and snippets.

^+a::
IfWinExist PuTTY
WinActivate
Else
Run,C:\Users\kazunori.nishi\app\putty-0.70-jp20170713\puttyjp.exe
return
^+b::
Process,Exist,chrome.exe

cronの多重起動防止

基本方針

pidof コマンドを使う (稼働中のプロセスIDを返す)

  • || で繋げてコマンド実行すればOK
  • /proc/$$/comm あたりと同じ動作なので、スクリプトの場合 bash が入ってしまう
  • pidof -x foo のように -x を入れるとスクリプトは対応できる

誤検出

@maiha
maiha / print-func.js
Created February 28, 2019 18:06
Javascript AST: print CallExpression or FunctionDeclaration
/* npm install acorn acorn-walk */
/* usage: nodejs print-func.js foo.js --call */
let mode = 'name';
let index = process.argv.findIndex(function(e) { return e == "--call"});
if (index > 0) { process.argv.splice(index, 1); mode = 'call'; }
let filename = process.argv[2];
if (!filename) throw "file not found";
@maiha
maiha / run.md
Last active February 10, 2019 01:10
$ curl -H 'Accept-Encoding: gzip' http://staff.livedoor.blog/ > x1
$ crystal test.cr > x2

$ LC_ALL=C ls -l x1 x2
-rw-rw-r-- 1 maiha maiha 13786 Feb 10 10:00 x1
-rw-rw-r-- 1 maiha maiha 13602 Feb 10 10:06 x2

$ file x1 x2
x1: gzip compressed data, last modified: Sun Feb 10 01:00:48 2019, from Unix
@maiha
maiha / sse.md
Last active February 15, 2024 12:48
Nginx configuration Cheat Sheet

nginx

location /sse/ {
  # enables EventSource support
  proxy_http_version 1.1;
  proxy_set_header Connection "";

  proxy_buffering off;
}

oauth2-proxy

docker-compose.yml

replace MYDOMAIN, MYHOST

version: '2'
services:
  oauth2-proxy-4181:
@maiha
maiha / jquery.md
Last active December 12, 2018 07:40

tooltip: max-width

.tooltip-inner {
  white-space: pre-wrap;
  max-width: 100%;
}

table: prevent 100% width

目的

  • 任意の日本語文章(UTF-8)を「ひらがな化」する

結論

  • ipadic-utf8 で mecab -Oyomi | nkf --hiragana がバランスよさげ
$ ls -l dic
合計 0