Skip to content

Instantly share code, notes, and snippets.

View prdanelli's full-sized avatar
👋

Paul Danelli prdanelli

👋
View GitHub Profile
@prdanelli
prdanelli / ranger-cheatsheet.md
Created October 8, 2021 13:15 — forked from heroheman/ranger-cheatsheet.md
Ranger Cheatsheet

Ranger Cheatsheet

General

Shortcut Description
ranger Start Ranger
Q Quit Ranger
R Reload current directory
? Ranger Manpages / Shortcuts
@prdanelli
prdanelli / tmux_cheatsheet.markdown
Last active August 18, 2021 09:46 — forked from henrik/tmux_cheatsheet.markdown
tmux cheatsheet

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name:

@prdanelli
prdanelli / gist:a0dd4684022459e0d344bd0a4d6b4ec7
Last active February 1, 2022 13:44
Install PG Gem without installing Postgres locally

Install PG Gem without installing Postgres locally

The Problem

Installing the ruby PG gem requires Postgres to be instaled locally to install the gem, which is annoying and unnecessary if you're building inside of docker.

An error occurred while installing pg (1.2.3), and Bundler cannot continue.
Make sure that `gem install pg -v '1.2.3' --source 'https://rubygems.org/'` succeeds before bundling.
@prdanelli
prdanelli / popup.js
Created June 8, 2021 09:27
Popup Window
// $("a.popup").each(function() {
// new PopupWindow($(this))
// });
class PopupWindow {
constructor($target){
this.$target = $target
if (this.$target.length === 0) {
return
@prdanelli
prdanelli / gist:d4c5511ca4b38ff1c1211331228f6586
Created January 7, 2020 12:35
Send email from Rails Console.
options = {
to: "recipient@address.com",
from: "email@address.org",
subject: "Testing",
body: "This is the body"
}
ActionMailer::Base.mail(options).deliver_now
@prdanelli
prdanelli / gist:47ef0b4e4cc1f7f54bee8e8e629b03b7
Created November 15, 2019 19:19
Module, metaprogramming, dynamic instance/class method definition
# Usage:
# class YourClass < ApplicationRecord
# denormalizable_collection :my_collection
# ...
#
# def self.my_collection_data
# self.where(...).limit(5)
# end
# end
@prdanelli
prdanelli / gist:c2cce7c1403488917d16b3f3bbee9fe8
Last active February 1, 2022 13:57
Decorate class with extend/prepend

Decorate class with extend/prepend

Update indexed instance after blob analyzed

# app/jobs/active_storage/analyze_job_decorator.rb
module ActiveStorage::AnalyzeJobDecorator
  def self.prepended(base)
    base.around_perform do |job, block|
      block.call
@prdanelli
prdanelli / clear-sidekiq-jobs.rb
Last active May 21, 2021 09:48 — forked from wbotelhos/clear-sidekiq-jobs.sh
Clear Sidekiq Jobs
# Oneliner
require 'sidekiq/api'; [Sidekiq::Queue.all.each(&:clear), Sidekiq::ScheduledSet.new.clear, Sidekiq::RetrySet.new.clear, Sidekiq::DeadSet.
new.clear];
require 'sidekiq/api';
# 1. Clear retry set
Sidekiq::RetrySet.new.clear
# 2. Clear scheduled jobs
du -h --max-depth 1
@prdanelli
prdanelli / gist:76404ebacb88aced1cbf
Created May 7, 2015 19:34
Get rails sending through mandrill
#app/config/initializers/mailer.rb
ActionMailer::Base.smtp_settings = {
address: 'smtp.mandrillapp.com',
port: 587,
user_name: '<account email>',
password: '<api key>',
authentication: 'login'
}
ActionMailer::Base.delivery_method = :smtp