source
stringclasses
1 value
repo
stringlengths
5
63
repo_url
stringlengths
24
82
path
stringlengths
5
167
language
stringclasses
1 value
license
stringclasses
5 values
stars
int64
10
51.4k
ref
stringclasses
23 values
size_bytes
int64
200
258k
text
stringlengths
137
258k
github
chordbook/chordbook
https://github.com/chordbook/chordbook
app/jobs/associate_songsheet_metadata.rb
Ruby
mit
87
main
837
class AssociateSongsheetMetadata < ApplicationJob def perform(songsheet, lookup_unknown_artist: true) artist = songsheet.metadata["artist"] || songsheet.metadata["subtitle"] # No need to continue if no artists declared return if artist.blank? # Prevent jobs from being enqueued recursively songsh...
github
chordbook/chordbook
https://github.com/chordbook/chordbook
app/jobs/application_job.rb
Ruby
mit
87
main
335
class ApplicationJob < ActiveJob::Base # Automatically retry jobs that encountered a deadlock # retry_on ActiveRecord::Deadlocked retry_on StandardError, wait: :polynomially_longer, attempts: 10 # Most jobs are safe to ignore if the underlying records are no longer available discard_on ActiveJob::Deserializ...
github
chordbook/chordbook
https://github.com/chordbook/chordbook
app/jobs/update_listener_counts.rb
Ruby
mit
87
main
1,314
class UpdateListenerCounts < ApplicationJob queue_as :low def perform ApplicationRecord.connection.execute <<~EOQ UPDATE artists SET listeners = count.listeners, updated_at = NOW() FROM ( SELECT artists.id, sum(tracks.listeners) as listeners FROM artists LEFT JOIN trac...
github
chordbook/chordbook
https://github.com/chordbook/chordbook
app/jobs/cleanup_searches_job.rb
Ruby
mit
87
main
325
class CleanupSearchesJob < ApplicationJob def perform Searchjoy::Search.where("created_at < ?", 1.year.ago).find_in_batches do |searches| search_ids = searches.map(&:id) Searchjoy::Conversion.where(search_id: search_ids).delete_all Searchjoy::Search.where(id: search_ids).delete_all end end...
github
chordbook/chordbook
https://github.com/chordbook/chordbook
app/jobs/parse_songsheet_metadata_job.rb
Ruby
mit
87
main
343
class ParseSongsheetMetadataJob < NodeJob self.script_path = Rails.root.join("app/jobs/parse_songsheet_metadata.mjs").to_s def perform(songsheet) songsheet.update! metadata: super(songsheet.source) end def self.all Songsheet.find_each do |songsheet| ParseSongsheetMetadataJob.perform_later(songsh...
github
chordbook/chordbook
https://github.com/chordbook/chordbook
app/jobs/youtube_lookup.rb
Ruby
mit
87
main
984
# Look up YouTube videos for a track class YoutubeLookup < ApplicationJob queue_as :metadata # Probably hit API limit, retry tomorrow retry_on Google::Apis::ClientError, wait: 24.hours API_KEY = ENV["YOUTUBE_API_KEY"] SERVICE = Google::Apis::YoutubeV3::YouTubeService.new.tap do |service| service.key = A...
github
chordbook/chordbook
https://github.com/chordbook/chordbook
app/jobs/node_job.rb
Ruby
mit
87
main
816
# This is a base class for jobs that run Node scripts. class NodeJob < ApplicationJob class_attribute :script_path class Error < StandardError attr_reader :data def initialize(data) super(data["message"]) @data = data exception.set_backtrace(data["stack"].split("\n").slice(1..-1)) en...
github
chordbook/chordbook
https://github.com/chordbook/chordbook
app/jobs/generated_setlists/too_many_versions.rb
Ruby
mit
87
main
220
class GeneratedSetlists::TooManyVersions < GeneratedSetlists def perform update_setlist "Too Many Versions" do Songsheet.joins(:track).order("tracks.songsheets_count DESC, songsheets.rank") end end end
github
chordbook/chordbook
https://github.com/chordbook/chordbook
app/jobs/generated_setlists/whats_new.rb
Ruby
mit
87
main
368
class GeneratedSetlists::WhatsNew < GeneratedSetlists def perform update_setlist "What's New" do # Get 300 most recently created, but limit to 100 sorted by rank to drop any # unranked or spammy stuff off the list. ids = Songsheet.order(created_at: :desc).limit(300).pluck(:id) Songsheet.wh...
github
chordbook/chordbook
https://github.com/chordbook/chordbook
app/jobs/generated_setlists/favorites.rb
Ruby
mit
87
main
229
class GeneratedSetlists::Favorites < GeneratedSetlists def perform update_setlist "All-time Favorites" do Songsheet.joins(:library_items).group(:id).order(Arel.sql("COUNT(*) DESC")).order_by_popular end end end
github
chordbook/chordbook
https://github.com/chordbook/chordbook
app/jobs/generated_setlists/decades.rb
Ruby
mit
87
main
309
class GeneratedSetlists::Decades < GeneratedSetlists def perform (1940..2010).step(10).to_a.reverse_each do |year| decade = (year...year + 10) update_setlist "#{year}s" do Songsheet.joins(track: :album).where("albums.released" => decade).order_by_popular end end end end
github
chordbook/chordbook
https://github.com/chordbook/chordbook
app/jobs/generated_setlists/key_of.rb
Ruby
mit
87
main
489
class GeneratedSetlists::KeyOf < GeneratedSetlists def perform %w[A A#/Bb B C C#/Db D D#/Eb E F F#/Gb G G#/Ab].each do |key| keys = key.split("/") update_setlist "Key of #{key}" do Songsheet.where("metadata->>'key' IN (?)", keys).order_by_popular end # Minor keys = keys.map ...
github
chordbook/chordbook
https://github.com/chordbook/chordbook
app/jobs/generated_setlists/recently_updated.rb
Ruby
mit
87
main
381
class GeneratedSetlists::RecentlyUpdated < GeneratedSetlists def perform update_setlist "Recently Updated" do # Get 300 most recently updated, but limit to 100 sorted by rank to drop any # unranked or spammy stuff off the list. ids = Songsheet.order(updated_at: :desc).limit(300).pluck(:id) ...
github
chordbook/chordbook
https://github.com/chordbook/chordbook
app/jobs/generated_setlists/unmatched.rb
Ruby
mit
87
main
264
class GeneratedSetlists::Unmatched < GeneratedSetlists EXCLUDED = [ "Traditional" ] def perform update_setlist "Unmatched" do Songsheet.where(track_id: nil).where("metadata->>'subtitle' NOT IN (?)", EXCLUDED).order_by_recent end end end
github
chordbook/chordbook
https://github.com/chordbook/chordbook
app/jobs/import/ozbcoz.rb
Ruby
mit
87
main
1,319
require "throttle" require "addressable" # Import songs from https://ozbcoz.com/ class Import::Ozbcoz < Import::Chordpro include HTTParty base_uri "https://ozbcoz.com/" delegate :get, to: :class def perform(url) source = get(url).body.force_encoding("UTF-8") Import::Chordpro.perform_later lint(source...
github
chordbook/chordbook
https://github.com/chordbook/chordbook
app/jobs/import/chordpro.rb
Ruby
mit
87
main
534
require "chordpro" # Import a songsheet in chordpro format class Import::Chordpro < ApplicationJob # Source needs modified discard_on ActiveRecord::RecordInvalid def perform(source, songsheet: nil, **attrs) chordpro = Chordpro.parse(source.strip) # Don't index yet, let the metadata lookup job do that ...
github
chordbook/chordbook
https://github.com/chordbook/chordbook
app/jobs/musix_match/match_track_job.rb
Ruby
mit
87
main
501
class MusixMatch::MatchTrackJob < ApplicationJob queue_as :low def perform(track) return unless Flipper.enabled?(:musixmatch) response = MusixMatch.match_track(q_artist: track.artist.name, q_track: track.title, q_album: track.album.title) data = response["message"]["body"]["track"] reference = tra...
github
chordbook/chordbook
https://github.com/chordbook/chordbook
app/jobs/musix_match/get_lyrics.rb
Ruby
mit
87
main
274
class MusixMatch::GetLyrics < ApplicationJob queue_as :low def perform(reference) return unless Flipper.enabled?(:musixmatch) response = MusixMatch.track_lyrics(reference.identifier) reference.update!(data: response["message"]["body"]["lyrics"]) end end
github
chordbook/chordbook
https://github.com/chordbook/chordbook
app/views/sitemaps/show.xml.builder
Ruby
mit
87
main
262
xml.instruct! xml.urlset xmlns: "http://www.sitemaps.org/schemas/sitemap/0.9" do @records.find_each do |record| xml.url do xml.loc client_url([params[:id], record.to_param].join("/")) xml.lastmod record.updated_at.to_fs(:w3c) end end end
github
chordbook/chordbook
https://github.com/chordbook/chordbook
ios/App/Podfile
Ruby
mit
87
main
612
require_relative "../../node_modules/@capacitor/ios/scripts/pods_helpers" platform :ios, "13.0" use_frameworks! # workaround to avoid Xcode caching of Pods that requires # Product -> Clean Build Folder after new Cordova plugins installed # Requires CocoaPods 1.6 or newer install! "cocoapods", disable_input_output_pat...
github
hopsoft/stimulus_reflex_expo
https://github.com/hopsoft/stimulus_reflex_expo
Gemfile
Ruby
mit
87
master
1,340
# frozen_string_literal: true source "https://rubygems.org" git_source(:github) { |repo| "https://github.com/#{repo}.git" } ruby "2.7.1" gem "bootsnap", ">= 1.4", require: false gem "cable_ready", "~> 4.4.6" gem "chartkick", "~> 3.4.0" gem "countries", "~> 3.0" gem "faker", "~> 2.7" gem "hiredis", "~> 0.6.3" gem "ht...
github
hopsoft/stimulus_reflex_expo
https://github.com/hopsoft/stimulus_reflex_expo
config/application.rb
Ruby
mit
87
master
700
# frozen_string_literal: true require_relative "boot" require "rails/all" # Require the gems listed in Gemfile, including any gems # you've limited to :test, :development, or :production. Bundler.require(*Rails.groups) module StimulusReflexExpo class Application < Rails::Application # Initialize configuration...
github
hopsoft/stimulus_reflex_expo
https://github.com/hopsoft/stimulus_reflex_expo
config/routes.rb
Ruby
mit
87
master
653
# frozen_string_literal: true Rails.application.routes.draw do scope :demos do resource :book_search, only: [:show] resource :calendar, only: [:show], path: "/calendar/:date" resources :calendar_events, only: [:create, :update] resource :chat, only: [:show] resource :geo_selector, only: [:show] ...
github
hopsoft/stimulus_reflex_expo
https://github.com/hopsoft/stimulus_reflex_expo
config/puma.rb
Ruby
mit
87
master
1,609
# frozen_string_literal: true # Puma can serve each request in a thread from an internal thread pool. # The `threads` method setting takes two numbers: a minimum and maximum. # Any libraries that use thread pools should be configured to match # the maximum value specified for Puma. Default is set to 5 threads for mini...
github
hopsoft/stimulus_reflex_expo
https://github.com/hopsoft/stimulus_reflex_expo
config/initializers/pagy.rb
Ruby
mit
87
master
6,860
# frozen_string_literal: true Pagy::VARS[:items] = 10 Pagy::VARS[:size] = [1, 2, 2, 1] # Pagy initializer file (3.6.0) # Customize only what you really need and notice that Pagy works also without any of the following lines. # Should you just cherry pick part of this file, please maintain the require-order of the ext...
github
hopsoft/stimulus_reflex_expo
https://github.com/hopsoft/stimulus_reflex_expo
config/environments/test.rb
Ruby
mit
87
master
1,931
# frozen_string_literal: true # The test environment is used exclusively to run your application's # test suite. You never need to work with it otherwise. Remember that # your test database is "scratch space" for the test suite and is wiped # and recreated between test runs. Don't rely on the data there! Rails.applic...
github
hopsoft/stimulus_reflex_expo
https://github.com/hopsoft/stimulus_reflex_expo
config/environments/development.rb
Ruby
mit
87
master
2,188
# frozen_string_literal: true Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. # In the development environment your application's code is reloaded on # every request. This slows down response time but is perfect for development # since you don...
github
hopsoft/stimulus_reflex_expo
https://github.com/hopsoft/stimulus_reflex_expo
config/environments/production.rb
Ruby
mit
87
master
5,196
# frozen_string_literal: true Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. # Code is not reloaded between requests. config.cache_classes = true # Eager load code on boot. This eager loads most of Rails and # your application in memory, a...
github
hopsoft/stimulus_reflex_expo
https://github.com/hopsoft/stimulus_reflex_expo
db/schema.rb
Ruby
mit
87
master
2,545
# This file is auto-generated from the current state of the database. Instead # of editing this file, please use the migrations feature of Active Record to # incrementally modify your database, and then regenerate this schema definition. # # This file is the source Rails uses to define your schema when running `rails #...
github
hopsoft/stimulus_reflex_expo
https://github.com/hopsoft/stimulus_reflex_expo
db/seeds.rb
Ruby
mit
87
master
466
# frozen_string_literal: true Restaurant.destroy_all 100.times do Restaurant.create( name: Faker::Restaurant.name, stars: [1, 2, 3, 4, 5].sample, price: [1, 2, 3].sample, category: Faker::Restaurant.type ) end MetricsEntry.destroy_all (Date.parse("2020-05-01")..Date.parse("2020-05-31")).each do |d...
github
hopsoft/stimulus_reflex_expo
https://github.com/hopsoft/stimulus_reflex_expo
db/migrate/20191027234259_create_restaurants.rb
Ruby
mit
87
master
342
# frozen_string_literal: true class CreateRestaurants < ActiveRecord::Migration[6.0] def change create_table :restaurants do |t| t.string :name, null: false t.integer :stars, null: false, default: 0 t.integer :price, null: false, default: 1 t.string :category, null: false t.timesta...
github
hopsoft/stimulus_reflex_expo
https://github.com/hopsoft/stimulus_reflex_expo
db/migrate/20200423144432_create_calendar_events.rb
Ruby
mit
87
master
340
# frozen_string_literal: true class CreateCalendarEvents < ActiveRecord::Migration[6.0] def change create_table :calendar_events do |t| t.string :session_id, null: false t.text :description, null: false t.datetime :occurs_at, null: false t.timestamps t.index [:session_id, :occurs_at...
github
hopsoft/stimulus_reflex_expo
https://github.com/hopsoft/stimulus_reflex_expo
db/migrate/20191030102010_create_todos.rb
Ruby
mit
87
master
344
# frozen_string_literal: true class CreateTodos < ActiveRecord::Migration[6.0] def change create_table :todos do |t| t.string :session_id, null: false t.string :title, null: false t.boolean :completed, null: false, default: false t.timestamps t.index :session_id t.index :comp...
github
hopsoft/stimulus_reflex_expo
https://github.com/hopsoft/stimulus_reflex_expo
db/migrate/20191026135315_create_users.rb
Ruby
mit
87
master
275
# frozen_string_literal: true class CreateUsers < ActiveRecord::Migration[6.0] def change create_table :users do |t| t.string :first_name, null: false t.string :last_name, null: false t.string :email, null: false t.timestamps end end end
github
hopsoft/stimulus_reflex_expo
https://github.com/hopsoft/stimulus_reflex_expo
db/migrate/20200608144304_create_metrics_entries.rb
Ruby
mit
87
master
235
class CreateMetricsEntries < ActiveRecord::Migration[6.0] def change create_table :metrics_entries do |t| t.float :requests_per_second t.integer :response_time t.date :date t.timestamps end end end
github
hopsoft/stimulus_reflex_expo
https://github.com/hopsoft/stimulus_reflex_expo
app/models/restaurant.rb
Ruby
mit
87
master
868
# frozen_string_literal: true # == Schema Information # # Table name: restaurants # # id :bigint not null, primary key # category :string not null # name :string not null # price :integer default(1), not null # stars :integer default(0), no...
github
hopsoft/stimulus_reflex_expo
https://github.com/hopsoft/stimulus_reflex_expo
app/models/user.rb
Ruby
mit
87
master
525
# frozen_string_literal: true # == Schema Information # # Table name: users # # id :bigint not null, primary key # first_name :string not null # last_name :string not null # email :string not null # created_at :datetime not null # updated_at :datetime...
github
hopsoft/stimulus_reflex_expo
https://github.com/hopsoft/stimulus_reflex_expo
app/models/todo.rb
Ruby
mit
87
master
766
# frozen_string_literal: true # == Schema Information # # Table name: todos # # id :bigint not null, primary key # completed :boolean default(FALSE), not null # title :string not null # created_at :datetime not null # updated_at :datetime not null # sess...
github
hopsoft/stimulus_reflex_expo
https://github.com/hopsoft/stimulus_reflex_expo
app/models/calendar_event.rb
Ruby
mit
87
master
1,779
# frozen_string_literal: true # == Schema Information # # Table name: calendar_events # # id :bigint not null, primary key # description :text not null # occurs_at :datetime not null # created_at :datetime not null # updated_at :datetime not null # sessi...
github
hopsoft/stimulus_reflex_expo
https://github.com/hopsoft/stimulus_reflex_expo
app/reflexes/example_reflex.rb
Ruby
mit
87
master
824
# frozen_string_literal: true class ExampleReflex < ApplicationReflex # Add Reflex methods in this file. # # All Reflex instances expose the following properties: # # - connection - the ActionCable connection # - channel - the ActionCable channel # - request - an ActionDispatch::Request proxy for t...
github
hopsoft/stimulus_reflex_expo
https://github.com/hopsoft/stimulus_reflex_expo
app/reflexes/time_series_reflex.rb
Ruby
mit
87
master
282
class TimeSeriesReflex < ApplicationReflex def set_data_source session[:data_source] = element.value.to_sym end def set_start_date session[:start_date] = Date.parse(element.value) end def set_end_date session[:end_date] = Date.parse(element.value) end end
github
hopsoft/stimulus_reflex_expo
https://github.com/hopsoft/stimulus_reflex_expo
app/reflexes/tabular_reflex.rb
Ruby
mit
87
master
961
# frozen_string_literal: true class TabularReflex < ApplicationReflex include Tabular def search params[:query] = element[:value].strip update_client end def order params[:order_by] = element.dataset["column-name"] params[:direction] = element.dataset["direction"] update_client end d...
github
hopsoft/stimulus_reflex_expo
https://github.com/hopsoft/stimulus_reflex_expo
app/reflexes/snake_reflex.rb
Ruby
mit
87
master
2,287
# frozen_string_literal: true class SnakeReflex < ApplicationReflex DIRECTIONS = {37 => "left", 38 => "up", 39 => "right", 40 => "down"} def turn(code) if DIRECTIONS.key?(code) if (["left", "right"].include?(session[:direction]) && ["up", "down"].include?(DIRECTIONS[code])) || (["up", "down"].include?(s...
github
hopsoft/stimulus_reflex_expo
https://github.com/hopsoft/stimulus_reflex_expo
app/reflexes/book_search_reflex.rb
Ruby
mit
87
master
287
# frozen_string_literal: true class BookSearchReflex < ApplicationReflex def perform(query = "") return unless query.size > 2 result = HTTP.get("http://openlibrary.org/search.json?#{{q: query}.to_query}") @books = JSON.parse(result.to_s) if result.status == 200 end end
github
hopsoft/stimulus_reflex_expo
https://github.com/hopsoft/stimulus_reflex_expo
app/reflexes/gravatar_reflex.rb
Ruby
mit
87
master
309
# frozen_string_literal: true class GravatarReflex < ApplicationReflex def perform email = element[:value] return unless %r{[^@]+@[^.]+\..+}.match?(email) email_md5 = Digest::MD5.hexdigest(email.downcase.strip) @gravatar_image_url = "https://www.gravatar.com/avatar/#{email_md5}" end end
github
hopsoft/stimulus_reflex_expo
https://github.com/hopsoft/stimulus_reflex_expo
app/reflexes/todos_reflex.rb
Ruby
mit
87
master
901
# frozen_string_literal: true class TodosReflex < ApplicationReflex def create Todo.create session_id: session.id, title: element[:value] end def edit @edit_id = element.dataset[:id].to_i end def cancel_edit @edit_id = nil end def update Todo.find_by(session_id: session.id.to_s, id: el...
github
hopsoft/stimulus_reflex_expo
https://github.com/hopsoft/stimulus_reflex_expo
app/reflexes/geo_selector_reflex.rb
Ruby
mit
87
master
724
# frozen_string_literal: true class GeoSelectorReflex < ApplicationReflex def select_region @region = session[:region] = element[:value].start_with?("Select a") ? nil : element[:value] end def select_subregion @region = session[:region] @subregion = session[:subregion] = element[:value].start_with?(...
github
hopsoft/stimulus_reflex_expo
https://github.com/hopsoft/stimulus_reflex_expo
app/reflexes/calendar_reflex.rb
Ruby
mit
87
master
749
# frozen_string_literal: true class CalendarReflex < ApplicationReflex def new_calendar_event @calendar_event = CalendarEvent.new(session_id: session.id, occurs_at: Date.parse(element.dataset["date"])) session[:calendar_event_attributes] = @calendar_event.attributes end def edit_calendar_event @cale...
github
hopsoft/stimulus_reflex_expo
https://github.com/hopsoft/stimulus_reflex_expo
app/reflexes/application_reflex.rb
Ruby
mit
87
master
331
# frozen_string_literal: true class ApplicationReflex < StimulusReflex::Reflex # Put application wide Reflex behavior in this file. # # Example: # # # If your ActionCable connection is: `identified_by :current_user` # delegate :current_user, to: :channel # # Learn more at: https://docs.stimulusrefl...
github
hopsoft/stimulus_reflex_expo
https://github.com/hopsoft/stimulus_reflex_expo
app/reflexes/chat_reflex.rb
Ruby
mit
87
master
1,122
# frozen_string_literal: true class ChatReflex < ApplicationReflex include ActionView::Helpers::SanitizeHelper def post(color, message) morph :nothing message = strip_tags(message[0, 100]) return if message.blank? chat = { color: color, author: request.remote_ip, message: messa...
github
hopsoft/stimulus_reflex_expo
https://github.com/hopsoft/stimulus_reflex_expo
app/helpers/application_helper.rb
Ruby
mit
87
master
293
# frozen_string_literal: true module ApplicationHelper def css(default = "", conditionals = {}) additions = conditionals.each_with_object([]) { |(k, v), memo| memo << k if v } "#{default} #{additions.join " "}" end def active?(name) controller_name.include? name end end
github
hopsoft/stimulus_reflex_expo
https://github.com/hopsoft/stimulus_reflex_expo
app/helpers/gists_helper.rb
Ruby
mit
87
master
472
# frozen_string_literal: true module GistsHelper FORMATTER = Rouge::Formatters::HTMLPygments.new(Rouge::Formatters::HTMLLinewise.new(Rouge::Formatters::HTML.new)) LEXERS = { erb: Rouge::Lexers::ERB.new, html: Rouge::Lexers::HTML.new, javascript: Rouge::Lexers::Javascript.new, ruby: Rouge::Lexers::...
github
hopsoft/stimulus_reflex_expo
https://github.com/hopsoft/stimulus_reflex_expo
app/helpers/validations_helper.rb
Ruby
mit
87
master
655
# frozen_string_literal: true module ValidationsHelper def validation_status(user, attr) return :ignore unless user.attributes[attr.to_s].present? user.errors[attr].present? ? :invalid : :valid end def validation_message(user, attr) case validation_status(user, attr) when :invalid errors =...
github
hopsoft/stimulus_reflex_expo
https://github.com/hopsoft/stimulus_reflex_expo
app/helpers/demos_helper.rb
Ruby
mit
87
master
2,418
# frozen_string_literal: true module DemosHelper def demos %w[ book_search chat calendar geo_selector gravatar reverse_text tabular time_series todo validation ] end def render_demo(demo) render("/demos/demo") { render demo } end def r...
github
hopsoft/stimulus_reflex_expo
https://github.com/hopsoft/stimulus_reflex_expo
app/helpers/tabulars_helper.rb
Ruby
mit
87
master
590
# frozen_string_literal: true module TabularsHelper include Pagy::Frontend def column_css(column_name) return "text-light selected" if column_name.to_s == @order_by "text-light" end def arrow(column_name) return if column_name.to_s != @order_by @direction == "desc" ? "↑" : "↓" end def di...
github
hopsoft/stimulus_reflex_expo
https://github.com/hopsoft/stimulus_reflex_expo
app/controllers/chats_controller.rb
Ruby
mit
87
master
254
# frozen_string_literal: true class ChatsController < ApplicationController def show session[:chat_color] ||= "red" @chats = Rails.cache.read(:chats) || [] @chats.shift while @chats.size > 50 Rails.cache.write :chats, @chats end end
github
hopsoft/stimulus_reflex_expo
https://github.com/hopsoft/stimulus_reflex_expo
app/controllers/application_controller.rb
Ruby
mit
87
master
233
# frozen_string_literal: true class ApplicationController < ActionController::Base before_action :set_action_cable_identifier private def set_action_cable_identifier cookies.encrypted[:session_id] = session.id end end
github
hopsoft/stimulus_reflex_expo
https://github.com/hopsoft/stimulus_reflex_expo
app/controllers/time_series_controller.rb
Ruby
mit
87
master
378
# frozen_string_literal: true class TimeSeriesController < ApplicationController def show @current_data_source = session[:data_source] || :response_time @start_date = session[:start_date] || MetricsEntry.minimum(:date) @end_date = session[:end_date] || MetricsEntry.maximum(:date) @metrics_entries = M...
github
hopsoft/stimulus_reflex_expo
https://github.com/hopsoft/stimulus_reflex_expo
app/controllers/calendars_controller.rb
Ruby
mit
87
master
529
# frozen_string_literal: true class CalendarsController < ApplicationController def show @start_date ||= Date.parse(params[:date]) @start_date = @start_date.to_date.beginning_of_month date_range = (@start_date..@start_date.end_of_month) @dates = date_range.to_a @dates.prepend(@dates.first - 1) un...
github
hopsoft/stimulus_reflex_expo
https://github.com/hopsoft/stimulus_reflex_expo
app/controllers/validations_controller.rb
Ruby
mit
87
master
301
# frozen_string_literal: true class ValidationsController < ApplicationController def show @user ||= User.new(user_params) @user.validate end private def user_params return {} unless params.key?(:user) params.require(:user).permit(:first_name, :last_name, :email) end end
github
hopsoft/stimulus_reflex_expo
https://github.com/hopsoft/stimulus_reflex_expo
app/controllers/calendar_events_controller.rb
Ruby
mit
87
master
913
# frozen_string_literal: true class CalendarEventsController < ApplicationController after_action :cleanup def create calendar_event = CalendarEvent.new(calendar_event_params) calendar_event.assign_hour hour_params calendar_event.save redirect_to calendar_path(calendar_event.occurs_at.beginning_of...
github
hopsoft/stimulus_reflex_expo
https://github.com/hopsoft/stimulus_reflex_expo
app/controllers/todos_controller.rb
Ruby
mit
87
master
516
# frozen_string_literal: true class TodosController < ApplicationController FILTERS = %w[all active completed].freeze after_action :cleanup def show session[:todo_filter] = "all" unless filter_permitted?(session[:todo_filter]) @all_todos = Todo.where(session_id: session.id.to_s) @filtered_todos = @a...
github
hopsoft/stimulus_reflex_expo
https://github.com/hopsoft/stimulus_reflex_expo
app/controllers/snakes_controller.rb
Ruby
mit
87
master
532
# frozen_string_literal: true class SnakesController < ApplicationController def show unless @stimulus_reflex session[:direction] = "right" session[:clock] = false session[:speed] = 0.2 session[:grid_x] = 30 session[:grid_y] = 30 session[:length] = 4 session[:snake] = []...
github
hopsoft/stimulus_reflex_expo
https://github.com/hopsoft/stimulus_reflex_expo
app/controllers/concerns/tabular.rb
Ruby
mit
87
master
885
module Tabular extend ActiveSupport::Concern include Pagy::Backend protected def prepare_variables @query = params[:query] @order_by = permitted_column_name(params[:order_by]) @direction = permitted_direction(params[:direction]) restaurants = Restaurant.order(@order_by => @direction) rest...
github
hopsoft/stimulus_reflex_expo
https://github.com/hopsoft/stimulus_reflex_expo
app/channels/application_cable/connection.rb
Ruby
mit
87
master
226
# frozen_string_literal: true module ApplicationCable class Connection < ActionCable::Connection::Base identified_by :session_id def connect self.session_id = cookies.encrypted[:session_id] end end end
github
hopsoft/stimulus_reflex_expo
https://github.com/hopsoft/stimulus_reflex_expo
test/channels/chat_red_channel_test.rb
Ruby
mit
87
master
202
# frozen_string_literal: true require "test_helper" class ChatRedChannelTest < ActionCable::Channel::TestCase # test "subscribes" do # subscribe # assert subscription.confirmed? # end end
github
erichaydel/errdo
https://github.com/erichaydel/errdo
Rakefile
Ruby
mit
87
master
567
begin require 'bundler/setup' rescue LoadError puts 'You must `gem install bundler` and `bundle install` to run rake tasks' end require 'rdoc/task' RDoc::Task.new(:rdoc) do |rdoc| rdoc.rdoc_dir = 'rdoc' rdoc.title = 'Errdo' rdoc.options << '--line-numbers' rdoc.rdoc_files.include('README.rdoc') rdoc....
github
erichaydel/errdo
https://github.com/erichaydel/errdo
errdo.gemspec
Ruby
mit
87
master
1,106
$LOAD_PATH.push File.expand_path('../lib', __FILE__) # Maintain your gem's version: require 'errdo/version' # Describe your gem and declare its dependencies: Gem::Specification.new do |s| s.name = 'errdo' s.version = Errdo::VERSION s.authors = ['erichaydel'] s.email = ['erichaydel@gmail.c...
github
erichaydel/errdo
https://github.com/erichaydel/errdo
Gemfile
Ruby
mit
87
master
1,048
source 'https://rubygems.org' # Declare your gem's dependencies in errdo.gemspec. # Bundler will treat runtime dependencies like base dependencies, and # development dependencies will be added by default to the :development group. gemspec # Declare any dependencies that are still in development here instead of in # y...
github
erichaydel/errdo
https://github.com/erichaydel/errdo
lib/errdo.rb
Ruby
mit
87
master
4,298
require 'errdo/engine' require 'errdo/extension' require 'errdo/extensions/cancancan' require 'errdo/notifications/slack' require 'errdo/rake/task' if defined?(Rake::Task) ActiveSupport.on_load(:active_job) do # Reports exceptions occurring in ActiveJob jobs. require 'errdo/active_job' include Errdo::ActiveJob ...
github
erichaydel/errdo
https://github.com/erichaydel/errdo
lib/generators/active_record/errdo_generator.rb
Ruby
mit
87
master
1,199
require 'rails/generators/active_record' module ActiveRecord module Generators class ErrdoGenerator < ActiveRecord::Generators::Base argument :attributes, type: :array, default: [], banner: "field:type field:type" source_root File.expand_path("../templates", __FILE__) def check_table_not_exi...
github
erichaydel/errdo
https://github.com/erichaydel/errdo
lib/generators/active_record/templates/migration.rb
Ruby
mit
87
master
1,624
class ErrdoCreate<%= table_name.camelize %> < ActiveRecord::Migration<%= migration_version %> def change create_table :<%= table_name %> do |t| t.text :exception_class_name t.text :exception_message t.string :http_method t.text :host_name t.text :url t.text :backtrace t...
github
erichaydel/errdo
https://github.com/erichaydel/errdo
lib/generators/errdo/install_generator.rb
Ruby
mit
87
master
383
require 'rails/generators/base' module Errdo module Generators class InstallGenerator < Rails::Generators::Base source_root File.expand_path("../../templates", __FILE__) desc "Creates an errdo initializer and sets the exceptions_app to errdo's" def copy_initializer template "errdo.rb...
github
erichaydel/errdo
https://github.com/erichaydel/errdo
lib/generators/errdo/errdo_generator.rb
Ruby
mit
87
master
1,043
require 'rails/generators/named_base' module Errdo module Generators class ErrdoGenerator < Rails::Generators::NamedBase desc "Creates the database objects for error logging" include Rails::Generators::ResourceHelpers namespace "errdo" argument :name, type: 'string', default: "error" ...
github
erichaydel/errdo
https://github.com/erichaydel/errdo
lib/generators/templates/errdo.rb
Ruby
mit
87
master
2,703
Errdo.setup do |config| # Add words to be scrubbed from the params here. By default, this is # %w(password passwd password_confirmation secret confirm_password secret_token) # So make sure you add on, not replace! # config.dirty_words += ["custom_param"] # By default, 404 errors are ignored. To un-ignore the...
github
erichaydel/errdo
https://github.com/erichaydel/errdo
lib/errdo/engine.rb
Ruby
mit
87
master
473
require 'chartkick' module Errdo class Engine < Rails::Engine isolate_namespace Errdo require "kaminari" config.autoload_paths += %W[#{config.root}/lib] config.before_initialize do |app| app.config.exceptions_app = Errdo::ExceptionsController.new(Rails.public_path) end initializer ...
github
erichaydel/errdo
https://github.com/erichaydel/errdo
lib/errdo/extension.rb
Ruby
mit
87
master
878
module Errdo # rubocop:disable MutableConstant EXTENSIONS = [] AUTHORIZATION_ADAPTERS = {} NOTIFICATION_ADAPTERS = {} # rubocop:enable MutableConstant # The extension may define various adapters (e.g., for authorization) and # register those via the options hash. def self.add_extension(extension_key, e...
github
erichaydel/errdo
https://github.com/erichaydel/errdo
lib/errdo/notifier.rb
Ruby
mit
87
master
369
module Errdo class Notifier include Errdo::Helpers::NotificationHelper def initialize(*args) exception, string, params = separate_args(*args) @parser = Errdo::Models::ErrorLoggerParser.new(exception, string, params) end def notify Errdo.notify_with.each do |notifier| notif...
github
erichaydel/errdo
https://github.com/erichaydel/errdo
lib/errdo/logger.rb
Ruby
mit
87
master
509
module Errdo class Logger include Errdo::Helpers::NotificationHelper def initialize(importance, *args) @importance = importance exception, string, params = separate_args(*args) @parser = Errdo::Models::ErrorLoggerParser.new(exception, string, params) end def log error = Errd...
github
erichaydel/errdo
https://github.com/erichaydel/errdo
lib/errdo/rake/task.rb
Ruby
mit
87
master
383
module Rake class Task alias execute_task execute # rubocop:disable Lint/RescueException def execute(args = nil) execute_task(args) rescue Interrupt => e raise e # Dont log if it's an interrupt rescue Exception => e Errdo.error(e, args) if Errdo.log_task_exceptions raise ...
github
erichaydel/errdo
https://github.com/erichaydel/errdo
lib/errdo/models/user_parser.rb
Ruby
mit
87
master
703
module Errdo module Models class UserParser attr_accessor :user def initialize(env) # Warden support (This includes devise). if env['warden'] user = app_user(env['warden']) return @user = user if user end controller = env["action_controller.instan...
github
erichaydel/errdo
https://github.com/erichaydel/errdo
lib/errdo/models/error_logger_parser.rb
Ruby
mit
87
master
2,160
module Errdo module Models class ErrorLoggerParser attr_accessor :user, :exception_class_name, :exception_message, :http_method, :host_name, :url, :backtrace, :ip, :user_agent, :referer, :query_string, :param_values, :cookie_values, :header_values, ...
github
erichaydel/errdo
https://github.com/erichaydel/errdo
lib/errdo/models/error_env_parser.rb
Ruby
mit
87
master
3,613
module Errdo module Models class ErrorEnvParser attr_accessor :exception_class_name, :exception_message, :http_method, :host_name, :url, :backtrace, :ip, :user_agent, :referer, :query_string, :param_values, :cookie_values, :header_values, :experie...
github
erichaydel/errdo
https://github.com/erichaydel/errdo
lib/errdo/notifications/slack/notification_adapter.rb
Ruby
mit
87
master
2,240
require 'slack-notifier' require_relative '../../helpers/views_helper.rb' module Errdo module Notifications module Slack # This adapter is for slack notifier class NotificationAdapter # See the slack notifier for where the initialization happens. def initialize(options = {}) ...
github
erichaydel/errdo
https://github.com/erichaydel/errdo
lib/errdo/extensions/cancancan/authorization_adapter.rb
Ruby
mit
87
master
1,766
module Errdo module Extensions module CanCanCan # This adapter is for the CanCanCan[https://github.com/CanCanCommunity/cancancan] authorization library. class AuthorizationAdapter # See the +authorize_with+ config method for where the initialization happens. def initialize(controller,...
github
erichaydel/errdo
https://github.com/erichaydel/errdo
lib/errdo/helpers/views_helper.rb
Ruby
mit
87
master
569
module Errdo module Helpers module ViewsHelper def user_show_string(user) if user.respond_to?(Errdo.user_string_method || "") user.send(Errdo.user_string_method) elsif user user.class.to_s + " #" + user.id.to_s else "" end end def us...
github
erichaydel/errdo
https://github.com/erichaydel/errdo
lib/errdo/helpers/notification_helper.rb
Ruby
mit
87
master
464
module Errdo module Helpers module NotificationHelper def separate_args(*args) exception = nil string = nil params = nil args.each do |arg| if arg.is_a?(StandardError) exception = arg elsif arg.is_a?(String) string = arg ...
github
erichaydel/errdo
https://github.com/erichaydel/errdo
app/controllers/errdo/exceptions_controller.rb
Ruby
mit
87
master
839
module Errdo class ExceptionsController < ActionDispatch::PublicExceptions # attr_accessor :public_path # def initialize(public_path) # super # end def call(env) status = env["PATH_INFO"][1..-1] request = ActionDispatch::Request.new(env) content_type = request.for...
github
erichaydel/errdo
https://github.com/erichaydel/errdo
app/controllers/errdo/application_controller.rb
Ruby
mit
87
master
421
module Errdo class ApplicationController < ::ApplicationController layout "errdo/errdo_layout" before_action :_authenticate! before_action :_authorize! def _current_user instance_eval(&Errdo.current_user_method) end private def _authenticate! instance_eval(&Errdo.authentic...
github
erichaydel/errdo
https://github.com/erichaydel/errdo
app/controllers/errdo/errors_controller.rb
Ruby
mit
87
master
2,223
require "slim" module Errdo class ErrorsController < Errdo::ApplicationController include Errdo::Helpers::ViewsHelper helper_method :user_show_string, :user_show_path before_action :authorize_user DEFAULT_SCOPE = "active" def index @scope = get_whitelisted_scope if @scope == "all...
github
erichaydel/errdo
https://github.com/erichaydel/errdo
app/helpers/errdo/histogram_helper.rb
Ruby
mit
87
master
691
module Errdo module HistogramHelper def hist(data, num_bins, time_start, time_range) times = {} (0..num_bins).each do |num| bin_start = (time_start + ((num.to_f / num_bins.to_f) * time_range)) bin_end = (time_start + (((num + 1) / num_bins.to_f) * time_range)).beginning_of_hour ...
github
erichaydel/errdo
https://github.com/erichaydel/errdo
app/models/errdo/exception.rb
Ruby
mit
87
master
970
module Errdo class Exception def initialize(env) user_parser = Errdo::Models::UserParser.new(env) @env_parser = Errdo::Models::ErrorEnvParser.new(env, user_parser) error = nil error = create_errors(@env_parser) unless Errdo.error_name.blank? unless too_soon? error Errdo.not...
github
erichaydel/errdo
https://github.com/erichaydel/errdo
app/models/errdo/error_occurrence.rb
Ruby
mit
87
master
1,179
module Errdo class ErrorOccurrence < ActiveRecord::Base self.table_name = "#{Errdo.error_name.to_s.singularize}_occurrences" serialize :param_values serialize :cookie_values serialize :header_values belongs_to :error, counter_cache: :occurrence_count belongs_to :experiencer, polymorphic: tr...
github
erichaydel/errdo
https://github.com/erichaydel/errdo
app/models/errdo/error.rb
Ruby
mit
87
master
2,695
include Errdo::HistogramHelper module Errdo class Error < ActiveRecord::Base REJECTION_REGEX = %r{\/ruby-[0-9]*\.[0-9]*\.[0-9]*\/|\/(ruby|gems)\/[0-9]*\.[0-9]*\.[0-9]*\/(gems|bin|webrick)|_test.rb|\/app\/bin\/bundle} paginates_per 20 self.table_name = Errdo.error_name enum status: [:active, :wont...
github
erichaydel/errdo
https://github.com/erichaydel/errdo
test/factories.rb
Ruby
mit
87
master
465
FactoryGirl.define do factory :error, class: "Errdo::Error" do exception_class_name "RuntimeError" exception_message "standard-error" sequence(:backtrace) { |n| ["error#{n}"] } http_method "GET" host_name "www.example.com" url ...
github
erichaydel/errdo
https://github.com/erichaydel/errdo
test/test_helper.rb
Ruby
mit
87
master
1,647
require 'simplecov' SimpleCov.start # Configure Rails Environment ENV["RAILS_ENV"] = "test" require File.expand_path("../../test/dummy/config/environment.rb", __FILE__) ActiveRecord::Migrator.migrations_paths = [File.expand_path("../../test/dummy/db/migrate", __FILE__)] require "rails/test_help" require 'minitest/rep...
github
erichaydel/errdo
https://github.com/erichaydel/errdo
test/integrations/non_web_test.rb
Ruby
mit
87
master
1,750
require 'test_helper' if defined?(ActiveJob::Base) class FailJob < ActiveJob::Base queue_as :default def perform(*_args) raise "AsynchronousFailure" end end end class NonWebTest < ActionDispatch::IntegrationTest # rubocop:disable Style/RescueModifier # rubocop:disable Lint/HandleExcepti...
github
erichaydel/errdo
https://github.com/erichaydel/errdo
test/integrations/views_integration_test.rb
Ruby
mit
87
master
1,147
require 'test_helper' class ViewsIntegrationTest < ActionDispatch::IntegrationTest include Errdo::Helpers::ViewsHelper context "views" do setup do get_via_redirect static_generic_error_path @errdo = Errdo::Engine.routes.url_helpers end should "be able to successfully get the index" do ...
github
erichaydel/errdo
https://github.com/erichaydel/errdo
test/integrations/plugins_integration_test.rb
Ruby
mit
87
master
1,604
require 'test_helper' FAILSAFE_FAIL_STRING = "If you are the administrator of this website, then please read this web application's \ log file and/or the web server's log file to find out what went wrong.".freeze class PluginsIntegrationTest < ActionDispatch::IntegrationTest setup do Er...
github
erichaydel/errdo
https://github.com/erichaydel/errdo
test/integrations/errors_integration_test.rb
Ruby
mit
87
master
6,050
require 'test_helper' class ErrorsIntegrationTest < ActionDispatch::IntegrationTest setup do Errdo.error_name = "errors" end should "render a 404 error page" do get "/not-a-path" assert_equal 404, @response.status end should "render a 500 error page" do get static_generic_error_path as...