[Node.js] node-validator でサニタイズ、バリデート
- 2013 1/20
Node.js でサニタイズやバリデートするには node-validator というパッケージが便利!
Node.js でサニタイズやバリデートするには node-validator というパッケージが便利!
Rubyで、状態遷移を管理できる state_machine が便利!ということで参考サイトをメモ。
・pluginaweek/state_machine · GitHub
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" } ] |
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
・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を変更する方法をメモ。
■ 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} |
ワンクリックでJavaScriptをオフにできるChrome拡張機能「jsoff」が地味に便利!
Ruby とか Rails とかで全文検索エンジンSolrを使うなら「sunspot」ということで色々とメモ。
・sunspotのチュートリアル意訳 – maeshimaの日記
・結局、Rails 3.2 で 大量のデータを検索する場合、Sunspot な Solr が一番 いい感じ。という面白くないオチ。 | JAM☆ぱん
・Will_Paginate with Sunspot – Ruby on Rails | What I Broke
リファレンス
・Module: Sunspot — Documentation for nuatt_sunspot (1.1.0.3)
・RSpec and Sunspot · sunspot/sunspot Wiki
・Install And Test SOLR+Sunspot In Your Rails+RSpec Project | DZone
Linux のメモリ(memory)管理について参考になったサイトをメモ。
・Linux のメモリー管理(メモリ-が足りない?,メモリーリークの検出/防止)(Kodama’s tips page)