This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var sys = require('child_process'); | |
function commandExists(cmd) { | |
var exists = false; | |
sys.exec(cmd, function(err) { | |
if(err === null) // of maybe: if(!err instanceof Error) | |
exists = true; | |
}); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# What the heck is this spec about? | |
# | |
# It's a gut-check that runs against every controller in the application. | |
# It is NOT a replacement for writing controller specs for each controller. | |
# | |
# What this does is things like check to make sure you didn't forget to lock | |
# down the index action of a controller to authorized users, checks to see if | |
# common routes are throwing silly errors, etc. | |
# | |
# Your controller passing these tests does not guarantee that it is healthy. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'faraday' | |
class WordpressController < ApplicationController | |
@@wp_client = Faraday.new(url: "http://#{ENV['WP_DOMAIN']}") do |builder| | |
builder.adapter Faraday.default_adapter | |
builder.headers = {'Content-Type' => 'application/json'} | |
builder.request :url_encoded | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require File.expand_path('../boot', __FILE__) | |
require 'rails/all' | |
# Require the gems listed in Gemfile, including any gems | |
# you've limited to :test, :development, or :production. | |
Bundler.require(*Rails.groups) | |
module MyProject | |
class Application < Rails::Application |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Stupid JavaScript and console tricks. | |
// Trap and record console things and errors. | |
function MosquitoNet() {} | |
MosquitoNet.history = []; | |
MosquitoNet.writeHistory = function(type, args) { | |
MosquitoNet.history.push({ type: type, args: args }); | |
} | |
MosquitoNet.shadowConsoleFunction = function(name) { | |
var oldFn = console[name]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = function(schema, options) { | |
schema.method('addUniqueRef', function(field, item) { | |
if(this[field].indexOf(item) < 0) this[field].push(item); | |
}); | |
schema.method('removeUniqueRef', function(field, item) { | |
this[field].splice(this[field].indexOf(item)); | |
}); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This plug takes HTML requests, forwards them to our controllers as JSON | |
# requests, takes the resulting JSON and POSTs it to a rendering service, | |
# then transforms the response back into HTML using the output from the | |
# rendering service. | |
# | |
# Which means we can write our probably-JavaScript/React view layer | |
# independently of Phoenix tooling. | |
defmodule ServiceRenderer do | |
# Base URL of render service goes here. | |
def init(url) do |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict' | |
const reactDocs = require('react-docgen') | |
const dir = require('node-dir') | |
export default function walkReactComponentFiles(path, pattern, handleFilename, done) { | |
const iterator = function(error, content, filename, next) { | |
if(error) { | |
throw error | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, {Component, PropTypes, Children, createElement} from 'react' | |
const CONTEXT_NAME = '__uniqueIDFunction__' | |
const CONTEXT_TYPES = {} | |
CONTEXT_TYPES[CONTEXT_NAME] = PropTypes.func | |
function createUniqueIDFunction() { | |
let counter = 0 | |
return function() { | |
return ++counter |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, {Component, Children} from 'react' | |
import {connect} from 'react-redux' | |
const MODAL_CHANGE = 'MODAL_CHANGE' | |
// Maintain a single active modal identifier | |
export function modalReducer(state = {activeModalId: null}, {type, id}) { | |
if(type !== MODAL_CHANGE) { | |
return state | |
} |