| var logger=org.elasticsearch.common.logging.ESLoggerFactory.getLogger('myscript'); | |
| logger.info(this); |
| Mail.defaults do | |
| delivery_method ActionMailer::Base.delivery_method, ActionMailer::Base.smtp_settings | |
| end | |
| mail = Mail.deliver do | |
| to '[email protected]' | |
| from 'Mikel Lindsaar <[email protected]>' | |
| subject 'First multipart email sent with Mail' | |
| text_part do |
| # ruby script/trackable_links.rb script/a.txt "?a=2&c=3" | |
| require 'addressable/uri' | |
| require 'nokogiri' | |
| class TrackableLinks | |
| ALLOWED_SCHEMAS = %w(http https) | |
| class << self | |
| def add(body, options) |
All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout. This is also called reflow or layout thrashing, and is common performance bottleneck.
elem.offsetLeft,elem.offsetTop,elem.offsetWidth,elem.offsetHeight,elem.offsetParentelem.clientLeft,elem.clientTop,elem.clientWidth,elem.clientHeightelem.getClientRects(),elem.getBoundingClientRect()
| import { Component } from "React"; | |
| export var Enhance = ComposedComponent => class extends Component { | |
| constructor() { | |
| this.state = { data: null }; | |
| } | |
| componentDidMount() { | |
| this.setState({ data: 'Hello' }); | |
| } | |
| render() { |
React now supports the use of ES6 classes as an alternative to React.createClass().
React's concept of Mixins, however, doesn't have a corollary when using ES6 classes. This left the community without an established pattern for code that both handles cross-cutting concerns and requires access to Component Life Cycle Methods.
In this gist, @sebmarkbage proposed an alternative pattern to React mixins: decorate components with a wrapping "higher order" component that handles whatever lifecycle methods it needs to and then invokes the wrapped component in its render() method, passing through props.
While a viable solution, this has a few drawbacks:
- There's no way for the child component to override functionality defined on the higher order component.
http://aurelien-herve.com/blog/2014/10/14/advanced-api-option-parser-for-grape/ - see comments for more implementations http://www.nicolasgarnil.me/blog/2013/crafting-ruby-grape-apis-partial-response-part1/ http://www.adamgotterer.com/post/27008214082/exposing-entities-in-grape-by-default http://googlecode.blogspot.com.ar/2010/03/making-apis-faster-introducing-partial.html