2013-11-22

ブログへソース等を張り付ける為に変換するやつ

要するに下のような感じに整形するものw

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title>タグ変換</title>

<script src="http://www.google.com/jsapi"></script>
<script>google.load("jquery", "1.7.0");</script>
    
<script>
 function onButtonClick()
 {
        ORGobj=document.getElementById('uSource');
        
        if (ORGobj.value != "") {
            
            obj=document.getElementById('uTags');
            
            t=new String();
            
            t=ORGobj.value;
            t=t.replace(/\</g, '<');
            t=t.replace(/\>/g, '>');
            t=t.replace(/\n/g, '<br/>');
            t="<!-- コード -->\n"
                +"<div style=\"background: #e0e0e0; margin:5px 0 5px 10px; padding:0px 0px 0px 20px;\">"
                +"\n<pre><code>\n"
                +t+"\n"
                +"</code></pre>\n</div>\n<!-- EOF コード -->\n";
            obj.value=t;
    
        } else {
            window.alert('変換元のコードを左のボックスへ入力して下さい');
        }
        

 }
 function onHenkanBtnClick()
 {
  onButtonClick();
  t=new String();
  t=document.getElementById('uTags').value;

  document.open();
  document.write(t);
  document.close();

 }
    function onCopyBtnClick()
    {

        var obj=document.getElementById('uTags');
        obj.select();        
        if (document.execCommand("copy") == false) {
            window.alert("このブラウザではコピー出来ませんCtrl+Cキーでコピーして下さい");
        }
    }
</script>
</head>
<body>
<form>
    <textarea id="uSource" rows="25" cols="40"></textarea>
    <input type="button" value="変換" onclick="onButtonClick()"/>
    <textarea id="uTags"  rows="25" cols="40"></textarea>
    <input type="button" value="CopyToClipboard" onclick="onCopyBtnClick()"/>
    <input type="hidden" value="変換プレビュー" onclick="onHenkanBtnClick()"/>
</form>
    
</body>
</html>

2013-11-21

ubuntu nginx設定

インストール

# aptitude install nginx ホームディレクトリの設定はapache等と同じ感じで
/etc/nginx/sites-available/ 以下に設定を記述又は変更して
/etc/nginx/sites-enabled/ 以下に シンボリックリンク(ln -s)を作成する


PHPを動かす

aptitude install php5-fpm nginxの設定(例えば/etc/nginx/sites-enabled/default)にて

        location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include /etc/nginx/fastcgi_params;
fastcgi_param SCRIPT_FILENAME
$document_root$fastcgi_script_name;
}
を追加

2013-11-11

wgetで保存しとく

役立ちそうなページはwgetとサクっとダウンロードして保存


wget -r -k http://www.hogehoge/



mac bootcampでWin8フリーズ等

管理者権限でcmdを起動して



bcdedit /set disabledynamictick yes




で止めるらしい

2013-11-09

ログからホワイトリスト用のメールアドレス抽出

サーバのコマンドでログから2回以上送信したアドレスを抽出してみる



zcat -f /var/log/mail.info*|grep "to"|grep "queued"|grep -v "<|@"|grep -vE "(自ドメイン|複数あれば|複数あれば)"|awk '{ if(match($0, /<|>/)) print substr($7, 2, length($7)-6); }'|sort|uniq -c|awk '{ if($1 > 3) print $2}'