カテゴリー : 2013年 1月

[Sublime Text 2] Ctrl+Tabでのタブ切替えコマンドをカスタマイズ

Sublime Text 2 で、Ctrl+Tabでのタブ切替えコマンドをカスタマイズしました。

デフォルトでは「最後に使用した文書に切り替える」挙動なので、これを「右のタブに移動する」「左のタブに移動する」挙動に変更します。

「Preferences」から「Key bindings – User」を選択して、下記の記述を追記するだけでOKです。

[
  { "keys": ["ctrl+tab"], "command": "next_view" },
  { "keys": ["ctrl+shift+tab"], "command": "prev_view" },
  { "keys": ["ctrl+pagedown"], "command": "next_view_in_stack" },
  { "keys": ["ctrl+pageup"], "command": "prev_view_in_stack" }
]

Sublime Text2でCtrl+Tabによるタブの切替をタブの順序どおりにする はてなブックマーク - Sublime Text2でCtrl+Tabによるタブの切替をタブの順序どおりにする

[JavaScript][jQuery] 要素 DOM の存在確認・チェック

JavaScriptで、要素 DOM の存在確認をする方法がたくさんあるので迷うけど、結論としては、

document.getElementById("id") != null

でチェックのが速くて良いみたい。

コード 速度
document.getElementById("id") != null 0.019ms
$("selector")[0] 0.033ms
$("selector").get(0) 0.040ms
$("selector").size() 0.041ms
$("selector").length 0.069ms
$("selector").is("*") 0.169ms

・引用元:[JS][jQuery] 要素の存在を確認する6通りのコードと実行速度 | きほんのき はてなブックマーク - [JS][jQuery] 要素の存在を確認する6通りのコードと実行速度 | きほんのき

jQueryによる要素の存在チェックまとめ: 小粋空間 はてなブックマーク - jQueryによる要素の存在チェックまとめ: 小粋空間

[Facebook] Handling Revoked Permissions – 失効権限の取り扱い

Handling Revoked Permissions – Facebook Developers はてなブックマーク - Handling Revoked Permissions - Facebook Developers

Handling Revoked Permissions
失効権限の取り扱い

The Permissions that are requested from a User by an App may not be fully granted, or may not remain constant – a user can choose to not grant some Permissions and can revoke these Permissions afterwards through their Facebook account settings. In order to provide a positive user experience, Apps should be built to handle these situations.
アプリケーションによるユーザーから要求された権限は完全に付与されていないか、一定のままでないかもしれません – ユーザはいくつかの権限を付与しないように選択することができ、自分のFacebookのアカウント設定を介して、その後、これらの権限を取り消すことができます。肯定的なユーザーエクスペリエンスを提供するために、アプリはこれらの状況を処理するために構築されるべきである。

[Ruby on Rails] ページごとにtitleを変更する方法

Ruby on Rails でページごとにtitleを変更する方法をメモ。

■ ERB

<title><%= content_for?(:title) ? yield(:title) : "default title"%></title>

■ Haml

%title><
  - if content_for? :title
    = yield :title
    |デフォルトタイトル
  - else
    デフォルトタイトル

metaタグのdescriptionやkeywordsも同じように書けます。

■ app/views/layouts/application.html.haml

- if content_for? :meta_description
  - meta_description = yield :meta_description
- else
  - meta_description = 'default description'
%meta(content="#{meta_description}" name="description")
- if content_for? :meta_keywords
  - meta_keywords = yield :meta_keywords
- else
  - meta_keywords = 'default keywords'
%meta(content="#{meta_keywords}" name="keywords")

■ どこかの view

= content_for :meta_description do
  #{@item.description}
= content_for :meta_keywords do
  #{@item.name}
= content_for :title do
  #{@item.name}

[MongoDB] find().forEach(printjson) または .toArray() で全件表示する

MongoDB のシェルで db.collection.find() だとデータの件数が多いと has more と表示されて、全件表示されません。

MongoDB | モンゴディービー

続きを読む