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 / promiseCatchWithAwait.js
Created July 8, 2020 14:05 — forked from dbayarchyk/promiseCatchWithAwait.js
Async/await without try/catch in JavaScript
async function fetchAndUpdatePosts() {
const posts = await fetchPosts().catch(() => {
console.log('error in fetching posts');
});
if (posts) {
doSomethingWithPosts(posts);
}
}
@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
@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 / _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 %>
<?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 / stimulus.md
Created January 2, 2021 20:18 — forked from mrmartineau/stimulus.md
Stimulus cheatsheet
@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 / 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 / _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.