Skip to content

Instantly share code, notes, and snippets.

View jmarsh24's full-sized avatar
🤓
Programming

Justin Marsh jmarsh24

🤓
Programming
View GitHub Profile
import { Controller } from 'stimulus'
export default class extends Controller {
static targets = ["button"]
static values = { source: String }
copy () {
debugger
navigator.clipboard.writeText(this.sourceValue)
this.copied()
// This file is automatically compiled by Webpack, along with any other files
// present in this directory. You're encouraged to place your actual application logic in
// a relevant structure within app/javascript and only use these pack files to reference
// that code so it'll be compiled.
require("@rails/ujs").start()
require("@rails/activestorage").start()
require("channels")
require("@hotwired/turbo-rails")
// This file is automatically compiled by Webpack, along with any other files
// present in this directory. You're encouraged to place your actual application logic in
// a relevant structure within app/javascript and only use these pack files to reference
// that code so it'll be compiled.
require("@rails/ujs").start()
require("@rails/activestorage").start()
require("channels")
require("@hotwired/turbo-rails")
require("youtube-player")
class Ahoy::Event < AhoyRecord
include Ahoy::QueryMethods
MIN_NUMBER_OF_VIEWS = ENV["MINIMUM_NUMBER_OF_VIEWS"] || 3
belongs_to :visit
belongs_to :user, optional: true
class << self
def most_viewed_videos_by_month
<%= button_tag type: "button",
class: "videos-sortable-button",
data: { controller: "filter",
action: "filter#filter",
"filter-watched-value": "1" } do %>
<% if filtering_params["watched"] == "1" %>
<%= content_tag(:b, "Watched") %>
<% else %>
Watched
<% end %>
<div class="videos-sortable-container">
<label>
Filters for you
</label>
<%= button_tag type: "button",
class: "videos-sortable-button",
data: { controller: "filter",
action: "filter#filter",
"filter-watched-value": "1",
"filter-user-id-value": current_user.id } do %>
irb(main):001:0> Video::YoutubeImport.from_video('S2c6TJTdDX0')
D, [2021-12-29T11:11:45.804188 #4] DEBUG -- : Video Load (2.4ms) SELECT "videos".* FROM "videos" WHERE "videos"."youtube_id" = $1 LIMIT $2 [["youtube_id", "S2c6TJTdDX0"], ["LIMIT", 1]]
D, [2021-12-29T11:11:46.036802 #4] DEBUG -- : Channel Load (1.5ms) SELECT "channels".* FROM "channels" WHERE "channels"."channel_id" = $1 LIMIT $2 [["channel_id", "UCW7HAK0wBGHo1Xv3PL-CCGw"], ["LIMIT", 1]]
D, [2021-12-29T11:11:46.052199 #4] DEBUG -- : TRANSACTION (0.6ms) BEGIN
D, [2021-12-29T11:11:46.053313 #4] DEBUG -- : Video Exists? (0.9ms) SELECT 1 AS one FROM "videos" WHERE "videos"."youtube_id" = $1 AND "videos"."id" != $2 LIMIT $3 [["youtube_id", "S2c6TJTdDX0"], ["id", 247706], ["LIMIT", 1]]
D, [2021-12-29T11:11:46.056040 #4] DEBUG -- : TRANSACTION (0.5ms) COMMIT
D, [2021-12-29T11:11:46.060362 #4] DEBUG -- : Leader Load (3.2ms) SELECT "leaders".* FROM "leaders"
D, [2021-12-29T11:11:46.158394 #4] DEBUG -- : Follower Load (4.0ms) SELECT
class Video::MusicRecognition::AcrCloud
class << self
def fetch(youtube_id)
new(youtube_id).update_video
rescue StandardError => e
Rails.logger.warn "Video::MusicRecognition::AcrCloud no video found: #{e.backtrace.join("\n\t")}"
end
end
def initialize(youtube_id)