Add a personal .gitignore
to a project.
Within the project
git config --local -e
[core]
... (existing configurations)
excludesfile = ~/Documents/my_repo/.john_gitignore
[remote "origin"]
Add a personal .gitignore
to a project.
Within the project
git config --local -e
[core]
... (existing configurations)
excludesfile = ~/Documents/my_repo/.john_gitignore
[remote "origin"]
<!doctype html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<link rel="stylesheet" href="main.css"> | |
<script src="bundle.js" async></script> | |
</head> | |
<body> | |
<div data-controller="toggler"> | |
<label>Toggle Me</label> |
Logs a timeout warning before unicorn kills the worker.
If something is running long enough for unicorn to want to kill it then its worth spending the time fixing. If the process is killed you will never know why it failed.
This will add a warning after 30 seconds and another one 1second before unicorn kills it.
It adds a middleware that sits on the Rack layer between Unicorn and Rails. It creates a timer Thread that sleeps for a set amount of time and if the current thread is still running then log a warning.
{ | |
"workbench.colorTheme": "Monokai", | |
"workbench.iconTheme": "city-lights-icons-vsc-light", | |
// Basic settings: turn linter(s) on | |
"ruby.lint": { | |
"rubocop": { | |
"lint": true, //enable all lint cops. | |
"only": [/* array: Run only the specified cop(s) and/or cops in the specified departments. */], | |
"except": [/* array: Run all cops enabled by configuration except the specified cop(s) and/or departments. */], | |
"forceExclusion": true, //Add --force-exclusion option |
# app/config/environments/development.rb | |
# Middleware to print to the screen so I can see the responses when streaming data | |
config.middleware.use( | |
Class.new do | |
def initialize(app) | |
@app = app | |
end | |
def call(env) |
# lib/google_map/directions.rb | |
# Calls the google maps directions api | |
# https://developers.google.com/maps/documentation/directions/intro | |
# Useage: | |
# gm = GoogleMap::Directions.new({origin: '52.662377,-8.630171', destination: '52.635720, -8.654714'}) | |
# gm.call | |
module GoogleMap | |
class Directions | |
include HTTParty | |
base_uri 'https://maps.googleapis.com/maps/api' |
# Rails side: | |
# 1. Attachment.rb model needs a token method that encrypts the model id. | |
class Attachment < ActiveRecord::Base | |
mount_uploader :file, AttachmentUploader | |
# Add this | |
def self.find_by_token(token) | |
begin | |
find(UrlParamEncryptor.decrypt(token)) |
My setup for configuring a Rails app with RSpec Feature tests that uses Capabara to test on a browserstack remote browser.
The browserstack docs only show either an RSpec or a Capabara setup.
What I wanted:
# spec/support/wait_for_ajax.rb | |
# # Angular, Rails, Capybara, wait for ajax | |
# Useage: | |
# click_link("Send an ajax request") | |
# wait_for_ajax | |
# expect(page).to have_content("expected ajax response message") | |
module WaitForAjax | |
def wait_for_ajax(max_wait_time = 30) | |
Timeout.timeout(max_wait_time) do | |
while pending_ajax_requests? |