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 / park4night.rb
Created August 1, 2020 16:16
park4night
require 'json'
require 'open-uri'
require 'nokogiri'
GPX = <<-GPX
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<gpx
xmlns="http://www.topografix.com/GPX/1/1"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd"
@dmitry
dmitry / park4night.rb
Last active February 9, 2024 12:59
park4night
require 'json'
require 'open-uri'
require 'nokogiri'
GPX = <<-GPX
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<gpx
xmlns="http://www.topografix.com/GPX/1/1"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd"
@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 / cleanup_vcr_cassettes.rb
Created October 15, 2014 23:25
Cleanup VCR Cassettes
require 'set'
USED_CASSETTES = Set.new
module CassetteReporter
def insert_cassette(name, options = {})
USED_CASSETTES << VCR::Cassette.new(name, options).file
super
end
end
VCR.extend(CassetteReporter)
for f in ./*.JPG ; do recoverjpeg -m 100m -o ./fixed/ -f ${f%.JPG}.JPG ${f%.JPG}.JPG ; done
@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 / _search.html.haml
Created December 8, 2012 15:45
Custom filters/search in sidebar for active_admin using a partial
= form_for @search, url: collection_path,
as: :q,
builder: ActiveAdmin::Filters::CustomFormBuilder,
html: {method: :get, class: :filter_form} do |f|
= f.input :code_contains, as: :string
= f.input :code_contains, as: :filter_string
= f.form_buffers.last
@dmitry
dmitry / download.js
Last active January 28, 2021 14:57
Download files in cypress <6.0
const path = require('path')
const { promisify } = require('util')
const CDP = require('chrome-remote-interface')
const debug = require('debug')('cypress:server:protocol')
const rimraf = promisify(require('rimraf'))
let port = 0
let client = null
module.exports = (on, config) => {
@dmitry
dmitry / union_scope_concern.rb
Created January 12, 2021 18:20
Union scope ActiveRecord concern (allow to use multiple scopes with or)
module UnionScopeConcern
extend ActiveSupport::Concern
class_methods do
def union_scope(*scopes)
scopes[1..-1].inject(where(id: scopes.first)) { |all, scope| all.or(where(id: scope)) }
end
end
end