Skip to content

Instantly share code, notes, and snippets.

View danlourenco's full-sized avatar

Dan Lourenço danlourenco

  • Slalom _build
  • Boston, MA
View GitHub Profile
@danlourenco
danlourenco / clean_code.md
Created April 30, 2020 20:07 — forked from wojteklu/clean_code.md
Summary of 'Clean code' by Robert C. Martin

Code is clean if it can be understood easily – by everyone on the team. Clean code can be read and enhanced by a developer other than its original author. With understandability comes readability, changeability, extensibility and maintainability.


General rules

  1. Follow standard conventions.
  2. Keep it simple stupid. Simpler is always better. Reduce complexity as much as possible.
  3. Boy scout rule. Leave the campground cleaner than you found it.
  4. Always find root cause. Always look for the root cause of a problem.

Design rules

@danlourenco
danlourenco / CleanArchitecture.md
Created April 30, 2020 20:07 — forked from ygrenzinger/CleanArchitecture.md
Summary of Clean Architecture by Robert C. Martin

Summary of book "Clean Architecture" by Robert C. Martin

Uncle Bob, the well known author of Clean Code, is coming back to us with a new book called Clean Architecture which wants to take a larger view on how to create software.

Even if Clean Code is one of the major book around OOP and code design (mainly by presenting the SOLID principles), I was not totally impressed by the book.

Clean Architecture leaves me with the same feeling, even if it's pushing the development world to do better, has some good stories and present robust principles to build software.

The book is build around 34 chapters organised in chapters.

@danlourenco
danlourenco / React HOC
Created February 7, 2020 17:55
React Patterns
const withHOC = (WrappedComponent) => {
return class WithHoc extends React.Component {
// custom methods to augment wrapped component
render() {
return <WrappedComponent {...this.props} />
}
}
@danlourenco
danlourenco / error-handling-with-fetch.md
Created December 6, 2019 15:49 — forked from odewahn/error-handling-with-fetch.md
Processing errors with Fetch API

I really liked @tjvantoll article Handling Failed HTTP Responses With fetch(). The one thing I found annoying with it, though, is that response.statusText always returns the generic error message associated with the error code. Most APIs, however, will generally return some kind of useful, more human friendly message in the body.

Here's a modification that will capture this message. The key is that rather than throwing an error, you just throw the response and then process it in the catch block to extract the message in the body:

fetch("/api/foo")
  .then( response => {
    if (!response.ok) { throw response }
    return response.json()  //we only get here if there is no error
 })
@danlourenco
danlourenco / tools.md
Last active December 2, 2019 19:07
Web Dev Env

Browsers

Chrome/MS Edge

  • Redux Extension
  • React Extension

Terminals

  • iTerm (Mac OSX)
  • Solarized Dark Theme
@danlourenco
danlourenco / master-javascript-interview.md
Created October 10, 2019 18:50 — forked from Geoff-Ford/master-javascript-interview.md
Eric Elliott's Master the JavaScript Interview Series
@danlourenco
danlourenco / README.md
Created May 21, 2019 19:15 — forked from leonardofed/README.md
A curated list of AWS resources to prepare for the AWS Certifications


A curated list of AWS resources to prepare for the AWS Certifications

A curated list of awesome AWS resources you need to prepare for the all 5 AWS Certifications. This gist will include: open source repos, blogs & blogposts, ebooks, PDF, whitepapers, video courses, free lecture, slides, sample test and many other resources.


@danlourenco
danlourenco / example.js
Last active March 8, 2019 04:38
ES7 omit property via object rest operator
const myObject = {
a: 1,
b: 2,
c: 3
};
const { a, ...noA } = myObject;
console.log(noA); // => { b: 2, c: 3 }
@danlourenco
danlourenco / policy.json
Created March 2, 2019 23:40
S3 Bucket Policy - Public Website
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "PublicReadGetObject",
"Effect": "Allow",
"Principal": "*",
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::bucket-name-here/*"
}
@danlourenco
danlourenco / cypress-commands.js
Created November 13, 2018 19:30
Using Cypress commands
Cypress.Commands.add('login', (overrides = {}) => {
Cypress.log({
name: 'loginViaAuth0',
});
const options = {
method: 'POST',
url: Cypress.env('auth_url'),
body: {
grant_type: 'password',