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 / convert_utf8_to_utf8mb4
Last active Jan 22, 2018 — forked from dschneider/convert_utf8_to_utf8mb4
How to easily convert utf8 tables to utf8mb4 in MySQL 5.5
View convert_utf8_to_utf8mb4
# For each database:
ALTER DATABASE century21_development CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci;
# For each table:
# 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 /
Created Sep 23, 2015 — forked from paulirish/
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.


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 / 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() {

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.
View ComPort Architecture draft.rb
Architecture description
Orchestrates the overall process from fetching to updating the db,
scheduling and managing aggregator jobs and their stages for different modules
fetch :all | latest - accepts a block with strategy to determine latest
jobs :all | :current - AggreagationJob - status, stop, pause, resume
dmitry / rem
Created Apr 21, 2014 — forked from xonic/rem
View 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: "";
View char_converter.rb
# config/initializers/char_converter.rb
require 'uri'
module Support
class CharConverter
def initialize(app)
@app = app
View rails_rce.rb
#!/usr/bin/env ruby
# Proof-of-Concept exploit for Rails Remote Code Execution (CVE-2013-0156)
# ## Advisory
# ## Caveats
View routes.rake
namespace :routes do
desc "Writes doc/routes.html. Requires Graphviz (dot)"
task :visualizer => :environment do'doc', 'routes.html'), 'wb') do |f|
f.write Rails.application.routes.router.visualizer
dmitry / nginx-site.conf
Last active Dec 9, 2015 — forked from anonymous/nginx-site.conf
Shows how to generate sitemap with sitemap_generator gem for multilingual site and set rewrite urls in nginx conf.
View nginx-site.conf
rewrite ^/sitemap1.xml.gz /sitemaps/$host/sitemap1.xml.gz last;
rewrite ^/sitemap_index.xml.gz /sitemaps/$host/sitemap_index.xml.gz last;
# or
location /sitemap {
# it can be already switched on for globally
# gzip_static on;
rewrite ^/sitemap.xml /sitemaps/$host/sitemap.xml last; # that's will catch .gz files and served as normal static file, but with gzip header
You can’t perform that action at this time.