Skip to content

Instantly share code, notes, and snippets.

View mikegehard's full-sized avatar

Mike Gehard mikegehard

  • VMware
  • Chattanooga, TN
  • 18:16 (UTC -04:00)
View GitHub Profile
@mikegehard
mikegehard / Setting longer HTTP timeout in capybara
Created April 15, 2011 19:20
Setting longer HTTP timeout in capybara
# We need this to fix the random timeout error that we were seeing in CI.
# May be related to: http://code.google.com/p/selenium/issues/detail?id=1439
Capybara.register_driver :selenium_with_long_timeout do |app|
client = Selenium::WebDriver::Remote::Http::Default.new
client.timeout = 120
Capybara::Driver::Selenium.new(app, :browser => :firefox, :http_client => client)
end
Capybara.javascript_driver = :selenium_with_long_timeout
[
{
"openapi": "3.0.1",
"info": {
"title": "Animal Rescue (from Gist)",
"description": "Sample application for Spring Cloud Gateway commercial product demos.",
"version": "1.0.0-K8s-hack"
},
"externalDocs": {
"url": "https://github.com/spring-cloud-services-samples/animal-rescue/"
@mikegehard
mikegehard / active_model_lint.rb
Created April 8, 2011 21:26 — forked from pairing/active_model_lint.rb
RSpec shared examples for ActiveModel::Lint
# adapted from rspec-rails http://github.com/rspec/rspec-rails/blob/master/spec/rspec/rails/mocks/mock_model_spec.rb
# put this in a file in your spec/support directory
# USAGE:
#
# let(:model) { ModelUnderTest.new(params) }
# it_behaves_like "ActiveModel"
shared_examples_for "ActiveModel" do
require 'test/unit/assertions'
require 'active_model/lint'
@mikegehard
mikegehard / gist:935825
Created April 22, 2011 01:13
Mocking fog for use with carrierwave
# drop this into a file in spec/support or feature/support and you should be all set.
unless Kernel.const_defined?("S3_CONFIG")
S3_CONFIG = YAML.load_file("#{Rails.root}/config/s3.yml")[Rails.env].try(:symbolize_keys)
end
Fog.mock!
connection = ::Fog::Storage.new(
:aws_access_key_id => S3_CONFIG[:access_key_id],
def apply(petRepository: PetRepository, contestResultRepository: ContestResultRepository, rules: Rules)
(pet1Id: UUID, pet2Id: UUID)
(implicit ec: ExecutionContext): Future[Either[String, UUID]] = {
val id = java.util.UUID.randomUUID
for {
pet1: Option[Pet] <- petRepository.find(pet1Id)
pet2: Option[Pet] <- petRepository.find(pet2Id)
// this is messy, try to change it to a more functional style at some point
@mikegehard
mikegehard / application.js
Last active December 22, 2016 13:43
Lineman questions
/* Exports an object that defines
* all of the configuration needed by the projects'
* depended-on grunt tasks.
*
* You can find the parent object in: node_modules/lineman/config/application.js
*/
module.exports = require('lineman').config.extend('application', {
appTasks: {
common: [
enum class EducationLevel {
HIGH_SCHOOL, BACHELORS, MASTERS, PHD
}
data class Person(val age: Int, val smoker: Boolean, val income: Int, val education: EducationLevel)
val people = listOf(
Person(19, false, 10000, EducationLevel.HIGH_SCHOOL),
Person(49, true, 120000, EducationLevel.BACHELORS),
Person(55, false, 400000, EducationLevel.MASTERS),
Books
TDD by Example
Extreme Programming Explained
Videos
http://vimeo.com/68375232
@mikegehard
mikegehard / Test File
Last active December 17, 2015 03:39
Test file and errors encountered when trying to run two browser based tests in the same Play test file.
package test.features
import org.specs2.mutable.Specification
import play.api.test.{Helpers, FakeApplication, WithBrowser}
import java.util.concurrent.TimeUnit
import play.api.db.DB
import slick.session.Database
import slick.jdbc.StaticQuery
import Database.threadLocalSession
import models.{BetaInvitationRequests, BetaInvitationRequest}
@mikegehard
mikegehard / code.scala
Created December 15, 2012 20:17
Problems with JSON API tests in Play2
object BetaInvitationRequestController extends Controller {
val successResponse = Map("success" -> true)
val betaInvitationRequestMapping = Forms.mapping(
"email" -> Forms.email
)(BetaInvitationRequest.apply)(BetaInvitationRequest.unapply)
val betaInvitationRequestForm = Form(betaInvitationRequestMapping)
def create = Action {