Skip to content

Instantly share code, notes, and snippets.

View coprolit's full-sized avatar
🥦

Philippe Simpson coprolit

🥦
View GitHub Profile
@coprolit
coprolit / pull-request-description-guide.md
Last active December 21, 2023 11:15
An collection of insights on how to do a good Pull Request description.

A guide to Pull Request Descriptions

There’s a Pull Request on the software that you and your team are responsible for, and before you start reading all the changes, you’ve no idea what it is about...
You’ve no idea what the author’s intent of the change is.
You don’t know why the changes are being made.
You don’t know if the author wants you to do an in-depth review, or just wants a token approval.

Sounds familiar?

When you create a Pull Request, please make these things clear to the reviewers.

@coprolit
coprolit / Promises-vs-Observables.md
Last active December 21, 2023 11:26
A quick summary of the main differences between Promises and Observables in JavaScript
@coprolit
coprolit / guidelines-for-sustainable-software.md
Created June 9, 2023 18:35
A few guidelines for sustainable software

A few guidelines for sustainable software

  • Favor decoupled over DRY.

  • Favor declarative programming (functional and reactive) over imperative programming.

  • Favor composition over inheritance (organize by function, instead of type).

  • Share interfaces, not implementation.

  • Separate code into stateful and stateless interactions.

  • Whenever possible, use stateless building blocks and push side-effects to the edges of the application.

  • Favor pure functions (pure function > function > factory > class).

@coprolit
coprolit / design-patterns-for-sustainable-frontend-architecture.md
Last active October 1, 2025 20:24
Some best practices for developing a front-end architecture of modular, loosely coupled and highly composable building blocks, to create codebases that are as scalable, reusable, flexible and maintainable as possible.
@coprolit
coprolit / index.html
Last active December 10, 2023 17:01
Vanilla JS Reactive Data Store By Chris Ferdinandi, Go Make Things
<div id="app"></div>
@coprolit
coprolit / auth.ts
Last active May 9, 2021 18:29
Common API requests service (passing access token to each API call, intercepting and handling unauthorized calls, by initiating an access token refresh)
/**
* A common interface for Authentication logic.
* Handling login, logout, and refresh token.
**/
import { Tokens, ApiError } from '@/models/api';
import { http, token } from "./";
export async function login(email: string, password: string): Promise<void> {
const result: Tokens | ApiError = await http.post(
// Pipelines
// A pipeline allows for easy function composition when performing multiple, immutable operations on a variable.
const pipe = functions => data => {
return functions.reduce(
(value, func) => func(value),
data
);
};
@coprolit
coprolit / lookupMap.js
Last active February 7, 2020 08:06
lookup map in JavaScript
// Using object literal:
function getStatusColor (status) {
return {
success: 'green',
warning: 'yellow',
info: 'blue',
error: 'red'
}[status]
}
@coprolit
coprolit / Fetch_API.js
Last active January 26, 2021 07:45
Snippets for using Fetch API
// GitHub window.fetch polyfill: https://github.com/github/fetch
// basic GET request:
fetch("/data.json").then(function(res) {
// res instanceof Response == true.
if (res.ok) {
res.json().then(function(data) {
console.log(data.entries);
});
} else {
// Each of the following options will create a new empty object:
var newObject = {};
// or
var newObject = Object.create( Object.prototype );
// or
var newObject = new Object();