Skip to content

Instantly share code, notes, and snippets.

View sanzstez's full-sized avatar
:octocat:

Alexandr Stets sanzstez

:octocat:
View GitHub Profile
# Wouldn't it be great if you could have STI like functionality
# without needing to encode strings of class names in the database?
# Well today is your lucky day! Discriminable Model is here to help.
#
# Simply specify your models desired type column, and provide a block to
# do the discrimination. If you want the whole STI-esque shebang of properly
# typed finder methods you can supply an array of 'discriminate_types' that will
# be used to apply an appropriate type.
#
# class MyModel < ActiveRecord::Base
cat ~/.config/default/action_cable
RVM_STRING = 2.4.3@schoolhire-app
PUMA_OPTS = "-e staging -p 28080 cable/config.ru"
DAEMON = puma
EXEC_COMMAND = cd /application/current && /.rvm/bin/rvm-shell ${RVM_STRING} -c "bundle exec ${DAEMON} ${PUMA_OPTS}"
~/.config/systemd/user/action_cable.service
[Unit]
Description = Action Cable
@sanzstez
sanzstez / deep.rb
Created September 18, 2017 22:33
recursive get deepnest of nested hash
def recount(hash, sum = 0)
hash.each { |key, value| sum = recount(value, sum + 1) if value.is_a?(Hash) }
sum
end
puts recount2(hash)
@sanzstez
sanzstez / gist:6006684
Created July 16, 2013 07:49
enable websockets firefox
# go to
about:config
# find
network.websocket