Skip to content

Instantly share code, notes, and snippets.

View ivan-marquez's full-sized avatar

Jose Ivan Marquez ivan-marquez

View GitHub Profile
@bowin
bowin / node.js PassThrough stream.md
Last active November 15, 2022 00:02
Node.js Stream PassThrough Usage
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 readable
@subfuzion
subfuzion / dep.md
Last active June 14, 2023 15:46
Concise guide to golang/dep

Overview

This 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:

@HarvsG
HarvsG / .travis.yml
Last active April 10, 2018 21:57 — forked from mderazon/.travis.yml
Automatic deployment to Google Cloud Functions with Travis-ci
# 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
@JaniAnttonen
JaniAnttonen / mongoDump.md
Last active March 18, 2024 09:58
Export Docker MongoDB collection as a JSON file

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
@joshbuchea
joshbuchea / semantic-commit-messages.md
Last active June 11, 2024 07:59
Semantic Commit Messages

Semantic Commit Messages

See how a minor change to your commit message style can make you a better programmer.

Format: <type>(<scope>): <subject>

<scope> is optional

Example

@mderazon
mderazon / .travis.yml
Last active April 13, 2020 11:05
Automatic deployment to Google Cloud Functions with Travis-ci
# Use Dockerized infrastructure
sudo: false
# Use node_js environnement
language: node_js
node_js:
- "6"
# Cache Gcloud SDK between commands
cache:
@jaimeiniesta
jaimeiniesta / index.js
Last active April 18, 2018 21:37
Google Cloud Functions for AccessLint
/**
* 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
});
@wesbos
wesbos / async-await.js
Created February 22, 2017 14:02
Simple Async/Await Example
// 🔥 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
});
}
@alirezas
alirezas / getTimeRemaining.js
Created February 13, 2017 10:49
Calculate remaining time with vanilla js
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,