Skip to content

Instantly share code, notes, and snippets.

View Merovex's full-sized avatar

Ben W Merovex

  • Gainfully Employed
  • In a hidden bunker under a non-descript building
  • 22:20 (UTC -04:00)
View GitHub Profile
@Merovex
Merovex / slug.rb
Created August 21, 2022 14:58
Create random slug
# frozen_string_literal: true
module Slug
extend ActiveSupport::Concern
def self.included(base)
base.extend ClassMethods
base.before_create :set_slug
end
def to_param
zucchini zoology zoologist zoo zone zombie zither zipper zinc ziggurat zero zephyr zen zebrafish zebra zampone yurt yoyo youth yourself youngster young yolk yoke yogurt yoga yin yew yesterday yellowjacket yellow yeast year yawl yarn yarmulke yard yang yam yak yahoo yacht xylophone wrong writing writer wrist wrinkle wriggler wrestler wrench wren wrecker wreck wrapping wrapper wraparound wrap wound worth worshiper worship worry worm world workshop workplace workout working workhorse workforce worker workbench work wording word woolens wool woodwind woodshed woodland woodchuck wood wont wonder wombat woman wolf wok witness withdrawal witchhunt witch wit wisteria wish wiseguy wisdom wiring wiretap wire winter winner wink wingtip wingman wing winery wine windshield windscreen window windchime windage wind win willow willingness will wildlife wildflower wilderness wildebeest wild wife width widow widget wick whorl wholesaler wholesale whole white whistle whisper whiskey whisker whirlwind whirlpool whip whey whelp w
@Merovex
Merovex / Gemfile
Created January 24, 2021 04:02 — forked from dhh/Gemfile
HEY's Gemfile
ruby '2.7.1'
gem 'rails', github: 'rails/rails'
gem 'tzinfo-data', '>= 1.2016.7' # Don't rely on OSX/Linux timezone data
# Action Text
gem 'actiontext', github: 'basecamp/actiontext', ref: 'okra'
gem 'okra', github: 'basecamp/okra'
# Drivers
@Merovex
Merovex / Gemfile
Created January 24, 2021 04:02 — forked from dhh/Gemfile
HEY's Gemfile
ruby '2.7.1'
gem 'rails', github: 'rails/rails'
gem 'tzinfo-data', '>= 1.2016.7' # Don't rely on OSX/Linux timezone data
# Action Text
gem 'actiontext', github: 'basecamp/actiontext', ref: 'okra'
gem 'okra', github: 'basecamp/okra'
# Drivers
CREATE TABLE `states` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
`code` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=53 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
@Merovex
Merovex / font-family-serif.scss
Last active September 30, 2020 11:48
Baseline the Serif font to the OS defaults, similar to what is used in Bootstrap's Reboot (same mix seen in dozens of websites using serif in body.
// font-family: Cambria, Georgia, "Times New Roman", Times, serif;
// Noto Serif found on modern Android and many Linux distros.
// Times is Mac OS
// Georgia is a classic serif font that I have seen leading this everywhere.
$font-family-sans-serif: Cambria, Georgia, "Noto Serif", "Times New Roman", Times, serif;
@function pow($base, $exponents) {
$raised: 1;
@for $i from 1 through $exponents {
$raised: $raised * $base;
}
@return $raised;
}
@function luma($color){
// Thanks voxpelli for a very concise implementation of luminance measure in sass
// Adapted from: https://gist.github.com/voxpelli/6304812
@Merovex
Merovex / create_toc.rb
Created August 2, 2020 14:36
Ruby Table of Contents generator for Markdown file in 6 lines
puts "\nCreating Table of Contents"
# This TOC generator assumes you don't care to include the page header
toc = "## Contents\n\n" + content.scan(/^##\s?(.*)\n/iu).flatten.map do |header|
next if header == 'Contents'
indent = " " * header.count("#")
anchor = header.downcase.gsub(/\W+/,'-').chomp('-')
"%s* [%s](#%s)\n" % [indent,header,anchor]
end.join
{
"extensions.showRecommendationsOnlyOnDemand": true,
"editor.tabSize": 2,
"editor.renderWhitespace": "boundary",
"editor.wordWrap": "wordWrapColumn",
"editor.mouseWheelZoom": true,
"editor.tabCompletion": "on",
"editor.fontFamily": "'Fira Code', Consolas, 'Courier New', monospace",
"editor.fontSize": 16,
"editor.fontWeight": "400",
export default function parseToMarkdown(chunk) {
let children = !chunk.type
? chunk.text
: chunk.children.map(c => parseToMarkdown({ ...c, parentType: chunk.type })).join('');
if (children === '') return;
// formatting
if (chunk.bold) {
children = `**${children.trim()}** `;