Skip to content

Instantly share code, notes, and snippets.

View kany's full-sized avatar

Frank Kany kany

  • Rickman, TN
View GitHub Profile
@kany
kany / rails6-actioncable-stimulus.md
Last active February 2, 2024 22:18
Rails 6 + ActionCable + Stimulus example for pushing updates to the view.

Rails 6 + ActionCable + Stimulus example for pushing updates to the view.

This example will show how to push updates to the view for a Model instance that has changed without the user having to refresh the page.

This example focuses more on getting ActionCable working with Stimulus. If you don't already have stimulus setup in your app, here's a great write up on how to set it up: https://medium.com/better-programming/how-to-add-stimulus-js-to-a-rails-6-application-4201837785f9

Example scenario

  • You have a Scan model with attributes.
  • You have a ScanController#show action.
  • A user is viewing a Scan through the show.html.slim|haml|erb view template.
@kany
kany / sendmail_setup.md
Last active September 22, 2023 00:16
Setup SENDMAIL on Mac OSX Yosemite
@kany
kany / rails-6-send-mail-from-the-console.md
Last active August 28, 2023 17:38
Rails 6 - Sending mail from the console (As of April 2021)

1) Create a new gmail account for testing

3) Update config/environments/development.rb

  config.action_mailer.default_url_options = {host: "localhost", port: 3000}
  config.action_mailer.delivery_method = :smtp
  config.action_mailer.raise_delivery_errors = true
@kany
kany / gist:3714996
Created September 13, 2012 15:14
Git Repo changes ssh fingerprint - how to update your known_hosts file
1) Open known_hosts file and look for the invalid host
nano ~/.ssh/known_hosts
2) Remove the line that has the invalid host. Should be the same host in your .git/config of your repo
ssh-keygen -R [dev.blahblah.com]:1234
3) Pull from repo
git pull
4) You should see something similar to this. Answer 'yes' when asked.
@kany
kany / index.txt
Created December 30, 2015 17:09 — forked from gus/index.txt
Ruby/Clojure analogs
For each Ruby module/class, we have Ruby methods on the left and the equivalent
Clojure functions and/or relevant notes are on the right.
For clojure functions, symbols indicate existing method definitions, in the
clojure namespace if none is explicitly given. clojure.contrib.*/* functions can
be obtained from http://github.com/kevinoneill/clojure-contrib/tree/master,
ruby-to-clojure.*/* functions can be obtained from the source files in this
gist.
If no method symbol is given, we use the following notation:
@kany
kany / Azure-SDK-for-Go-and-Azure-REST-API.md
Last active July 7, 2022 13:38
Azure SDK for Go and Azure REST API

Azure SDK for Go and Azure REST API examples

This document details how to create credentials to use when making Azure REST API calls or when using the Azure SDK for Go.

I created this gist because my Golang app was returning empty results and when using the REST API I would see this error message:

{
    "error": {
        "code": "AuthorizationFailed",
        "message": "The client '3c470957-xxxxxx' with object id '3c470957-xxxxxx' does not have authorization to perform action 'Microsoft.Resources/resources/read' over scope '/subscriptions/3dcd5fea-zzzzzz' or the scope is invalid. If access was recently granted, please refresh your credentials."
 }
@kany
kany / redis-resque-stuff.md
Last active June 28, 2022 05:33
Clearing dead/stuck/zombie Resque workers redis resque delayed_job

$ rails c

Loading development environment (Rails 3.1.3)
1.9.3p0 :002 > Resque::Worker.working.each{|w| w.done_working}

$ redis-cli

# Removes data from your connection's CURRENT database.
@kany
kany / delete-old-git-branches.md
Last active February 9, 2022 15:29
Delete old git branches

Delete old git branches

This will delete all branches except for main and feature/foo-bar.

git branch -D `git branch | grep -vE 'main|feature/foo-bar'`

This will delete all branches except for master and branches that begin with kany/SAVE, and kany/hack.

@kany
kany / pagination_controller.js
Created June 4, 2021 15:18 — forked from dhh/pagination_controller.js
HEY's Stimulus Pagination Controller
/*
ERB template chunk from The Feed's display of emails:
<section class="postings postings--feed-style" id="postings"
data-controller="pagination" data-pagination-root-margin-value="40px">
<%= render partial: "postings/snippet", collection: @page.records, as: :posting, cached: true %>
<%= link_to(spinner_tag, url_for(page: @page.next_param),
class: "pagination-link", data: { pagination_target: "nextPageLink", preload: @page.first? }) unless @page.last? %>
</section>
@kany
kany / Stripe-Webhooks-Rails-6.md
Created April 22, 2021 21:22
Testing Stripe Webhooks + Rails 6 on your local machine

Testing Stripe Webhooks + Rails 6 on your local machine

The document describes how to test Stripe Webhooks with Ruby On Rails on your local machine. Information in this document is current as of 4/22/2021.

  • Rails 6.1.3.1
  • Ruby 2.7.3p183
  • Stripe 1.5.14