Skip to content

Instantly share code, notes, and snippets.

View tbcooney's full-sized avatar

Taylor Cooney tbcooney

View GitHub Profile
@tbcooney
tbcooney / utm-tracking.md
Last active January 24, 2019 21:45
UTM Tracking on Universe

UTM Tracking on Universe

The following overview provides a quick look into data that is captured when a user clicks on a Marketing ad.

Ad Platforms

Events are triggered on a "per channel" basis depending on certain user actions, such as creating an account or purchasing a ticket. Below is an overview of the expected events that should fire on a "per channel" basis. The use cases listed below will highlight the actual behaviour and the discrepency between expected and actual.

Bing

  • CompleteRegistration is fired when a visitor creates an account from Sign Up in the top navigation or Create Event on a landing page
  • Lead is fired when a visitor clicks Sign Up in the top navigation or a User clicks Create Event from a landing page/top navigation

Facebook

@tbcooney
tbcooney / migrate_from_g+.md
Last active January 29, 2019 21:13
Migrate From G+

Things We Use Google+ To Do

Case 1

  • When a user creates an account on Universe, they can sign up with Google (via G+ API)
    • user clicks Sign Up With Google, multiverse calls authenticateProvider which creates an OpenID Connect request from a deprecated scope plus/v1/people/me/openIdConnect
    • web sets params via auth_requests_controller.rb using a deprecated scope auth/plus.login
    • user data is fetched from deprecated scope plus/v1/people/me/openIdConnect to populate user info (email, first_name, photo, uid etc.)

Solution

  • Change the scope from deprecated G+ plus.login endpoint to profile
  • Set the user basic profile information with new method

Case 2

taylorcooney@Taylors-MacBook-Air:~/Code/openunit$ ⚡
bundle exec rails c
Running via Spring preloader in process 90646
Loading development environment (Rails 6.0.2.2)
irb(main):001:0> ActiveRecord::Base.connection.select_value("SEL
ECT users.unconfirmed_email FROM users")
/Users/taylorcooney/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/activemodel-6.0.2.2/lib/active_model/type/integer.rb:13: warning: Using the last argument as keyword parameters is deprecated; maybe ** should be added to the call
/Users/taylorcooney/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/activemodel-6.0.2.2/lib/active_model/type/value.rb:8: warning: The called method `initialize' is defined here
/Users/taylorcooney/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/activerecord-6.0.2.2/lib/active_record/connection_adapters/postgresql/oid/specialized_string.rb:12: warning: Using the last argument as keyword parameters is deprecated; maybe ** should be added to the call
@tbcooney
tbcooney / _seating_plan.html.haml
Created April 20, 2020 14:45 — forked from ftes/_seating_plan.html.haml
Drag and drop in CSS grid with rails 6, stimulus and rails-ujs
-# https://johnbeatty.co/2018/03/09/stimulus-js-tutorial-how-do-i-drag-and-drop-items-in-a-list/
.grid--draggable{ 'data-controller': 'seating-plan',
'data-seating-plan-endpoint': endpoint,
'data-action': 'dragstart->seating-plan#onDragStart dragover->seating-plan#onDragOver dragenter->seating-plan#onDragEnter drop->seating-plan#onDrop dragend->seating-plan#onDragEnd' }
- seating_plan.each do |seat|
- if seat[:is_empty]
.grid__item.grid__item--empty{ 'data-row': seat[:row],
'data-col': seat[:col],
style: "grid-row: #{seat[:row]}; grid-column: #{seat[:col]};",
class: ('grid__item--border' if seat[:is_border]) }
@tbcooney
tbcooney / gist:e7fcf7b24b501b455a423b836ff54e4c
Last active April 29, 2020 18:11
group_by_date_messages.rb
@messages.each do |day, messages|
%li.date_divider.w-full.block
.break
%span= "#{day.strftime("%B %d")}"
%ul
- messages.each do |message|
- if !unread_messages && @chatroom_user.last_read_at < message.created_at
- unread_messages = true
.strike
# chatroom_channel.rb
class ChatroomsChannel < ApplicationCable::Channel
def subscribed
current_user.chatrooms.each do |chatroom|
stream_from "chatrooms:#{chatroom.id}"
end
end
def unsubscribed
stop_all_streams
require 'openssl'
begin
require 'origami'
rescue LoadError
# ORIGAMIDIR = "C:\RailsInstaller\Ruby1.9.3\lib\ruby\gems\1.9.1\gems\origami-1.2.4\lib"
# $: << ORIGAMIDIR
# require 'origami'
end
include Origami
- @no_header = true
%section.login.w-full
%div
.branding.block
%div
%h2.mt-6.text-3xl.leading-9.font-extrabold.text-gray-900
= t('users.two_factor.two_factor_authentication')
- if @user.two_factor_otp_enabled?
# frozen_string_literal: true
# == AuthenticatesWithTwoFactor
#
# Controller concern to handle two-factor authentication
module AuthenticatesWithTwoFactor
extend ActiveSupport::Concern
def prompt_for_two_factor(user)
@user = user
-----> Ruby app detected
-----> Installing bundler 2.0.2
-----> Removing BUNDLED WITH version in the Gemfile.lock
-----> Compiling Ruby/Rails
-----> Using Ruby version: ruby-2.7.0
-----> Installing dependencies using bundler 2.0.2
Running: bundle install --without development:test --path vendor/bundle --binstubs vendor/bundle/bin -j4 --deployment
[DEPRECATED] The `--deployment` flag is deprecated because it relies on being remembered across bundler invocations, which bundler will no longer do in future versions. Instead please use `bundle config set deployment 'true'`, and stop using this flag
[DEPRECATED] The `--path` flag is deprecated because it relies on being remembered across bundler invocations, which bundler will no longer do in future versions. Instead please use `bundle config set path 'vendor/bundle'`, and stop using this flag
[DEPRECATED] The `--without` flag is deprecated because it relies on being remembered across bundler invocations, which bundler will no longer do