Skip to content

Instantly share code, notes, and snippets.

View danvitoriano's full-sized avatar
💭
probably coding

Dan Vitoriano 🌈 danvitoriano

💭
probably coding
View GitHub Profile
@wesleyegberto
wesleyegberto / convert-postman-to-insomnia.js
Created September 22, 2020 05:57
Script to convert a Postman backupt to Insomnia
/**
* Script to parse a Postman backupt to Insomnia keeping the same structure.
*
* It parses:
* - Folders
* - Requests
* - Environments
*
* Notes: Insomnia doesn't accept vars with dots, if you are using you must replace yours URLs manually (see ENVIRONMENTS_EXPORTS).
*/
@lexblagus
lexblagus / TerminalColorsTemplate.sh
Last active March 19, 2020 21:22
Bash colors template
#!/bin/bash
for clbg in {40..47} {100..107} 49 ; do # background
for clfg in {30..37} {90..97} 39 ; do # foreground
for attr in 0 1 2 4 5 7 ; do # formatting
printf "\e[${attr};${clbg};${clfg}m" # colorization
printf "\\\e[${attr};${clbg};${clfg}m" # code text prefix
printf " ░▒▓█▓▒░ " # sample characters
printf "\\\e[0m" # code text suffix
printf "\e[0m" # reset color
@KeKs0r
KeKs0r / Description.md
Last active July 8, 2022 14:56
Marcs React Structure 2019 Examples

How I currently write React Apps (2019 Hooks Edition)

Foreword

Most of my products are very MVP-ish, so I dont focus too much on super clean code and high quality, but there are a few patterns that I reuse quite a bit and find useful. But this is not an exhaustive list and the examples might not be as clean as one would think.

Technology Stack

Usually I am not using any sophisticated state Library anymore, the react hooks useState and useReducer in combination with context is absolutely sufficient, at least for UI-State. Everything else is in data persistence, which is in my case either Firebase or Graphql (= Apollo).

@diego3g
diego3g / settings.json
Last active November 1, 2025 06:31
VSCode Settings (Updated)
{
"workbench.startupEditor": "newUntitledFile",
"editor.fontSize": 16,
"editor.lineHeight": 1.8,
"javascript.suggest.autoImports": true,
"javascript.updateImportsOnFileMove.enabled": "always",
"editor.rulers": [
80,
120
],
/**
* Arquivo: calculadora-test.js
* Author: Glaucia Lemos
* Description: arquivo responsável por realizar os testes do arquivo: 'calculadora.js'
* Data: 30/03/2018
*
* Documentação: http://chaijs.com/guide/styles/#assert
*
*/
@bvaughn
bvaughn / updating-external-data-when-props-changes-using-promises.js
Last active June 16, 2024 21:56
Example for loading new external data in response to updated props
// This is an example of how to fetch external data in response to updated props,
// If you are using an async mechanism that does not support cancellation (e.g. a Promise).
class ExampleComponent extends React.Component {
_currentId = null;
state = {
externalData: null
};
@bvaughn
bvaughn / eager-prefetching-async-data-example.js
Last active November 28, 2024 00:44
Advanced example for eagerly prefetching async data in a React component.
// This is an advanced example! It is not intended for use in application code.
// Libraries like Relay may make use of this technique to save some time on low-end mobile devices.
// Most components should just initiate async requests in componentDidMount.
class ExampleComponent extends React.Component {
_hasUnmounted = false;
state = {
externalData: null,
};
@elitan
elitan / ContactForm.js
Last active August 11, 2025 03:44
React Router V4 Redirect after form submission
import React, { Component } from 'react';
import { withRouter } from 'react-router-dom'; // <--- import `withRouter`. We will use this in the bottom of our file.
class ContactForm extends Component {
submitForm (e) {
e.preventDefault()
this.props.history.push('/thank-you'); // <--- The page you want to redirect your user to.
}
@radarseven
radarseven / README.md
Created August 1, 2017 03:57 — forked from amir-rahnama/README.md
A simple Webpack (with Dev Server) + Gulp Configuration + LiveReload + Babel to playground where you can code ES6 without the need for React

A simple Webpack + Gulpfile configuration wihtout any need for React.js that assumes you have the following project structure:

node_modules/ bower_components/ scripts/

Entry script is in scripts/entry.js

You should run gulp && gulp build-dev and you are good to go.

@alexvcasillas
alexvcasillas / github-store.js
Created May 4, 2017 08:35
Async Fetching with MobX Actions
import fetch from 'node-fetch';
import { observable, action, runInAction } from 'mobx';
export default class GithubStore {
@observable searchName;
@observable user;
@observable repos;
@observable fetchingData;
constructor() {