const {PassThrough} = require('stream')
const fs = require('fs')
const d = new PassThrough()
fs.createReadStream('tt2.js').pipe(d) // can be piped from reaable stream
d.pipe(process.stdout) // can pipe to writable stream
d.on('data', console.log) // also like readableThis gist is based on the information available at golang/dep, only slightly more terse and annotated with a few notes and links primarily for my own personal benefit. It's public in case this information is helpful to anyone else as well.
I initially advocated Glide for my team and then, more recently, vndr. I've also taken the approach of exerting direct control over what goes into vendor/ in my Dockerfiles, and also work from
isolated GOPATH environments on my system per project to ensure that dependencies are explicitly found under vendor/.
At the end of the day, vendoring (and committing vendor/) is about being in control of your dependencies and being able to achieve reproducible builds. While you can achieve this manually, things that are nice to have in a vendoring tool include:
| # REQUIRES CHANGES TO LINES 37 AND 42 TO WORK FOR YOUR PROJECT | |
| # Use Dockerized infrastructure | |
| sudo: false | |
| # Use node_js environnement | |
| language: node_js | |
| node_js: | |
| - "6.9.1" | |
| # Cache Gcloud SDK between commands |
First, find the container that runs your MongoDB and ssh into it.
Then, find the collection you want to export:
mongo
show dbs
use <database>
show collections
exit| # Use Dockerized infrastructure | |
| sudo: false | |
| # Use node_js environnement | |
| language: node_js | |
| node_js: | |
| - "6" | |
| # Cache Gcloud SDK between commands | |
| cache: |
| /** | |
| * HTTP Cloud Function. | |
| * | |
| * @param {Object} req Cloud Function request context. | |
| * @param {Object} res Cloud Function response context. | |
| */ | |
| exports.accessLintJson = function accessLintJson (req, res) { | |
| var url = req.param("url"); | |
| var exec = require('child_process').exec; |
| fetch(`/api/search?${queryParams}`) | |
| .then(response => response.json()) | |
| .then(normalizeSearchResultsApiData) // the do-it-all data massager | |
| .then(normalData => { | |
| // dispatch normalData to the store here | |
| }); |
| // 🔥 Node 7.6 has async/await! Here is a quick run down on how async/await works | |
| const axios = require('axios'); // promised based requests - like fetch() | |
| function getCoffee() { | |
| return new Promise(resolve => { | |
| setTimeout(() => resolve('☕'), 2000); // it takes 2 seconds to make coffee | |
| }); | |
| } |
| var deadline = '2017-03-15'; | |
| function getTimeRemaining(endtime){ | |
| var t = Date.parse(endtime) - Date.parse(new Date()); | |
| var seconds = Math.floor( (t/1000) % 60 ); | |
| var minutes = Math.floor( (t/1000/60) % 60 ); | |
| var hours = Math.floor( (t/(1000*60*60)) % 24 ); | |
| var days = Math.floor( t/(1000*60*60*24) ); | |
| return { | |
| 'total': t, |