Skip to content

Instantly share code, notes, and snippets.

View eclectic-coding's full-sized avatar
🏠
Working from home

Chuck eclectic-coding

🏠
Working from home
View GitHub Profile
@eclectic-coding
eclectic-coding / toast_controller.js
Created March 15, 2023 12:03
Show Bootstrap 5 Toast from Stimulus controller
import { Controller } from "@hotwired/stimulus";
import * as bootstrap from "bootstrap";
export default class extends Controller {
connect() {
new bootstrap.Toast(this.element).show();
}
}
@eclectic-coding
eclectic-coding / sortingAlphabetically.js
Created March 15, 2022 15:22 — forked from Thaekeh/sortingAlphabetically.js
Sort arrays alphabetically
computed: {
sortedArray() {
let sortedRecipes = this.recipes;
sortedRecipes = sortedRecipes.sort((a,b) => {
let fa = a.title.toLowerCase(), fb = b.title.toLowerCase();
if (fa < fb) {
return -1
}
if (fa > fb) {
@eclectic-coding
eclectic-coding / _vue-rails.md
Created March 10, 2022 22:22 — forked from przbadu/_vue-rails.md
Vue js and Rails integration

Setup Rails and Vuejs

  1. Generate new rails app using --webpack flag
rails new myApp --webpack=vue

Note:

  1. You can use --webpack=angular for angular application and --webpack=react for react.
@eclectic-coding
eclectic-coding / for-loop-sorted-collection
Created April 7, 2021 11:52 — forked from Phlow/for-loop-sorted-collection
This Liquid loop for Jekyll sorts a collection by date in reverse order
{% comment %}
*
* This loop loops through a collection called `collection_name`
* and sorts it by the front matter variable `date` and than filters
* the collection with `reverse` in reverse order
*
* To make it work you first have to assign the data to a new string
* called `sorted`.
*
{% endcomment %}
@eclectic-coding
eclectic-coding / devise_hotwire_fix.md
Last active January 30, 2021 20:35
Devise fix for

Create new controllers

Add the following to the top of config/initializers/devise.rb:

class TurboFailureApp < Devise::FailureApp
  def respond
    if request_format == :turbo_stream
      redirect
    else
      super
    end
@eclectic-coding
eclectic-coding / stimulus.md
Created January 2, 2021 20:18 — forked from mrmartineau/stimulus.md
Stimulus cheatsheet
<?php
/**
* If the aria-label argument has been specified in a wp_dropdown_categories() call,
* output the aria-label option in the <select>
*
* @since 1.0.0
*
* @param string $output HTML Output
* @param array $arguments wp_dropdown_category() arguments
* @return string Modified HTML Output
@eclectic-coding
eclectic-coding / _flash_messages.html.erb
Created September 16, 2020 11:39 — forked from roberto/_flash_messages.html.erb
Rails flash messages using Twitter Bootstrap
<% flash.each do |type, message| %>
<div class="alert <%= bootstrap_class_for(type) %> fade in">
<button class="close" data-dismiss="alert">×</button>
<%= message %>
</div>
<% end %>
@eclectic-coding
eclectic-coding / gitconfig
Created August 3, 2020 13:23
Current gitconfig aliases
[alias]
co = checkout
cob = checkout -b
com = checkout master
br = branch
brd = branch -d
dmerged = "git branch --merged | grep -v '\\*' | xargs -n 1 git branch -d"
st = status -sb
aa = add -A .
cm = commit
@eclectic-coding
eclectic-coding / vim-cheats.md
Created August 2, 2020 14:11 — forked from Starefossen/vim-cheats.md
My vim cheat sheet for working with tabs and window splits.

Tabs

New Tab

  • :tabnew - new blank tab
  • :tabedit [file] - open file in tab

Cursor Movement

  • gt (:tabn) - next tab