Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View cswalina's full-sized avatar

Chet Swalina cswalina

  • West Arete
View GitHub Profile
@cswalina
cswalina / gist:b2651fa04095232355936b16092bb919
Created April 21, 2020 21:14
mixpanel integration examples
We usually store tokens in the app in config/mixpanle.yml:
development:
token: 1234xyz
test:
token: abc123
And put the top-level Mixpanel code snippet in a shared partial, "app/views/shared/_mixpanel.html.erb":
<% if mixpanel_enabled? %>
RailsAdmin.config do |config|
config.authorize_with do
redirect_to main_app.root_path, error: "You are not authorized." unless current_user.is_admin?
end
.
.
.
end
--------
@cswalina
cswalina / gist:5f04c41dfc4eb017e8ed5ec340e30557
Created June 14, 2018 21:27
Rails API 2 ways: active_model_serializers, fast_jsonapi
gem 'active_model_serializers'
rails g serializer publication
app/serializers/api/v1/publication_serializer.rb
module API::V1
class PublicationSerializer < ActiveModel::Serializer
attributes :title
end

Keybase proof

I hereby claim:

  • I am cswalina on github.
  • I am chets (https://keybase.io/chets) on keybase.
  • I have a public key ASC2UEXdsoUnobHu4pQ85lHbQu9Hmi3bOm5f1rsAw8rKtgo

To claim this, I am signing this object:

@cswalina
cswalina / gist:b53060150e94e7d642c4935988304c92
Created June 13, 2016 22:04
How we might generate work sessions
class Rotation
has_many :shift_cycles
def template
# given some shift_cycles:
#-------------------------------+
# days_on | days_off | shift_id |
#-------------------------------+
# 3 | 1 | 5
# 2 | 1 | 6