Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View dmitry's full-sized avatar
🇪🇪
Water, earth and air.

Dmitry Polushkin dmitry

🇪🇪
Water, earth and air.
View GitHub Profile
@dmitry
dmitry / README.md
Created September 28, 2020 07:21 — forked from joyrexus/README.md
collapsible markdown

collapsible markdown?

CLICK ME

yes, even hidden code blocks!

print("hello world!")
@dmitry
dmitry / convert_utf8_to_utf8mb4
Last active January 22, 2018 08:06 — forked from dschneider/convert_utf8_to_utf8mb4
How to easily convert utf8 tables to utf8mb4 in MySQL 5.5
# For each database:
ALTER DATABASE century21_development CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci;
# For each table:
SELECT CONCAT('ALTER TABLE `', TABLE_NAME,'` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;') AS mySQL FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA= "century21_development"
# For each column:
select CONCAT('ALTER TABLE `', TABLE_SCHEMA, '.', TABLE_NAME,'` CHANGE ',COLUMN_NAME,' ', COLUMN_NAME, ' ', DATA_TYPE,'(',CHARACTER_MAXIMUM_LENGTH,') CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;') as column_alter from INFORMATION_SCHEMA.COLUMNS WHERE DATA_TYPE IN('varchar', 'text') AND TABLE_SCHEMA = 'century21_development'
@dmitry
dmitry / what-forces-layout.md
Created September 23, 2015 15:28 — forked from paulirish/what-forces-layout.md
What forces layout/reflow. The comprehensive list.

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 September 17, 2015 12:04 — forked from sebmarkbage/Enhance.js
Higher-order Components
import { Component } from "React";
export var Enhance = ComposedComponent => class extends Component {
constructor() {
this.state = { data: null };
}
componentDidMount() {
this.setState({ data: 'Hello' });
}
render() {
@dmitry
dmitry / alternative-to-higher-order-components.md
Last active September 17, 2015 12:04 — forked from aldendaniels/alternative-to-higher-order-components.md
Alternative to Higher-order Components

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.
Architecture description
-
Aggregator
Orchestrates the overall process from fetching to updating the db,
scheduling and managing aggregator jobs and their stages for different modules
does:
fetch :all | latest - accepts a block with strategy to determine latest
jobs :all | :current - AggreagationJob - status, stop, pause, resume
@dmitry
dmitry / rem
Created April 21, 2014 16:33 — forked from xonic/rem
// Mixin that allows to specify arbitrary CSS properties with
// unitless numbers. The output has rem unit with pixel fallback.
// Shorthand assignments are supported too!
$base_line: 10;
@mixin rem($property, $values, $important:"")
{
// Placeholder variables
$shorthand_px: "";
$shorthand_rem: "";
# config/initializers/char_converter.rb
require 'uri'
module Support
class CharConverter
def initialize(app)
@app = app
end
#!/usr/bin/env ruby
#
# Proof-of-Concept exploit for Rails Remote Code Execution (CVE-2013-0156)
#
# ## Advisory
#
# https://groups.google.com/forum/#!topic/rubyonrails-security/61bkgvnSGTQ/discussion
#
# ## Caveats
#
namespace :routes do
desc "Writes doc/routes.html. Requires Graphviz (dot)"
task :visualizer => :environment do
File.open(Rails.root.join('doc', 'routes.html'), 'wb') do |f|
f.write Rails.application.routes.router.visualizer
end
end
end