Skip to content

Instantly share code, notes, and snippets.

@mark-d-holmberg
mark-d-holmberg / srd_5e_monsters.json
Created April 4, 2020 23:50 — forked from tkfu/srd_5e_monsters.json
A JSON file with all the D&D 5e SRD monster data
[
{
"name": "Aboleth",
"meta": "Large aberration, lawful evil",
"Armor Class": "17 (Natural Armor)",
"Hit Points": "135 (18d10 + 36)",
"Speed": "10 ft., swim 40 ft. ",
"STR": "21",
"STR_mod": "(+5)",
"DEX": "9",
@mark-d-holmberg
mark-d-holmberg / foreign key maria.sql
Created March 23, 2020 20:33
Show foreign keys in a maria database.
select concat(fks.constraint_schema, '.', fks.table_name) as foreign_table,
'->' as rel,
concat(fks.unique_constraint_schema, '.', fks.referenced_table_name)
as primary_table,
fks.constraint_name,
group_concat(kcu.column_name
order by position_in_unique_constraint separator ', ')
as fk_columns
from information_schema.referential_constraints fks
join information_schema.key_column_usage kcu
class Solver
def self.solve!(my_array, my_string)
# my_array.each { |k| my_string.gsub!(k, " #{k} ") }
# my_string.split.join(' ')
# Working:
my_string.gsub(/(#{my_array.sort_by(&:length).reverse.join("|")})\s*/, ' \1').split.join(' ')
# my_string.gsub(/(#{my_array.join("|")})\s*/, ' \1')
# my_array.sort_by(&:length).each { |k| my_string.gsub!(/#{k}\s*/, " #{k}") }
# Number 1
input = %w[therapy fun is]
string = 'therapyisfunfunfunfunis'
input.each { |k| string.gsub!(k, " #{k} ") }
string.split.join(' ')
# Number 2
# Same solution as 1
@mark-d-holmberg
mark-d-holmberg / rails-5.2.3-ruby-2.6.4-gem-engine
Created September 10, 2019 20:51
Create a Rails 5.2.3 on Ruby 2.6.4 Gem engine running API JSON mode only
rails plugin new elemental -d mysql --mountable -T --dummy-path=spec/dummy --skip-action-mailer -C --skip-turbolinks --skip-action-cable --skip-spring --skip-active-storage --skip-coffee --skip-yarn --api -p
@mark-d-holmberg
mark-d-holmberg / patch-rails-api-secret-key-base.rb
Created August 21, 2019 15:10
Because API only Rails Apps don't need no cookies!
# https://github.com/rails-api/rails-api/issues/72
# https://github.com/rails/rails/blob/v5.2.3/railties/lib/rails/application.rb#L579
Rails::Application.class_eval do
if defined?(::Rails.logger)
Rails.logger.warn '[initializers][AA_rails_hacks] - Patching Rails Application class'
else
puts '[initializers][AA_rails_hacks] - Patching Rails Application class'
end
@mark-d-holmberg
mark-d-holmberg / Wrap-in-Begin-Rescue-End.sublime-snippet
Created August 20, 2019 17:12
Sublime Text 3 Begin Rescue End
<snippet>
<content><![CDATA[${TM_SELECTED_TEXT/([\t ]*).*/$1/m}begin
${3:${TM_SELECTED_TEXT/(\A.*)|(.+)|\n\z/(?1:$0:(?2:\t$0))/g}}
${TM_SELECTED_TEXT/([\t ]*).*/$1/m}rescue ${1:Exception}${2/.+/ => /}${2:e}
${TM_SELECTED_TEXT/([\t ]*).*/$1/m} $0
${TM_SELECTED_TEXT/([\t ]*).*/$1/m}end
]]></content>
<tabTrigger>begin</tabTrigger>
<scope>source.ruby - comment</scope>
<description>begin … rescue … end</description>
@mark-d-holmberg
mark-d-holmberg / close_stupid_gadgets.js
Created August 6, 2019 15:54
Close stupid JIRA gadgets
$("a.minimization").each(function(index) {
$(this).trigger('click');
});
find . -name ".DS_Store" -print | xargs rm
@mark-d-holmberg
mark-d-holmberg / Hotkeys.ini
Created July 28, 2018 05:56
Fallout 4 Hotkeys
[Macros]
hot=cqf hotkeys activate
[Hotkeys]
F2=
F3=
Shift-1=hot 1
Shift-2=hot 2
Shift-3=hot 3
Shift-4=hot 4