Skip to content

Instantly share code, notes, and snippets.

💭
hacking away on notebook.ai

Andrew Brown drusepth

💭
hacking away on notebook.ai
Block or report user

Report or block drusepth

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View lol.sql
=> "SELECT id,name,page_type,user_id,created_at,updated_at,deleted_at,archived_at,privacy,universe_id FROM universes WHERE user_id = 1 AND deleted_at IS NULL AND archived_at IS NULL UNION ALL SELECT id,name,page_type,user_id,created_at,updated_at,deleted_at,archived_at,privacy,universe_id FROM characters WHERE user_id = 1 AND deleted_at IS NULL AND archived_at IS NULL AND universe_id = 2 UNION ALL SELECT id,name,page_type,user_id,created_at,updated_at,deleted_at,archived_at,privacy,universe_id FROM locations WHERE user_id = 1 AND deleted_at IS NULL AND archived_at IS NULL AND universe_id = 2 UNION ALL SELECT id,name,page_type,user_id,created_at,updated_at,deleted_at,archived_at,privacy,universe_id FROM items WHERE user_id = 1 AND deleted_at IS NULL AND archived_at IS NULL AND universe_id = 2 UNION ALL SELECT id,name,page_type,user_id,created_at,updated_at,deleted_at,archived_at,privacy,universe_id FROM buildings WHERE user_id = 1 AND deleted_at IS NULL AND archived_at IS NULL AND universe_id = 2 UNION ALL SE
View thredded_proxy_controller.rb
class ThreddedProxyController < ApplicationController
def topic
topic = Thredded::Topic.find_by(slug: params[:slug])
redirect_to thredded.messageboard_topic_path(
messageboard_id: topic.messageboard_id,
id: topic.id
)
end
end
@drusepth
drusepth / thredded.rb
Last active Jun 4, 2020
config/initializers/thredded.rb
View thredded.rb
# config/initializers/thredded.rb
# ...
# snip
# ...
require 'extensions/thredded/topic'
Rails.application.config.to_prepare do
begin
if ActiveRecord::Base.connection.table_exists?(:thredded_topics)
Thredded::Topic.include(Extensions::Thredded::Topic)
@drusepth
drusepth / topic.rb
Last active Jun 4, 2020
lib/extensions/thredded/topic.rb
View topic.rb
# lib/extensions/thredded/topic.rb
module Extensions
module Thredded
module Topic
extend ActiveSupport::Concern
included do
after_create :create_content_page_share
has_many :content_page_shares, as: :content
View gist:1515a68c0fed4916d5f2175d0af47598
Deck
1 Banehound (WAR) 77
9 Swamp (IKO) 268
4 Act of Treason (M19) 127
12 Mountain (IKO) 271
4 Portent of Betrayal (THB) 149
2 Barrier of Bones (GRN) 61
4 Electrostatic Field (GRN) 97
3 Piston-Fist Cyclops (GRN) 217
1 Mayhem Devil (WAR) 204
View explain-analyze.sql
irb(main):032:0> result = ActiveRecord::Base.connection.execute(sql)
irb(main):033:0> (0...result.ntuples).each { |i| puts result.getvalue(i, 0) }
Sort (cost=534.90..535.03 rows=270 width=144) (actual time=1.648..1.669 rows=443 loops=1)
Sort Key: universes.page_type, ((universes.id)::bigint)
Sort Method: quicksort Memory: 87kB
-> Append (cost=0.08..532.72 rows=270 width=144) (actual time=0.028..1.260 rows=443 loops=1)
-> Result (cost=0.08..219.59 rows=120 width=144) (actual time=0.028..0.612 rows=247 loops=1)
-> Append (cost=0.08..219.11 rows=120 width=136) (actual time=0.027..0.580 rows=247 loops=1)
-> Index Scan using index_universes_on_deleted_at_and_user_id on universes (cost=0.08..82.13 rows=46 width=70) (actual time=0.027..0.139 rows=38 loops=1)
Index Cond: ((deleted_at IS NULL) AND (user_id = 5))
View all-content-query.sql
SELECT id,name,page_type,user_id,created_at,updated_at,deleted_at,archived_at,privacy
FROM universes WHERE user_id = 5 AND deleted_at IS NULL AND archived_at IS NULL
UNION ALL
SELECT id,name,page_type,user_id,created_at,updated_at,deleted_at,archived_at,privacy
FROM characters WHERE user_id = 5 AND deleted_at IS NULL AND archived_at IS NULL
UNION ALL
SELECT id,name,page_type,user_id,created_at,updated_at,deleted_at,archived_at,privacy
FROM locations WHERE user_id = 5 AND deleted_at IS NULL AND archived_at IS NULL
UNION ALL
SELECT id,name,page_type,user_id,created_at,updated_at,deleted_at,archived_at,privacy
View has_content#content.rb
def content(
content_types: Rails.application.config.content_types[:all].map(&:name),
page_scoping: { user_id: self.id },
universe_id: nil
)
return {} if content_types.empty?
polymorphic_content_fields = [:id, :name, :page_type, :user_id, :created_at, :updated_at, :deleted_at, :archived_at, :privacy]
where_conditions = page_scoping.map { |key, value| "#{key} = #{value}" }.join(' AND ') + ' AND deleted_at IS NULL AND archived_at IS NULL'
View segfault.txt
/app/vendor/bundle/ruby/2.6.0/gems/sassc-2.2.1/lib/sassc/engine.rb:42: [BUG] Segmentation fault at 0x0000000000000000
ruby 2.6.3p62 (2019-04-16 revision 67580) [x86_64-linux]
-- Control frame information -----------------------------------------------
c:0046 p:---- s:0336 e:000335 CFUNC :compile_data_context
c:0045 p:0298 s:0331 e:000330 METHOD /app/vendor/bundle/ruby/2.6.0/gems/sassc-2.2.1/lib/sassc/engine.rb:42
c:0044 p:0006 s:0319 e:000318 BLOCK /app/vendor/bundle/ruby/2.6.0/gems/sassc-rails-2.1.2/lib/sassc/rails/template.rb:40
c:0043 p:0028 s:0316 e:000315 METHOD /app/vendor/bundle/ruby/2.6.0/gems/sprockets-4.0.0/lib/sprockets/utils.rb:138
c:0042 p:0164 s:0309 e:000308 METHOD /app/vendor/bundle/ruby/2.6.0/gems/sassc-rails-2.1.2/lib/sassc/rails/template.rb:39
c:0041 p:0053 s:0300 e:000299 METHOD /app/vendor/bundle/ruby/2.6.0/gems/sprockets-4.0.0/lib/sprockets/processor_utils.rb:84
View shortcuts.js
add_redirect_shortcut("b", "/plan/buildings/new");
add_redirect_shortcut("c", "/plan/characters/new");
add_redirect_shortcut("n", "/plan/conditions/new");
add_redirect_shortcut("u", "/plan/countries/new");
add_redirect_shortcut("r", "/plan/creatures/new");
add_redirect_shortcut("d", "/plan/deities/new");
add_redirect_shortcut("w", "/plan/floras/new");
add_redirect_shortcut("f", "/plan/foods/new");
add_redirect_shortcut("g", "/plan/governments/new");
add_redirect_shortcut("o", "/plan/groups/new");
You can’t perform that action at this time.