Skip to content

Instantly share code, notes, and snippets.

View antoniosmgatto's full-sized avatar
🏠
Working from home

Antonio Gatto antoniosmgatto

🏠
Working from home
View GitHub Profile
@stouset
stouset / LICENSE
Last active May 27, 2022 16:46
Best-practices based API key authentication
Copyright © 2021 Stephen Touset <stephen@touset.org>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SO
@kany
kany / rails6-actioncable-stimulus.md
Last active May 28, 2024 09:26
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.
@oshanz
oshanz / delayed_job@.service
Created January 6, 2020 12:59 — forked from stevensona/delayed_job@.service
systemd unit file for running ruby/rails delayed_job as service
# Keep delayed job workers running using systemd on ubuntu
# Usage
# Start "sudo systemctl start delayed_job@{0..3}" to start 4 worker instances
# Enable "sudo systemctl enable delayed_job@{0..3}" to enable 4 worker instances
# Restart "sudo systemctl restart delayed_job@{0..3}" to restart 4 worker instances
# Disable "sudo systemctl disable delayed_job@{0..3}" to disable 4 worker instances
# Stop "sudo systemctl stop delayed_job@{0..3}" to stop 4 worker instances
[Unit]
Description=Delayed Job Worker %i
@castwide
castwide / rails.rb
Last active April 27, 2024 08:54
Enhance Rails Intellisense in Solargraph
# The following comments fill some of the gaps in Solargraph's understanding of
# Rails apps. Since they're all in YARD, they get mapped in Solargraph but
# ignored at runtime.
#
# You can put this file anywhere in the project, as long as it gets included in
# the workspace maps. It's recommended that you keep it in a standalone file
# instead of pasting it into an existing one.
#
# @!parse
# class ActionController::Base
@coorasse
coorasse / bitbucket-pipelines.yml
Created September 13, 2018 08:46
Example of Bitbucket Pipeline for Ruby 2.5.1 + Webpacker + System Tests + Deployment to Elastic Beanstalk
image: circleci/ruby:2.5.1-node-browsers
pipelines:
default:
- step: &tests
name: Tests
caches:
- bundler
- node
services:
@vre2h
vre2h / normalize.md
Last active May 21, 2024 20:54
Simple guide to adding normalize.css to create-react-app
  1. Install normalize.css via npm
npm install --save normalize.css

1.1 Or yarn

yarn add normalize.css
@lorenadl
lorenadl / rails_download_active_storage_attachment.md
Last active January 10, 2023 01:04
[Rails] Download an Active Storage attachment
@kyledcline
kyledcline / postgres-best-practices.md
Last active October 26, 2023 06:10
Postgres Best Practices

PSQL CLI Client

Psql is a fully-fledged CLI client for Postgres, but most people are unaware of its many advanced features.

~/.psqlrc can be edited to persist any behavior or configuration settings you want between psql sessions. It behaves just like ~/.bashrc or ~/.vimrc, sourced at psql launch. See More out of psql for some interesting configurations.

If you have a long query to write and rewrite, you can use \e to edit your query in an editor.

Use \watch at the end of a query in order to automatically re-run the query every few seconds - great for monitoring while making changes elsewhere in your application architecture.

@baweaver
baweaver / ruby_books.md
Last active June 5, 2024 20:35
A list of books for learning and expanding on your Ruby knowledge.

Ruby Book List

Learning Ruby

You're taking your first steps into Ruby

A good introduction to programming in general. Easy on newer programmers.

@mihow
mihow / load_dotenv.sh
Last active June 11, 2024 05:15
Load environment variables from dotenv / .env file in Bash
if [ ! -f .env ]
then
export $(cat .env | xargs)
fi