Skip to content

Instantly share code, notes, and snippets.

Vladimir Dementyev palkan

View GitHub Profile
@palkan
palkan / config.yml
Last active Mar 3, 2019
Parcel + GH pages + S3
View config.yml
version: 2.1
workflows:
version: 2
build_and_test:
jobs:
- checkout
- yarn_install:
requires:
- checkout
@palkan
palkan / patch.rb
Created Feb 28, 2019
rspec-rails vs. Rails 6.0.0.beta2
View patch.rb
# frozen_string_literal: true
# PR: https://github.com/rspec/rspec-rails/pull/2095
RSpec::Rails::ViewRendering::EmptyTemplateHandler.singleton_class.prepend(Module.new do
def call(template, _source)
super(template)
end
end)
View slim_faker.rb
# frozen_string_literal: true
# Faker load tons of useless locales by default
# (see https://github.com/stympy/faker/tree/master/lib/locales)
#
# And it's impossible to configure it(
# (see https://github.com/stympy/faker/blob/v1.9.3/lib/faker.rb#L14-L15)
#
# First, ensure i18n is loaded
@palkan
palkan / anycable_0.6.0.md
Last active Nov 21, 2018
AnyCable 0.6.0 releases
View anycable_0.6.0.md
@palkan
palkan / doc.md
Created Aug 17, 2018
[draft] Pundit to Action Policy
View doc.md

From Pundit to ActionPolicy:

  • Remove include Pundit from ApplicationController
  • Add alias authorize authorize!
  • Add authorize :current_user, as: :user
  • Add include ActionPolicy::Policy::Core to ApplicationPolicy
  • Update ApplicationPolicy#initialize:
def initialize(target, user:)
@palkan
palkan / action_policy__i18n.rb
Last active Nov 2, 2018
ActionPolicy i18n basics
View action_policy__i18n.rb
# See issue: https://github.com/palkan/action_policy/issues/15
module ActionPolicy
module I18n
class << self
def full_message(policy_class, rule)
# generate candidates
candidates = [:"#{policy_class.identifier}.#{rule}"]
# add global fallbacks
View 01_rack_rewrite_config.rb
class RackRewriteConfig
class << self
# Configure named rewrite rule
def configure(name, &block)
raise ArgumentError, "Block is required" unless block_given?
rules[name] = block
end
# Apply named rule to the target
def apply(target, name, *args)
View keybase.md

Keybase proof

I hereby claim:

  • I am palkan on github.
  • I am palkan (https://keybase.io/palkan) on keybase.
  • I have a public key ASD9_7Qr5xvMYx75u8VApLRsuCjYGR87WquHVLTtuUahwAo

To claim this, I am signing this object:

View 01_readme.md
View sti_update.rb
module StiUpdate
def as(type)
if self.type == type
self
else
klass = type.camelize.constantize
if klass.nil?
self
else
became = self.becomes!(klass)
You can’t perform that action at this time.