Skip to content

Instantly share code, notes, and snippets.

View MyklClason's full-sized avatar

Mykl Clason MyklClason

  • Wisconsin, United States
View GitHub Profile
@MyklClason
MyklClason / select2.html.erb
Last active July 23, 2022 22:56
select2 scripts
<script>
$(document).on('turbolinks:before-cache', function(e) {
$('.form-control.select2, .form-control.select2-taggable, .form-control.select2-w-100').each(function() {
if ($(this).data('select2')) {
$(this).select2('destroy');
}
});
});
$('.form-control.select2, .form-control.select2-taggable, .form-control.select2-w-100').each(function() {
@MyklClason
MyklClason / pretty_helper.rb
Last active March 20, 2022 00:44
Pretty Helper
module PrettyHelper
def pretty_boolean(boolean)
boolean ? "Yes" : "No"
end
def pretty_array(array, seperator: ";")
array.to_a.join("; ")
end
def pretty_linked_record_array(array, field, new_window: true)
@MyklClason
MyklClason / bootstrap_nav_helper.rb
Last active July 29, 2022 04:59
Bootstrap Nav Helper (Bootstrap 4/5)
module BootstrapNavHelper
def navbar_text(nav_text)
content_tag :span, class: "navbar_text" do
nav_text
end
end
def navbar_link_to(nav_text, nav_path, link_options = {})
is_active = current_page?(nav_path)
link_options[:class] = "#{link_options[:class]} nav-link"
@MyklClason
MyklClason / .erb-lint.yml
Last active February 1, 2023 23:44
Code Quality Config. Copy the files
# https://github.com/Shopify/erb-lint
linters:
DeprecatedClasses:
enabled: true
FinalNewline:
enabled: true
ErbSafety:
enabled: true
exclude:
- '**/node_modules/**'
@MyklClason
MyklClason / handlebars_render.js
Last active September 25, 2019 23:23
Handlebars/Mustache helpers
/* global $, HandlebarsTemplates */
// For use with https://github.com/leshill/handlebars_assets
function renderTemplate(template, context) {
return HandlebarsTemplates[template](context)
}
function renderTemplateAt(query, template, context) {
return (
$(query).html(
renderTemplate(template, context)
// Note: Must use `var self = this` to access stuff within the success/error functions
Rails.ajax({
url: action_path,
type: "PATCH",
data: $.param(data),
dataType: 'script',
processData: false,
contentType: false,
success: function(data) { },
error: function(data) { }
@MyklClason
MyklClason / graph.rb
Last active December 20, 2023 05:00
Basic graph utility functions class (Ruby)
# This is a very simple hash based graph utility class.
# By Mykl Clason
# https://gist.github.com/MyklClason/fe603a6005a1dedc6ec65fda7ff47f68
class Graph
def self.undirected_graph_from_edges(edges)
# Edges are (a,b) pairs with a => b and b => a relationships.
edges.each_with_object(Hash.new { |h, k| h[k] = Set.new }) { |(k, v), h| h[k] << v }
end
def self.directed_graph_from_edges(edges)
@MyklClason
MyklClason / stimulusjs.md
Last active July 21, 2019 22:03
Rails StimulusJS setup

Yarn

https://yarnpkg.com/lang/en/docs/install/#debian-stable

Run Commands

curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
sudo apt-get update && sudo apt-get install --no-install-recommends yarn
@MyklClason
MyklClason / rails_guide.md
Last active November 2, 2024 08:38
AWS Cloud9 Rails Setup Guide (and migration from c9.io) for Rails 7.1

Overview

Warning: This guide intended for Rails 6.1. (It may not be complete)

This is direction for Migration from c9.io to AWS Cloud9 or to simply setup AWS Cloud9 for Rails Development, after you follow the cloud9 migration directions and created a workspace, keeping in mind the Workspace settings Section below.

Be sure you are using the right version of rails. You may need to remove rails and rail-ties and install rails 6.1. Check online for how (search how to reinstall rails with a specific version)