はてなダイアリー使いづらい→づらくない

ブログにRetweet 機能が無い事に気づいたので実装しようと思ったのだが駄目だった。

Retweetボタンの実装自体は簡単で、

<a href="http://twitter.com?status=書き込みたいコメントUTF8をBASE64エンコードした文字列">Retweet</a>

を記事に埋め込むだけで良いのだが、

実装しようとした所

各記事のフッダーHTMLを編集して<a> を書き込む

はてなダイアリーでは各記事のスタイルを編集することはできず、HTMLを直接編集できるのはヘッダーとフッダーのみ

じゃあJQueryとかを使って、クライアントサイドで記事のフッダーに動的に<a> を追加する

Javascriptは使えない

うぜー

毎回手作業で、Retweetボタンをタグ直打ちで書き込むと言う方法もあるが、同じコードは二度書かないというプログラミングの原則から外れているので却下。
というわけで方法は

せっかく調べたのでRetweetリンクでも貼っておく
この記事をRetweet

2011/2/27
追伸
いつの間にか対応してくれたみたい。
ヨカッタヨカッタ

ニコニコ動画に自動ログインする Greasemonkey スクリプト

ニコニコ動画の動画がWebサイト等で紹介されているときに、ログイン画面がいちいち出てきてうざいので、自動でログインするGreasemonkeyスクリプトを探していたら、
marvelous.zip さんのブログでちょうどそれっぽいのを発見した。
http://blog.livedoor.jp/marvelous_zip/archives/1159269.html

marvelous.zip さんのスクリプトだと、一回だけクリックしないといけないのでそこを改造して以下のスクリプトを作った

// ==UserScript==
// @name           niconico autologin
// @namespace      niconico_autologin
// @description    ニコニコ動画に自動でログインします。
// @include        http://www.nicovideo.jp/watch/*
// @include        https://secure.nicovideo.jp/secure/login_form*
// ==/UserScript==
var email = "メールアドレス";
var pass = "パスワード";
if(document.getElementById("login") && ! document.getElementById("login").innerHTML.match("ログイン情報が間違っています")){
  document.getElementById("mail").value = email;
  document.getElementById("password").value = pass;
  document.getElementById("login").submit();
}
else{
  if(document.URL.match(/^https\:\/\/secure\.nicovideo\.jp\/secure\/login_form\?/)){
    document.getElementByID("mail").value = email;
    document.getElementByID("password").value = pass;
    document.getElementByID("login_submit").submit();
  }
  else{
    var as = document.getElementsByTagName("a");
    for(i=0;i<as.length;i++){
      if(as[i].href.match(/^https\:\/\/secure\.nicovideo\.jp\/secure\/login_form\?/)){
        location.href = as[i].href;
        break;
      }
    }
  }
}

便利!!

下に直接DLできるようにしておく(リンクが死んでたので直しました)
https://github.com/katsusuke/niconico-autologin/raw/master/niconico-autologin.user.js

Ruby1.9をMac Portsで入れる

Rails3 もリリースされた事なので Ruby1.9xをMac Portでインストールしてみる。
前回何らかの理由でRuby 1.9Mac Portで入れるのは断念したのだが、理由が何故だったか忘れたので再び入れることにする(gem周りだった気がするが、忘れた)

$ sudo port selfupdate
$ sudo port upgrade installed
$ sudo port install ruby19
--->  Computing dependencies for ruby19
--->  Dependencies to be installed: libyaml
--->  Fetching libyaml
--->  Attempting to fetch yaml-0.1.3.tar.gz from http://distfiles.macports.org/libyaml
--->  Verifying checksum(s) for libyaml
--->  Extracting libyaml
--->  Configuring libyaml
--->  Building libyaml
--->  Staging libyaml into destroot
--->  Installing libyaml @0.1.3_0
--->  Activating libyaml @0.1.3_0
--->  Cleaning libyaml
--->  Fetching ruby19
--->  Attempting to fetch ruby-1.9.2-p0.tar.bz2 from ftp://ftp.iij.ad.jp/pub/lang/ruby/1.9
--->  Verifying checksum(s) for ruby19
--->  Extracting ruby19
--->  Applying patches to ruby19
--->  Configuring ruby19
--->  Building ruby19
--->  Staging ruby19 into destroot
--->  Installing ruby19 @1.9.2-p0_2
--->  Activating ruby19 @1.9.2-p0_2
--->  Cleaning ruby19
$ ruby1.9 -v
ruby 1.9.2p0 (2010-08-18 revision 29036) [x86_64-darwin10]
$ gem1.9 -v
1.3.7

ついでにGemでRailsも入れてみる。
どうなるんだろう・・・・ドキドキ

$ gem1.9 list

*** LOCAL GEMS ***

minitest (1.6.0)
rake (0.8.7)
rdoc (2.5.8)

ちなみにgem1.9 のリストは gem のリストと違った結果を返しているので、インストール先は別と思われる。

