Skip to content

Instantly share code, notes, and snippets.

View prdanelli's full-sized avatar
👋

Paul Danelli prdanelli

👋
View GitHub Profile
@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: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 / 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 / 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 / gist:31970b099c31dfe3985e2a700073d019
Created October 12, 2021 08:42
Passenger development config for Docker
web:
<<: *app
environment:
<<: *web_environment
PASSENGER_STARTUP_FILE: "spec/internal_test_hyku/config.ru"
PASSENGER_ENGINE: "builtin"
PASSENGER_APP_TYPE: "rack"
PASSENGER_ADDRESS: "0.0.0.0"
PASSENGER_PORT: "3000"
PASSENGER_FRIENDLY_ERROR_PAGES: "true"
@prdanelli
prdanelli / config.rb
Created November 9, 2021 09:36
Create a configuration class
# Usage:
#
# Settings.configure do |c|
# c.foo = "biz"
# c.bar = "boo"
# end
# Test.config.foo
# => "biz"
# Test.configured?
@prdanelli
prdanelli / sentry data.rb
Created December 2, 2022 12:51
Log Extra data to Sentry
def my_method
# ...
rescue NoMethodError => e
Sentry.with_scope do |scope|
scope.set_tags(foo: "bar") # <= Searchable tags
scope.set_context('Model Attributes', @local_instance_variable.attributes) # <= Logs extra hash of data
Sentry.capture_message("A test message") # <= Your custom message
Sentry.capture_error(e) # <= Log the error
end
end
@prdanelli
prdanelli / gist:7b2d161281f517aa83845691ba220d0d
Last active March 10, 2023 11:15
Use FactoryBot methods inside Rails console

$ rails console -e test --sandbox

require 'factory_bot'; include FactoryBot::Syntax::Methods
require 'benchmark'
require 'dry-struct'
require 'ostruct'
require 'hashie'
require 'active_support'
class ClassCar
attr_accessor :wheels, :mileage
end
@prdanelli
prdanelli / block.rb
Last active March 23, 2023 22:07
Block / Class / Factory / Function processing
require 'nokogiri'
require 'uri'
require 'net/http'
require 'byebug'
require 'json'
# Block example
def requester(url, &block)
uri = URI(url)
res = Net::HTTP.get_response(uri)