Skip to content

Instantly share code, notes, and snippets.

View supairish's full-sized avatar
🏂
Shreddin

Chris Irish supairish

🏂
Shreddin
View GitHub Profile
@AlexB52
AlexB52 / uniquely_generated_code.rb
Last active March 8, 2024 05:32
How to secure a unique random code in Rails without hitting a race condition
# Made as an answer to the question is rails forums
# https://discuss.rubyonrails.org/t/how-would-you-handle-gracefully-validating-a-generated-unique-code-until-its-guaranteed-to-be-valid/84919/9
require "bundler/inline"
gemfile(true) do
source "https://rubygems.org"
gem "rails"
gem "sqlite3"
@palkan
palkan / example.rb
Created August 16, 2022 19:33
pattern_matching_joe.rb
require 'active_support/core_ext/hash/indifferent_access'
def send_admin_notification(changes = previous_changes)
case changes
in ends_at: [Time, _]
:resubscribed
in ends_at: [nil, Time]
:churned
in processor_plan: [nil, String]
:subscribed
@bigtiger
bigtiger / image_processing-on-heroku.md
Last active December 2, 2022 00:21
How We Deployed Image Processing to Heroku in Support of a Rails 6 Application

How We Deployed Image Processing to Heroku in Support of a Rails 6 Application

Our app was already deployed and working on Heroku with MiniMagick. There were a few features of Image Processing that were appealing, performance and autorotation, and it appeared to be a straightforward swap.

Locally, we had run brew install vips on our MacBooks to get it running. That was early in the process and a detail long forgotten. When I deployed to Heroku @juliancheal pointed out that the staging environment was failing with an ActiveSupport::MessageVerifier::InvalidSignature error.

We were able to quickly identify the missing libvips dependency.

Figuring out how to install libvips to support rubyvips to support Image Processing was not trivial and therefore this guidepost exists.

@besrabasant
besrabasant / about.md
Last active March 3, 2023 06:48
Submitting Forms with Turbolinks ( tested with Laravel );
@jay-snee
jay-snee / run-rspec.yml
Created March 11, 2020 20:03
GitHub Actions workflow to install Ruby/Redis/Postgresql, build a Ruby app (with gem cache) and then run then Rspec with final step to merge onto 'deploy' branch upon successful completion.
name: run rspec
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
build:
@souzagab
souzagab / OpenSSL-Fix.md
Last active December 24, 2023 06:26
Install OpenSSL 1.0.2 via Homebrew ( Fix for older Ruby Versions )

How to fix openSSL incompatibility issues in older Ruby Versions. (<=2.3)

Homebrew

Install openssl 1.0.2 via homebrew :

brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/64555220bfbf4a25598523c2e4d3a232560eaad7/Formula/openssl.rb -f

This should install openssl in /usr/local/opt/openssl

If you already have 1.1 installed, you should have 2 versions of opensll in: /user/local/opt/

@inopinatus
inopinatus / variant.rb
Last active March 22, 2022 00:30
Validating uniqueness of an association record with external scope
# frozen_string_literal: true
require "bundler/inline"
gemfile(true) do
source "https://rubygems.org"
gem "rails", "6.0.0"
gem "sqlite3"
gem "pry"
end
@lazaronixon
lazaronixon / dropzone_controller.js
Last active March 9, 2024 05:14
Dropzone.js + Stimulus + Active Storage
import { Controller } from "stimulus"
import { DirectUpload } from "@rails/activestorage"
import Dropzone from "dropzone"
import { getMetaValue, findElement, removeElement, insertAfter } from "helpers"
Dropzone.autoDiscover = false
export default class extends Controller {
static targets = [ "input" ]
require 'bundler/inline'
gemfile do
source 'https://rubygems.org'
gem 'selenium-webdriver', '3.142.3'
gem 'webdrivers'
gem 'capybara', '3.28.0'
gem 'byebug'
end
@Mangara
Mangara / activerecord_executable_test_32940.rb
Created May 20, 2018 21:04
Executable test for Rails issue #32940
# frozen_string_literal: true
begin
require "bundler/inline"
rescue LoadError => e
$stderr.puts "Bundler version 1.10 or later is required. Please update your Bundler"
raise e
end
gemfile(true) do