$ sudo gem1.9 install rails
Password:
Successfully installed activesupport-3.0.0
Successfully installed builder-2.1.2
Successfully installed i18n-0.4.1
Successfully installed activemodel-3.0.0
Successfully installed rack-1.2.1
Successfully installed rack-test-0.5.4
Successfully installed rack-mount-0.6.13
Successfully installed tzinfo-0.3.23
Successfully installed abstract-1.0.0
Successfully installed erubis-2.6.6
Successfully installed actionpack-3.0.0
Successfully installed arel-1.0.1
Successfully installed activerecord-3.0.0
Successfully installed activeresource-3.0.0
Successfully installed mime-types-1.16
Successfully installed polyglot-0.3.1
Successfully installed treetop-1.4.8
Successfully installed mail-2.2.5
Successfully installed actionmailer-3.0.0
Successfully installed thor-0.14.0
Successfully installed railties-3.0.0
Successfully installed bundler-1.0.0
Successfully installed rails-3.0.0
23 gems installed
Installing ri documentation for activesupport-3.0.0...
Installing ri documentation for builder-2.1.2...
Installing ri documentation for i18n-0.4.1...
Installing ri documentation for activemodel-3.0.0...
Installing ri documentation for rack-1.2.1...
Installing ri documentation for rack-test-0.5.4...
Installing ri documentation for rack-mount-0.6.13...
Installing ri documentation for tzinfo-0.3.23...
Installing ri documentation for abstract-1.0.0...
Installing ri documentation for erubis-2.6.6...
Installing ri documentation for actionpack-3.0.0...
Installing ri documentation for arel-1.0.1...
Installing ri documentation for activerecord-3.0.0...
Installing ri documentation for activeresource-3.0.0...
Installing ri documentation for mime-types-1.16...
Installing ri documentation for polyglot-0.3.1...
Installing ri documentation for treetop-1.4.8...
Installing ri documentation for mail-2.2.5...
Installing ri documentation for actionmailer-3.0.0...
Installing ri documentation for thor-0.14.0...
Installing ri documentation for railties-3.0.0...
Installing ri documentation for bundler-1.0.0...
Installing ri documentation for rails-3.0.0...
Installing RDoc documentation for activesupport-3.0.0...
Installing RDoc documentation for builder-2.1.2...
Installing RDoc documentation for i18n-0.4.1...
Installing RDoc documentation for activemodel-3.0.0...
Installing RDoc documentation for rack-1.2.1...
Installing RDoc documentation for rack-test-0.5.4...
Installing RDoc documentation for rack-mount-0.6.13...
Installing RDoc documentation for tzinfo-0.3.23...
Installing RDoc documentation for abstract-1.0.0...
Installing RDoc documentation for erubis-2.6.6...
Installing RDoc documentation for actionpack-3.0.0...
Installing RDoc documentation for arel-1.0.1...
Installing RDoc documentation for activerecord-3.0.0...
Installing RDoc documentation for activeresource-3.0.0...
Installing RDoc documentation for mime-types-1.16...
Installing RDoc documentation for polyglot-0.3.1...
Installing RDoc documentation for treetop-1.4.8...
Installing RDoc documentation for mail-2.2.5...
Installing RDoc documentation for actionmailer-3.0.0...
Installing RDoc documentation for thor-0.14.0...
Installing RDoc documentation for railties-3.0.0...
Installing RDoc documentation for bundler-1.0.0...
Installing RDoc documentation for rails-3.0.0...

$ which -a rails
/opt/local/bin/rails
$ rails -v
Rails 3.0.0

ありゃ??Ruby1.8.7 のgem でインストールしたrails はどこいった??
これは困った

$ find /opt/local/ -name rails
/opt/local/bin/rails
/opt/local/lib/ruby/gems/1.8/gems/rails-2.3.8/bin/rails
/opt/local/lib/ruby/gems/1.8/gems/rails-2.3.8/builtin/rails_info/rails
/opt/local/lib/ruby/gems/1.8/gems/rails-2.3.8/lib/rails
/opt/local/lib/ruby1.9/gems/1.9.1/doc/actionmailer-3.0.0/rdoc/lib/rails
/opt/local/lib/ruby1.9/gems/1.9.1/doc/activerecord-3.0.0/rdoc/lib/rails
/opt/local/lib/ruby1.9/gems/1.9.1/gems/actionmailer-3.0.0/lib/rails
/opt/local/lib/ruby1.9/gems/1.9.1/gems/activerecord-3.0.0/lib/rails
/opt/local/lib/ruby1.9/gems/1.9.1/gems/rails-3.0.0/bin/rails
/opt/local/lib/ruby1.9/gems/1.9.1/gems/railties-3.0.0/lib/rails
/opt/local/lib/ruby1.9/gems/1.9.1/gems/railties-3.0.0/lib/rails/generators/rails
/opt/local/lib/ruby1.9/gems/1.9.1/gems/railties-3.0.0/lib/rails/generators/rails/app/templates/script/rails

gem は見つけたが...
どうしよう...

とりあえずgem1.9 のgems を全てアンインストールして、Mac Port のruby19 もuninstall
その後 rails3 だけをruby1.8.7 環境にインストールした。

なんじゃそりゃ

教訓:前回駄目だったことは理由に関わらず今回もダメ

追記
RVM(Ruby Version Manager)をインストールすれば行けそう。
再トライ予定

はてなに登録したらブログを作らされた。

ついでなのでブログを書いていこうかと思う。

以下はてな記法のテスト

  • リスト
  • リスト2
  1. 番号付きリスト
  2. 番号付きリスト
テーブルってこうか? 2列目
1-2 2-2