Skip to content

Instantly share code, notes, and snippets.

Avatar

Mark Holmberg mark-d-holmberg

View GitHub Profile
@mark-d-holmberg
mark-d-holmberg / srd_5e_monsters.json
Created Apr 4, 2020 — forked from tkfu/srd_5e_monsters.json
A JSON file with all the D&D 5e SRD monster data
View srd_5e_monsters.json
[
{
"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 Mar 23, 2020
Show foreign keys in a maria database.
View foreign key maria.sql
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
View solver.rb
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}") }
View ruby-test.rb
# 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 Sep 10, 2019
Create a Rails 5.2.3 on Ruby 2.6.4 Gem engine running API JSON mode only
View rails-5.2.3-ruby-2.6.4-gem-engine
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 Aug 21, 2019
Because API only Rails Apps don't need no cookies!
View patch-rails-api-secret-key-base.rb
# 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
View Wrap-in-Begin-Rescue-End.sublime-snippet
<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>
View close_stupid_gadgets.js
$("a.minimization").each(function(index) {
$(this).trigger('click');
});
View nuke-ds-store-files.sh
find . -name ".DS_Store" -print | xargs rm
View Hotkeys.ini
[Macros]
hot=cqf hotkeys activate
[Hotkeys]
F2=
F3=
Shift-1=hot 1
Shift-2=hot 2
Shift-3=hot 3
Shift-4=hot 4
You can’t perform that action at this time.