Skip to content

Instantly share code, notes, and snippets.

View dpickett's full-sized avatar

Dan Pickett dpickett

View GitHub Profile
View app_controllers_multtenant_behaviors.rb
module MultitenantBehaviors
def current_company
if request.subdomain && request.subdomain != 'www'
# assumes a `subdomain` string field on the Company class / table
@current_company ||= Company.find_by(subdomain: request.subdomain)
dpickett /
Created April 26, 2018 20:49
Fetch in Rails Config

Fetch in Rails Config

Once Rails is probably configured in our Rails application, we are not out of the jungle yet. We will also need to properly configure our applications such that our fetch requests communicate effectively with Rails. Let's briefly touch on these:

Rails Options

Rails has built in securities and config that make it very selective about the requests that are allowed to come in. We'll need to edit our controller configuration to allow fetch requests and their json formats so that we can respond accordingly.

View weather.html
<!doctype html>
<html lang="en">
<meta charset="utf-8">
<!--[if lt IE 9]>
<script src=""></script>
View officiant.rb
require 'date'
class Officiant
def authorized?
is_minister_of_the_gospel? || willing_to_get_ordained_online?
def available?(date)
!not_really_interested && !busy?(date) && !generally_too_busy
View main.js
let React = require('react')
let ReactDOM = require('react-dom')
var Hello = React.createClass({
getInitialState: function(){
return {
updateName: function(event){
View simple-widget.js
var Hello = React.createClass({
getInitialState: function(){
return {
updateName: function(event){
View webpack.config.js
var webpack = require('webpack');
var CopyWebpackPlugin = require('copy-webpack-plugin');
module.exports = {
entry: {
path: './src/main.js'
output: {
path: './build',
View long_string.rb
puts "Lorem ipsum dolor sit amet, consectetur adipisicing elit, " +
"sed do eiusmod tempor incididunt ut labore et dolore magna aliqua." +
"Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris"
View gist:e1b14fd602d50f6e21ff
# Path to your oh-my-zsh installation.
export ZSH=$HOME/.oh-my-zsh
# Set name of the theme to load.
# Look in ~/.oh-my-zsh/themes/
# Optionally, if you set this to "random", it'll load a random theme each
# time that oh-my-zsh is loaded.
# Uncomment the following line to use case-sensitive completion.
dpickett / player_pseudo.js
Last active August 29, 2015 14:03
View player_pseudo.js
function KeyHandler(){
//handy underscoreJS function
_.bindAll(this, 'handleUpKey', 'handleKey');
this.handleUp = function(e){
//we can use jQuery to trigger events on plain ol' JavaScript objects
this.handleKey = function(e){