Skip to content

Instantly share code, notes, and snippets.

View bethesque's full-sized avatar
💭
Intermittently coding

Beth Skurrie bethesque

💭
Intermittently coding
View GitHub Profile
// attribution: http://stackoverflow.com/a/15281070/32453
// you can compile this with gcc [mingw or mingw-w64] and probably other compilers as well
#include <stdlib.h> // NULL
#include <stdbool.h> // false
#include <windows.h> // AttachConsole, CTRL_C_EVENT, etc.
#include <stdio.h> // printf
#include <strsafe.h>
void logLastError()
@bethesque
bethesque / 1.sh
Last active July 10, 2018 06:56
HTTP requests to ruby mock server
You will need ruby or the standalone mock service to run these examples.
$ gem install pact-mock_service
@bethesque
bethesque / thoughts.md
Last active January 1, 2016 04:29
Thoughts on flexible matching for Pact

Assumptions based on experience with pacts so for:

  • The most common type of matching that is useful is asserting that:
    • The expected keys are present
    • The values at the actual keys are of the same class (string/number/nil) as the expected values
    • Occasionally we'll want a literal match
    • Occasionally we'll want a regular expresssion
    • Extra keys in a hash are OK for responses but not for requests (following the "be strict with what you send out, be lax with what you accept" principle)
    • Extra items in an array are debatable (extra keys in a hash are generally ignored, however, all items in an array are generally processed, so allowing "unverified" extras to sneak in could be a bad thing. Working out what to do with "extras" is not immediately obvious to me however.)
@bethesque
bethesque / flexible-matching.rb
Last active January 1, 2016 04:29
An idea of what a flexible matching fluent API might look like, and how it could be serialised.
# Notes:
# Headers and status would still be value based matching
# Default to type based matching???
# like(xxx) means xxx and all children would be matched using type based matching
# literal(xxx) means xxx and all children would be matched using exact value matching
# eg(generate, matcher) would be a regular expression match
# each_like([]) would indicate the each element in the array should be like the example given
# A like() could be nested inside a literal() which could be nested inside a like() - at each stage,
# it changes the matching type for all children until it gets switched back.
@jamiehodge
jamiehodge / webmachine.markdown
Last active May 7, 2020 22:21
Webmachine state machine and resource callbacks

Webmachine State Machine

General

  • Service available?
    • callback: service_available?
    • false: 503 Service Unavailable
  • Known method?
    • callback: known_methods
  • absent: 501 Not Implemented