Skip to content

Instantly share code, notes, and snippets.

☀️
Catching the sun

Dmitry Polushkin dmitry

☀️
Catching the sun
Block or report user

Report or block dmitry

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@dmitry
dmitry / plain_mail.rb
Created Apr 29, 2016
Use ActionMailer config to send plain through plain Mail
View plain_mail.rb
Mail.defaults do
delivery_method ActionMailer::Base.delivery_method, ActionMailer::Base.smtp_settings
end
mail = Mail.deliver do
to 'dmitry.polushkin@gmail.com'
from 'Mikel Lindsaar <test@9flats.com>'
subject 'First multipart email sent with Mail'
text_part do
@dmitry
dmitry / trackable_links.rb
Last active Dec 2, 2015
Add trackable links
View trackable_links.rb
@dmitry
dmitry / what-forces-layout.md
Created Sep 23, 2015 — forked from paulirish/what-forces-layout.md
What forces layout/reflow. The comprehensive list.
View what-forces-layout.md

What forces layout / reflow

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.

Element

Box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
  • elem.clientLeft, elem.clientTop, elem.clientWidth, elem.clientHeight
  • elem.getClientRects(), elem.getBoundingClientRect()
@dmitry
dmitry / Enhance.js
Last active Sep 17, 2015 — forked from sebmarkbage/Enhance.js
Higher-order Components
View Enhance.js
import { Component } from "React";
export var Enhance = ComposedComponent => class extends Component {
constructor() {
this.state = { data: null };
}
componentDidMount() {
this.setState({ data: 'Hello' });
}
render() {
View alternative-to-higher-order-components.md

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:

  1. There's no way for the child component to override functionality defined on the higher order component.
@dmitry
dmitry / parent_controller_path.rb
Created Aug 13, 2015
Parent controller path through recognize_path
View parent_controller_path.rb
class ParentControllerPath
SEGMENT = '/'
attr_reader :path, :found
class << self
def routes
Rails.application.routes
end
end
You can’t perform that action at this time.