Skip to content

Instantly share code, notes, and snippets.

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

Alejandro Ventura alexventuraio

🏠
Working from home
View GitHub Profile
@vilusa
vilusa / environment.rb
Created September 3, 2021 18:56
Rails Redis Cache Configuration
# For TLS Connections
config.cache_store = :redis_cache_store, {
url: ENV.fetch('CACHE_STORE_REDIS_TLS_URL') { ENV['CACHE_STORE_REDIS_URL'] || 'redis://127.0.0.1:6379' },
db: 0,
connect_timeout: 20, # Defaults to 20 seconds
read_timeout: 1, # Defaults to 1 second
write_timeout: 1, # Defaults to 1 second
reconnect_delay: 1.5 ,
reconnect_delay_max: 10.0,
reconnect_attempts: 10, # Defaults to 0
@joeytwiddle
joeytwiddle / async-await-forEach-alternatives.md
Last active April 22, 2024 15:24
Do not use forEach with async-await

Do not use forEach with async-await

TLDR: Use for...of instead of forEach() in asynchronous code.

For legacy browsers, use for...i or [].reduce()

To execute the promises in parallel, use Promise.all([].map(...))

The problem

@dommmel
dommmel / blob_authenticatable.rb
Last active July 12, 2023 01:01
Devise authentication for Rails' ActiveStorage
# Rails controller concern to enable Devise authentication for ActiveStorage.
# Put it in +app/controllers/concerns/blob_authenticatable.rb+ and include it when overriding
# +ActiveStorage::BlobsController+ and +ActiveStorage::RepresentationsController+.
#
# Optional configuration:
#
# Set the model that includes devise's database_authenticatable.
# Defaults to Devise.default_scope which defaults to the first
# devise role declared in your routes (usually :user)
#
@andyyou
andyyou / rails_webpacker_bootstrap_expose_jquery.md
Last active August 9, 2022 07:38
Rails 5.2 with webpacker, bootstrap, stimulus starter

Rails 5.2 with webpacker, bootstrap, stimulus starter

This gist will collects all issues we solved with Rails 5.2 and Webpacker

Create Project

# Last few parameters(--skip-* part) is only my habbit not actully required
$ rails new <project_name> --webpack=stimulus --database=postgresql --skip-coffee --skip-test
@hew
hew / _readme.md
Last active June 10, 2022 19:13
Operator Mono w/ Italics on OSX VIm

Operator Mono w/ Italics on OSX Vim

codigo = " p 'hello world' "
pp Ripper.lex(codigo) # Paso 1, Tokenizacion
# [[[1, 0], :on_sp, " "],
# [[1, 1], :on_ident, "p"],
# [[1, 2], :on_sp, " "],
# [[1, 3], :on_tstring_beg, "'"],
# [[1, 4], :on_tstring_content, "hello world"],
# [[1, 15], :on_tstring_end, "'"],
@HenderOrlando
HenderOrlando / Place.js
Created April 6, 2016 00:00 — forked from PascalAnimateur/Place.js
Geospatial example in Sails.js using native MongoDB query
/* Place model */
module.exports = {
attributes: {
name: {
type: 'string',
required: true
},
@maxivak
maxivak / readme.md
Last active December 26, 2021 00:48
Rails. Skip the authenticity token check if its a json request

skip the authenticity token check for a json request

if you got this error while requesting the application via JSON request:

exception ActionController::InvalidAuthenticityToken

backtrace":"[\"/home/uadmin/.rvm/gems/ruby-2.1.7/gems/actionpack-4.2.4/lib/action_controller/metal/request_forgery_protection.rb:181:in `handle_unverified_request'\", 
\"/home/uadmin/.rvm/gems/ruby-2.1.7/gems/actionpack-4.2.4/lib/action_controller/metal/request_forgery_protection.rb:209:in `handle_unverified_request'\", 
...
@SteveBenner
SteveBenner / pry-cheatsheet.md
Last active April 23, 2022 18:28 — forked from lfender6445/gist:9919357
Pry cheat sheet

Pry Cheat Sheet

Youtube Tutorial (2013)

Command Line

  • pry -r ./config/app_init_file.rb -- load your app into a pry session (look at the file loaded by config.ru)
  • pry -r ./config/environment.rb -- load your rails into a pry session

Debugger