pxkw.hatenadiary.com

めもめも

Bookmarklet to fill forms matched to a regex

We can not use a regex in getElementsByXXX("/^like this*/").
So we have to get superset of what we need and then evaluate each element whether its name (or tagname or something) matches to the regex.

Example

  <form>
    <input type="text" name="target0" value="target0" />
    <input type="text" name="target1" value="target1" />
    <input type="text" name="dummy0"  value="dummy0"  />
    <input type="text" name="target2" value="target2" />
    <input type="text" name="target3" value="target3" />
    <input type="text" name="dummy1"  value="dummy1"  />
  </form>
  
  <button id="changebtn">change</button>

  <script>
    document.getElementById("changebtn").onclick = function(){
        var es = document.getElementsByTagName("input");
          for( var i=0; i<es.length; i++ ){
              var e = es[i];
              if( e.name.match(/^target.*/) ) {
                  e.value = "changed!";

                  /*somehow necessary for scriptlet on my environment*/
                  console.log(); 
              }
          }
    }
  </script>












How to register the script as a bookmarklet

  1. Show bookmark-toolbar (Ctrl-Shift-b)
  2. Rclick -> Add page...
    • URL : javascript:{ [PASTE THE SCRIPT IN A LINE] }

ssh公開鍵認証*初期*設定

ナンベンやっても忘れるからメモ

@クライアント

[1/2] 鍵作成
$ ssh-kengen -t rsa

パスワードを入力。
オプションは明示的にRSA認証方式を指定するもの。

[2/2] SSH認証エージェントに鍵を登録

これを忘れがち!

$ ssh-add ~/.ssh/id_rsa

@サーバ

[1/3] ~/.ssh/authorized_keysに公開鍵を追加

クライアントの公開鍵(~/.ssh/id_rsa.pub)をサーバの~/.ssh/authorized_keysに追記。
ディレクトリ/ファイルがなければ作成する。

[2/3] ~/.ssh/の権限を700に設定
% chmod 700 ~/.ssh

権限が drwx------ になっていることを確認する。

[3/3] ~/.ssh/authorized_keysの権限を600に変更
% chmod 600 ~/.ssh/authorized_keys

権限が -r-------- になっていることを確認する。

UbuntuでBluetoothオーディオレシーバのペアリングが成功するのにsound設定で認識されない事案の対処

環境

Ubuntuは13.10(64)。
オーディオレシーバはこいつ。

GREEN HOUSE Bluetoothオーディオレシーバー クリップ付 ブラック GH-BHARCK

GREEN HOUSE Bluetoothオーディオレシーバー クリップ付 ブラック GH-BHARCK

対処

bluetooth - How can I get the A2DP output option and the input working again? - Ask Ubuntu によると、

Loading the bluetooth discovery module manually fixes the problem

らしい。ペアリングしたら自動でやってくんないのか...

pactl load-module module-bluetooth-discover

※要管理者権限

module-bluetooth-discoverをリ(?)ロードすると認識される。
f:id:pixikawa:20140313140818p:plain

pactlとは

PulseAudioサーバのコントローラらしい。

manいわく

load-module NAME [ARGUMENTS ...]
Load the specified module with the specified arguments into the running sound server. Prints the numeric index of the module just loaded to STDOUT. You can use it to unload the module later.

最後に

人間界からすべてのケーブルが消えますように。

トグる2

クリックでtdの表示をトグる

<div id="slide-toggle-sample1">
  <table>
    <tr >
      <td>
        <div id="trigger">Click me to show msg</div>
        <div id="message" style="display:none" >Can you see me?</div>
      </td>
    </tr>
  </table>

  <script src="http://code.jquery.com/jquery-2.1.0.min.js"></script>
  <script>
    $(function(){
      $("#trigger").click( function() {
        $("#trigger").hide(100);
        $("#message").show(200);
      });
    });
    $(function(){
      $("#message").click( function() {
        $("#message").hide(100);
        $("#trigger").show(200);
      });
    });
  </script>
</div>



Click me to show msg



うにょってなる。

How to remap CapsLock to Ctrl or swap them.

(Tried and successful on Ubuntu 13.10)

[1/2] Edit option in a configuration file.

Edit XKBOPTIONS in the file /etc/default/keyboard.
SU permission will be required.


To remap CAPS to CTRL, add the following option.

ctrl:nocaps

e.g. XKBOPTIONS="ctrl:nocaps"


To swap CAPS and CTRL, add the following.

ctrl:swapcaps

e.g. XKBOPTIONS="ctrl:swapcaps"

[2/2] Apply the configuration.

Run this command with SU permission

dpkg-reconfigure keyboard-configuration

and follow the guidance.

Ubuntu 13.10にAnthy日本語入力を導入する

if( 英語版OS && 日本語入力がしたい )
 参考文献どおりでOK。

  • Anthy設定 : Anthyを選択しつつ画面中央左下くらいのボタンをポチる。

f:id:pixikawa:20140220103215p:plain

  • 全角スペース→半角スペース化しても、Shift-Space(insert_alternate_space)で全角スペースを入れれて便利。

f:id:pixikawa:20140220103456p:plain

  • その他キーバインドを変更した方がいいかも。circle_inputって何だ。

f:id:pixikawa:20140220103731p:plain