Skip to content

Instantly share code, notes, and snippets.

@n-studio
n-studio / DEPLOY_WITH_KAMAL_ON_DEDICATED_SERVER.md
Last active April 22, 2024 22:47
Deploy a web app on a dedicated server with Kamal

Warning

This gist is still a draft. At the moment it is not functional: see basecamp/kamal#257

Motivation

Kamal was designed with 1 service = 1 droplet/VPS in mind.
But I'm cheap and I want to be able to deploy multiple demo/poc apps apps on my $20/month dedicated server.
What the hell, I'll even host my private container registry on it.

@yfkhar
yfkhar / Spree: Filter by brand.md
Created June 13, 2022 19:47 — forked from vsokolov/Spree: Filter by brand.md
Spree: Filter Products by properties

Fix 'scoped' error for Rails 4

error: undefined method 'scoped' solution:

# config/initializers/scoped.rb
class ActiveRecord::Base
  # do things the modern way and silence Rails 4 deprecation warnings
 def self.scoped(options=nil)

options ? where(nil).apply_finder_options(options, true) : where(nil)

@sgarciav
sgarciav / pass.md
Last active April 21, 2024 19:22
Initialize your password store

About

Summarizing the instructions of the pass tool (as seen on its website).

Getting Started

Installation

Execute: $ sudo apt install pass

@dhh
dhh / Gemfile
Created June 24, 2020 22:23
HEY's Gemfile
ruby '2.7.1'
gem 'rails', github: 'rails/rails'
gem 'tzinfo-data', '>= 1.2016.7' # Don't rely on OSX/Linux timezone data
# Action Text
gem 'actiontext', github: 'basecamp/actiontext', ref: 'okra'
gem 'okra', github: 'basecamp/okra'
# Drivers
@strfry
strfry / README.md
Last active April 10, 2024 13:21
Deploys FreeBSD on a Hetzner cloud server

Deploys FreeBSD on a Hetzner cloud server

Prerequisites:

  • A Hetzner Cloud API Token (Pass in via APIKEY)
  • jq
  • sshpass

Usage

Replace server_id variable with your hetzner server Id
@simoleone
simoleone / shrine.rb
Created March 28, 2019 12:32
Configuring Shrine for mass-distribution with S3 and Cloudfront
require "shrine/storage/s3"
base_s3_options = {
access_key_id: Rails.application.credentials.dig(:aws, :access_key_id),
secret_access_key: Rails.application.credentials.dig(:aws, :secret_access_key),
region: 'us-east-1',
bucket: ENV['SHRINE_S3_BUCKET'],
}
cache_s3_options = base_s3_options.merge(
@tonyfg
tonyfg / log_response_time.rb
Created September 14, 2018 09:14
Log Rails request response time
# config/initializers/log_response_time.rb
event_logger = ::Logger.new("#{Rails.root}/log/response_times.log")
event_logger.formatter = proc { |_severity, _datetime, _progname, msg|
"#{msg}\n"
}
ActiveSupport::Notifications.subscribe('process_action.action_controller') do |_, started, finished, _, stats|
request_time = (finished - started) * 1000
controller = stats[:controller][0..-11].underscore
@mrmartineau
mrmartineau / stimulus.md
Last active April 19, 2024 09:41
Stimulus cheatsheet
@shivendra14
shivendra14 / Illustrator_Scale_Artboard_and_Artwork.jsx
Created September 17, 2017 14:19
Script to scale up Illustrator Assets
#target Illustrator
/*
Revision-1
Author: Shivendra Agarwal
Year: 2017
Title: Script to scale-up artwork and artboard above 15 Mpixel
*/
if ( app.documents.length > 0 )
alert("ERROR: \n Close all documents before running this script." );