Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am mcordell on github.
  • I am mikecordell (https://keybase.io/mikecordell) on keybase.
  • I have a public key whose fingerprint is DADF A5DF 31EF E467 BB7D 5AF8 C105 626C 25A8 C62C

To claim this, I am signing this object:

@mcordell
mcordell / mockGraphqlServer.js
Created August 19, 2018 18:35
Mock Graphql Server
const { ApolloServer, gql } = require('apollo-server');
import {
makeExecutableSchema,
addMockFunctionsToSchema,
MockList
} from 'graphql-tools';
import casual from 'casual'
// Construct a schema, using GraphQL schema language
module Global
def plugins
yield
end
def register(value)
@value = value
end
def value
module ROM
extend Global
plugins do
register :macros, ROM::ConfigurationPlugins::ConfigurationDSL, type: :configuration
register :registry_reader, ROM::Plugins::Relation::RegistryReader, type: :relation
register :schema, ROM::Plugins::Command::Schema, type: :command
end
end
@mcordell
mcordell / michaeltest
Created January 30, 2015 04:38
test robot
class Michael < RTanque::Bot::Brain
extend Forwardable
attr_accessor :next_radar_heading, :samples, :current_target, :current_search_area
def_delegator :sensors, :heading , :current_heading
def_delegator :sensors, :radar , :radar
NAME = 'Michael'
include RTanque::Bot::BrainHelper
@mcordell
mcordell / class_instance_vars.rb
Created August 1, 2013 17:58
Class Instance Variables in Ruby.
class ClassVarTest
@variable = "Class Variable"
def self.get_class_variable
@variable
end
def get_object_variable
@variable
end
@mcordell
mcordell / gist:5282288
Last active December 15, 2015 15:29
Nutrient has_many Recommendation. Recommendation belongs_to Nutrient. Is this the proper way to find and set the nutrient/recommendation relationship as a recommendation is created?
def create
nutrient_id = params[:recommendation][:nutrient_id]
if nutrient_id.blank?
#nutrient_id was blank in the submit, get other recommendation params and re-render 'new'
params[:recommendation].delete(:nutrient_id)
@recommendation=Recommendation.new(params[:recommendation])
render 'new'
else
@nutrient = Nutrient.find(nutrient_id)
if @nutrient