Skip to content

Instantly share code, notes, and snippets.

View goofballLogic's full-sized avatar
👔
Still counting things

Andrew Stewart Gibson goofballLogic

👔
Still counting things
  • 10:06 (UTC +01:00)
View GitHub Profile
@goofballLogic
goofballLogic / Jenkinsfile
Created September 14, 2016 19:36
Nested stages not working
stage('Clone from git') {
stage('test nested stages') {
sh 'pwd'
}
deleteDir()
}
@goofballLogic
goofballLogic / gist:61e4e7df3e7671b9ff66114a32c8ad9d
Last active September 26, 2016 16:28
Not sure that serialization "works"
> new RegExp( "/" )
/\//
> var x = new RegExp( "/" )
undefined
> x.test( "/hello" )
true
> var y = new RegExp( x.toString() )
undefined
> y.test( "/hello" )
false
/*eslint-env node*/
/*
This class is for:
1. Creating Authentication HTTP headers
2. Creating Accept-Language headers
3. Sending a HTTP request
@goofballLogic
goofballLogic / create-react-app.md
Last active May 9, 2018 22:03
Bog standard create-react-app

We're assuming you already have node.js installed

1. Install the create-react-app package:

npm install -g create-react-app

2. Create an application:

1. Add the People component:

class People extends Component {
  constructor() {
    super();
    this.state = { people: [] };
    this.callAPI();
  }
 callAPI() {

Add a person details component (with children)

const PersonDetails = ( { person, children } ) => <div className="person-details">

  <p className="name">{person.name} {person.surname}</p>
  <p><span className="label">Region</span>{person.region}</p>
  <img src={person.photo} />
  {children}

Create a folder named "routes", and one named "middleware"

api
   middleware                        <---
   node_modules
   routes                            <---
   .gitignore
   index.js
 package-lock.json

Having dived a bit deeper, I'm concluding that there are some design decisions which need to be made here.

For a normal scenario like:

Feature: my feature
 Scenario: my scenario
  Given step 1
  When step 2
  Then step 3
function sendJSON( method, data, url ) {
return fetch( url, {
body: data && JSON.stringify( data ),
method: "POST",
mode: "cors",
headers: {
"Content-Type": "application/json"
fetchForLater().then( resp => {
if ( !resp.ok ) { throw new Error( "Failed to fetch for later people" ); }
return resp.json();
} ).then( json => {
const savedForLater = json.map( ( [ id, person ] ) => person );
this.setState( { saved: savedForLater } );