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
const http = require('http'); | |
const server = http.createServer((req, res) => { | |
res.writeHead(200, { 'Content-Type': 'text/html; charset=utf-8' }); | |
/* | |
below is cool because the browser could download assets while we fetch data, | |
BUT there is a huge web breaking caveat, it seems we have to know the HTTP response code at this | |
moment in time. But we don't - what if there is a 500 during fetching? what happens if we actually need to 404? | |
Defaulting to 200 would lead to undesirable outcomes, especially with web scrapers and APM tooling. |
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
# delete flag means files that exist in the prod bucket but not in the staging | |
# bucket are deleted during sync | |
aws s3 sync s3://staging.mybucket.com s3://mybucket.com --delete --region eu-west-1 |
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
machine: | |
ruby: | |
version: 2.2.3 | |
dependencies: | |
pre: | |
- sudo pip install awscli | |
# gets verion 1.15 instead of 1.13.4 | |
- sudo apt-get update; sudo apt-get install wget |
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
# precomile the static assets the HTML pages link to such as the .js, .css and .jpg files | |
RAILS_ENV=production bundle exec rake assets:precompile | |
# circleci has RAILS_ENV & RACK_ENV env variables set to test need to override. -d runs | |
# the server as a daemon. | |
RAILS_ENV=production RACK_ENV=production bundle exec rails s -d | |
# wait for server to load | |
sleep 10 |
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
class PostIndex extends React.Component { | |
state = { loading: false }; | |
componentDidMount() { | |
window.onscroll = () => { | |
if (!this.state.loading | |
&& (window.innerHeight + window.scrollY) | |
>= document.body.offsetHeight) { | |
this.setState({loading: 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
import Post from './Post'; | |
class App extends React.Component { | |
render() { | |
return ( | |
<div> | |
<h1>Post list</h1> | |
<ul> | |
{this.props.posts.edges.map(edge => | |
<Post key={edge.node.id} post={edge.node} /> |
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
query FetchInceptionQuery { | |
movie(title: "Inception") { | |
title | |
director | |
actors | |
released | |
type | |
plot | |
poster | |
director |
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
query IntrospectionImdbNestedFieldsQuery { | |
__type(name: "Imdb") { | |
name | |
description | |
fields { | |
name | |
description | |
type { | |
name | |
kind |
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
query IntrospectionMovieNestedFieldsQuery { | |
__type(name: "Movie") { | |
name | |
description | |
fields { | |
name | |
description | |
type { | |
name | |
kind |
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
query IntrospectionQueryTypeQuery { | |
__schema { | |
queryType { | |
name | |
fields { | |
name | |
description | |
type { | |
name | |
kind |
NewerOlder