2011年11月20日日曜日

jQueryを使用したJavaScriptコーディングスタイル

(function($) {
var elements,
bind = {
buttonClick: function() {
elements.$button.click(e) { e.preventDefault();
action.sayHello('World');
}
}
},
action = {
sayHello: function(to) {
console.log('Hello ' + to + ' !')
}
};
$(function() {
elements = {
$button: $('a.button')
};
bind.buttonClick();
});
})(jQuery);
view raw gistfile1.js hosted with ❤ by GitHub


こんな感じに落ち着いてる。
CoffeeScript覚えるのめんどくさい。
2011年11月10日木曜日

Rails3.1.0 の request オブジェクトのメソッド一覧

[
:ignore_accept_header,
:ignore_accept_header=,
:auth_type,
:gateway_interface,
:path_translated,
:remote_host,
:remote_ident,
:remote_user,
:remote_addr,
:server_name,
:server_protocol,
:accept,
:accept_charset,
:accept_encoding,
:accept_language,
:cache_control,
:from,
:negotiate,
:pragma,
:key?,
:request_method,
:request_method_symbol,
:method,
:method_symbol,
:get?,
:post?,
:put?,
:delete?,
:head?,
:headers,
:fullpath,
:forgery_whitelisted?,
:forgery_whitelisted_with_deprecation?,
:forgery_whitelisted_without_deprecation?,
:media_type,
:content_length,
:xml_http_request?,
:xhr?,
:ip,
:remote_ip,
:server_software,
:raw_post,
:body,
:form_data?,
:body_stream,
:reset_session,
:session=,
:session_options=,
:GET,
:query_parameters,
:POST,
:request_parameters,
:authorization,
:local?,
:cookie_jar,
:flash,
:tld_length,
:tld_length=,
:url,
:protocol,
:raw_host_with_port,
:host,
:host_with_port,
:port,
:standard_port,
:standard_port?,
:optional_port,
:port_string,
:server_port,
:domain,
:subdomains,
:subdomain,
:filtered_parameters,
:filtered_env,
:filtered_path,
:parameter_filter,
:env_filter,
:parameter_filter_for,
:filtered_query_string,
:parameters,
:params,
:path_parameters=,
:symbolized_path_parameters,
:path_parameters,
:content_mime_type,
:content_type,
:accepts,
:format,
:formats,
:format=,
:negotiate_mime,
:valid_accept_header,
:use_accept_header,
:if_modified_since,
:if_none_match,
:not_modified?,
:etag_matches?,
:fresh?,
:env,
:script_name,
:path_info,
:query_string,
:session,
:session_options,
:logger,
:media_type_params,
:content_charset,
:scheme,
:ssl?,
:script_name=,
:path_info=,
:options?,
:patch?,
:trace?,
:parseable_data?,
:[],
:[]=,
:values_at,
:referer,
:referrer,
:user_agent,
:cookies,
:base_url,
:path,
:parse_query,
:parse_multipart,
:psych_to_yaml,
:to_yaml_properties,
:to_yaml,
:in?,
:blank?,
:present?,
:presence,
:acts_like?,
:try,
:html_safe?,
:duplicable?,
:to_json,
:instance_values,
:instance_variable_names,
:as_json,
:with_options,
:to_param,
:to_query,
:`,
:returning,
:dclone,
:require_or_load,
:require_dependency,
:require_association,
:load_dependency,
:load,
:require,
:unloadable,
:nil?,
:===,
:=~,
:!~,
:eql?,
:hash,
:<=>,
:class,
:singleton_class,
:clone,
:dup,
:initialize_dup,
:initialize_clone,
:taint,
:tainted?,
:untaint,
:untrust,
:untrusted?,
:trust,
:freeze,
:frozen?,
:to_s,
:inspect,
:methods,
:singleton_methods,
:protected_methods,
:private_methods,
:public_methods,
:instance_variables,
:instance_variable_get,
:instance_variable_set,
:instance_variable_defined?,
:instance_of?,
:kind_of?,
:is_a?,
:tap,
:send,
:public_send,
:respond_to?,
:respond_to_missing?,
:extend,
:display,
:public_method,
:define_singleton_method,
:__id__,
:object_id,
:to_enum,
:enum_for,
:gem,
:psych_y,
:y,
:silence_warnings,
:enable_warnings,
:with_warnings,
:silence_stderr,
:silence_stream,
:suppress,
:capture,
:silence,
:quietly,
:class_eval,
:require_library_or_gem,
:require_library_or_gem_with_deprecation,
:require_library_or_gem_without_deprecation,
:debugger,
:breakpoint,
:suppress_warnings,
:__called_from__,
:expirable_memoize,
:==,
:equal?,
:!,
:!=,
:instance_eval,
:instance_exec,
:__send__
]
view raw gistfile1.rb hosted with ❤ by GitHub