Skip to content

Instantly share code, notes, and snippets.

View joeybeninghove's full-sized avatar

Joey Beninghove joeybeninghove

View GitHub Profile
@joeybeninghove
joeybeninghove / application.html.erb
Created February 9, 2018 03:58
app/views/layouts/application.html.erb
<!DOCTYPE html>
<html>
<head>
<title>App</title>
<%= csrf_meta_tags %>
<%= stylesheet_pack_tag "application", media: "all", "data-turbolinks-track": "reload" %>
<%= javascript_pack_tag "application", "data-turbolinks-track": "reload" %>
</head>
@joeybeninghove
joeybeninghove / environment.js
Created February 9, 2018 03:57
config/webpack/environment.js
const { environment } = require('@rails/webpacker')
const webpack = require('webpack')
environment.plugins.prepend(
'Provide',
new webpack.ProvidePlugin({
$: 'jquery',
jQuery: 'jquery',
jquery: 'jquery'
})
@joeybeninghove
joeybeninghove / content_security_policy.rb
Created February 9, 2018 03:57
config/initializers/content_security_policy.rb
# Define an application-wide content security policy
# For further information see the following documentation
# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy
Rails.application.config.content_security_policy do |p|
p.default_src :self, :https
p.font_src :self, :https, :data
p.img_src :self, :https, :data
p.object_src :none
p.script_src :self, :https
@joeybeninghove
joeybeninghove / .postcssrc.yml
Created February 9, 2018 03:56
.postcssrc.yml
plugins:
postcss-import: {}
postcss-cssnext: {}
tailwindcss: "./app/javascript/src/tailwind.js"
@joeybeninghove
joeybeninghove / application.css
Created February 9, 2018 03:56
app/javascript/src/application.css
@tailwind preflight;
@tailwind utilities;
@joeybeninghove
joeybeninghove / application.js
Created February 9, 2018 03:55
app/javascript/packs/application.js
import Rails from "rails-ujs"
Rails.start()
import * as ActiveStorage from "activestorage"
ActiveStorage.start()
import Turbolinks from "turbolinks"
Turbolinks.start()
import { Application } from "stimulus"
Hey Joey,
I’ve been looking into this a while and I’ve run into some blockers so it’s only half of a solution for now.
Here’s what you can do:
You need the IP that every container will see your computer as (what’s traditional 127.0.0.1). See IP of HOST available within site container? for instructions on how to get that. It’s as simple as running one command in Terminal.
Open Local and right-click on the site you want to connect to your Rails app
Click “Open Site SSH”
Enter nano /etc/hosts
/*! normalize.css v7.0.0 | MIT License | github.com/necolas/normalize.css */
/* Document
========================================================================== */
/**
* 1. Correct the line height in all browsers.
* 2. Prevent adjustments of font size after orientation changes in
* IE on Windows Phone and in iOS.
*/
@joeybeninghove
joeybeninghove / application.js
Created January 9, 2018 00:03
Rails 5.2 Webpacker Defaults
import Rails from "rails-ujs"
import Turbolinks from "rails-ujs"
import * as ActiveStorage from "activestorage"
Turbolinks.start()
ActiveStorage.start()
import '../src/application.css';
@joeybeninghove
joeybeninghove / notifier.rb
Created September 13, 2017 20:49
Tiny Pub/Sub in Ruby
class Notifier
attr_reader :events
def initialize
@events = {}
end
def subscribe(event, &handler)
@events[event] ||= []
@events[event] << handler