Skip to content

Instantly share code, notes, and snippets.

@mark-d-holmberg
mark-d-holmberg / redcarpet.rb
Created February 15, 2012 04:56 — forked from stephencelis/redcarpet.rb
Redcarpet (Markdown) template handler for Rails 3.1.
class ActionView::Template
class Markdown
def call(template)
Redcarpet::Markdown.new(Redcarpet::Render::HTML).render(template.source).inspect
end
end
ActionView::Template.register_template_handler :md, Markdown.new
end
@mark-d-holmberg
mark-d-holmberg / spec_helper.rb
Last active December 25, 2015 15:19 — forked from pauljamesrussell/spec_helper.rb
Allows it to test accepts_nested_attributes_for with associations that are a `has_one`
# See: https://gist.github.com/1353500
# Use: it { should accept_nested_attributes_for(:association_name).using_has_one(true).and_accept({valid_values => true}).but_reject({ :reject_if_nil => nil })}
RSpec::Matchers.define :accept_nested_attributes_for do |association|
match do |model|
@model = model
@nested_att_present = model.respond_to?("#{association}_attributes=".to_sym)
if @nested_att_present && @reject
model.send("#{association}_attributes=".to_sym,[@reject])
@reject_success = model.send("#{association}").empty?
end
bash_prompt_command() {
local K="\[\033[0;30m\]" # black
local R="\[\033[0;31m\]" # red
local G="\[\033[0;32m\]" # green
local Y="\[\033[0;33m\]" # yellow
local B="\[\033[0;34m\]" # blue
local M="\[\033[0;35m\]" # magenta
local C="\[\033[0;36m\]" # cyan
local W="\[\033[0;37m\]" # white
local NONE="\[\033[0m\]"
@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",