Skip to content

Instantly share code, notes, and snippets.

View santanaG's full-sized avatar
🏠
Working from home

Gustavo Santana santanaG

🏠
Working from home
View GitHub Profile
const userQ = 'SELECT `id` FROM `user` WHERE `email` = ?'
const permissionsQ = 'SELECT `id`, `name` FROM `permission` WHERE `user_id` = ?'
const getUserbyEmail = (connection, email) => connection
.queryAsync(userQ, [email])
.spread(user => user === undefined
? [{}, {}]
: Promise.all([user, connection.queryAsync(permissionsQ, [user.id])]))
.then(([user, permissions]) => ({ ...user, permissions }))
// 1. move queries to their own variables
const userQ = 'SELECT `id` FROM `user` WHERE `email` = ?'
const permissionsQ = 'SELECT `id`, `name` FROM `permission` WHERE `user_id` = ?'
// 2. remove codeblocks/explicit return statements
// 3. use 2 spaces instead of 4 for tabs
// 4. leverage ternary operator for that check
const getUserByEmail = (connection, userEmail) => connection
@santanaG
santanaG / chrome.md
Created October 24, 2017 20:04 — forked from 0xjjpa/chrome.md
Understanding Google Chrome Extensions

#Introduction

Developing Chrome Extensions is REALLY fun if you are a Front End engineer. If you, however, struggle with visualizing the architecture of an application, then developing a Chrome Extension is going to bite your butt multiple times due the amount of excessive components the extension works with. Here are some pointers in how to start, what problems I encounter and how to avoid them.

Note: I'm not covering chrome package apps, which although similar, work in a different way. I also won't cover the page options api neither the new brand event pages. What I explain covers most basic chrome applications and should be enough to get you started.

Table of Contents

  1. Understand the Chrome Architecture
  2. Understand the Tabs-Extension Relationship
  3. Picking the right interface for the job
@santanaG
santanaG / README.md
Created October 24, 2017 20:00 — forked from jxson/README.md
README.md template

Synopsis

At the top of the file there should be a short introduction and/ or overview that explains what the project is. This description should match descriptions added for package managers (Gemspec, package.json, etc.)

Code Example

Show what the library does as concisely as possible, developers should be able to figure out how your project solves their problem by looking at the code example. Make sure the API you are showing off is obvious, and that your code is short and concise.

Motivation

@santanaG
santanaG / README-Template.md
Created October 24, 2017 19:59 — forked from PurpleBooth/README-Template.md
A template to make good README.md

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites