Skip to content

Instantly share code, notes, and snippets.

Avatar
🇪🇪
Water, earth and air.

Dmitry Polushkin dmitry

🇪🇪
Water, earth and air.
View GitHub Profile
@dmitry
dmitry / download.js
Last active Jan 28, 2021
Download files in cypress <6.0
View download.js
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 Jan 12, 2021
Union scope ActiveRecord concern (allow to use multiple scopes with or)
View union_scope_concern.rb
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
View application_policy.rb
class ApplicationPolicy < ActionPolicy::Base
scope_matcher :action_controller_params, Types::Base::InputObject
class ParamsFilter < ActionController::Parameters
include ActionPolicy::Behaviour
include ActionPolicy::Behaviours::ThreadMemoized
include ActionPolicy::Behaviours::Memoized
include ActionPolicy::Behaviours::Namespaced
attr_accessor :user, :record, :attributes, :parent, :root
@dmitry
dmitry / README.md
Created Sep 28, 2020 — forked from joyrexus/README.md
collapsible markdown
View README.md

collapsible markdown?

CLICK ME

yes, even hidden code blocks!

print("hello world!")
View park4night.rb
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"
View park4night.rb
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"
View a.json
[{"id":4,"folder":"music\/\u041c\u043e\u043a\u0440\u043e\u0443\u0441\u043e\u0432","filename":"\u0410\u0445, \u043a\u0430\u043a \u0445\u043e\u0447\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0441\u043d\u0443\u0442\u044c\u0441\u044f \u0420 \u041c\u043e\u043a\u0440\u043e\u0443\u0441\u043e\u0432 \u0415 \u0417\u044f\u0442\u0435\u0432\u0430.mp3","name":"\u0420\u043e\u043c\u0430\u043d \u041c\u043e\u043a\u0440\u043e\u0443\u0441\u043e\u0432 \u0438 \u0415\u043a\u0430\u0442\u0435\u0440\u0438\u043d\u0430 \u0417\u044f\u0442\u0435\u0432\u0430 - \u0410\u0445, \u043a\u0430\u043a \u0445\u043e\u0447\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0441\u043d\u0443\u0442\u044c\u0441\u044f","artist":"\u0420\u043e\u043c\u0430\u043d \u041c\u043e\u043a\u0440\u043e\u0443\u0441\u043e\u0432 \u0438 \u0415\u043a\u0430\u0442\u0435\u0440\u0438\u043d\u0430 \u0417\u044f\u0442\u0435\u0432\u0430","title":"\u0410\u0445, \u043a\u0430\u043a \u0445\u043e\u0447\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0441\u043d\u0443\u0442\u044c\u0441\u044f","genre
View vue-i18n-async.js
import merge from 'lodash.merge';
export default {
data() {
return {
translationMessageLoaded: false
};
},
created() {
if (!this.$root.i18nComponents) {
View gist:f8c5c2b7c8bfafbcc4ded36c3f1f562e
https://takeout.google.com/
http://nearby.org.uk/convert-saved-places.php
https://kml2gpx.com/?results