Skip to content

Instantly share code, notes, and snippets.

View cramhead's full-sized avatar

Marc d'Entremont cramhead

  • Squamish, BC, Canada
View GitHub Profile
"webpack": "webpack --mode development"
"scripts": {
"dev": "nodemon src/server.js --exec babel-node",
"webpack": "webpack"
},
"scripts": {
"dev": "nodemon src/index.js --exec babel-node"
}
{
"presets": [
"env"
]
}
@cramhead
cramhead / Procfile
Created April 3, 2018 00:00
Starts a webserver and points the node process running our main.js
web: node dist/main.js
@cramhead
cramhead / Index.js
Created April 2, 2018 15:09
Index.js file without cors
import express from 'express'
const PORT = process.env.PORT || 3000
const app = express();
app.use('/', (req, res) => {
res.send(`Server says ${(new Date).toString()}`)
})
@cramhead
cramhead / index.js
Created April 1, 2018 22:52
Index.js file with cors enabled
import express from 'express'
import cors from 'cors'
const PORT = process.env.PORT || 3000
const app = express();
app.use('*', cors()) // todo: Add more restrictions
@cramhead
cramhead / .gitignore
Created April 1, 2018 22:22
A standard node.js git ignore file
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# Runtime data
pids
*.pid
@cramhead
cramhead / .sh
Created April 1, 2018 03:00
Apollo Curl example
curl \
-X POST \
-H "Content-Type: application/json" \
--data '{ "query": "{ posts { title } }" }' \
https://1jzxrj179.lp.gql.zone/graphql
@cramhead
cramhead / gist:b6b3935309a440b0a7b370ba7f38a034
Created October 16, 2017 16:07
Infinitely interate over array
public class WhatEver {
private int[] _ids;
public WhatEver(string Ids){
_id = appContextIds.Split(',').Select(id => id.Trim()).Select(int.Parse).ToArray();
}
public IEnumerable<int?> NextId()
{
var etor = _ids.GetEnumerator();