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 / nginx-site.conf
Last active March 8, 2023 15:53 — 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.
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
@dmitry
dmitry / sanitize.js
Created October 28, 2011 21:05 — forked from timjb/sanitize.js
HTML Sanitizer for JavaScript
// I'm developing this now as a part of substance (https://github.com/michael/substance)
@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 / backbone-mixin.js
Created October 1, 2011 21:49 — forked from wesen/backbone-mixin.js
Merge backbone views (mixin pattern)
/**
* ## Merging mixin views in backbone.js ##
*
* really just more a test for tumblr gistr
*/
/**
* Merge the mixin (a Backbone.View) into another Backbone.View. Automatically merge events, defaults, and call the parent initializer.
**/
function mergeMixin(view, mixin) {
@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'
# 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
@dmitry
dmitry / gist:1394872
Created November 26, 2011 02:50 — forked from avalanche123/gist:981817
GitHub Emoji
:+1:
:-1:
:airplane:
:art:
:bear:
:beer:
:bike:
:bomb:
:book:
:bulb:
@dmitry
dmitry / gist:1296732
Created October 18, 2011 21:09
Creating a Backbone.js View Manager
/**
Big thanks to Derick Bailey for his post here:
http://lostechies.com/derickbailey/2011/09/15/zombies-run-managing-page-transitions-in-backbone-apps/
*/
(function(Account) {
/** LOTS OF MODEL, COLLECTION, AND VIEW CREATION GOING ON UP HERE, LEFT IT OUT FOR SIMPLICITY */
/**
* Define Routing.