Skip to content

Instantly share code, notes, and snippets.

View washingtonsoares's full-sized avatar
🎯
Focusing

Washington Soares washingtonsoares

🎯
Focusing
View GitHub Profile
@CristinaSolana
CristinaSolana / gist:1885435
Created February 22, 2012 14:56
Keeping a fork up to date

1. Clone your fork:

git clone git@github.com:YOUR-USERNAME/YOUR-FORKED-REPO.git

2. Add remote from original repository in your forked repository:

cd into/cloned/fork-repo
git remote add upstream git://github.com/ORIGINAL-DEV-USERNAME/REPO-YOU-FORKED-FROM.git
git fetch upstream
@sebmarkbage
sebmarkbage / Enhance.js
Last active January 31, 2024 18:33
Higher-order Components
import { Component } from "React";
export var Enhance = ComposedComponent => class extends Component {
constructor() {
this.state = { data: null };
}
componentDidMount() {
this.setState({ data: 'Hello' });
}
render() {
@givigier
givigier / backend.mkd
Last active March 14, 2016 18:06
Open positions at Agrid

Backend Developer at Agrid

  • Full time position
  • Flexible working hours
  • Remote job
  • Salary from R$ 3000,00 to R$ 6000,00 according with experience
  • Company stocks in case of hiring

Agrid is an API of prices of services that aims to make market more fair for clients and service providers. Our team consists of experienced developers who needs others qualified and agile professionals to transform ideas in code.

@ljharb
ljharb / array_iteration_thoughts.md
Last active May 22, 2024 09:22
Array iteration methods summarized

Array Iteration

https://gist.github.com/ljharb/58faf1cfcb4e6808f74aae4ef7944cff

While attempting to explain JavaScript's reduce method on arrays, conceptually, I came up with the following - hopefully it's helpful; happy to tweak it if anyone has suggestions.

Intro

JavaScript Arrays have lots of built in methods on their prototype. Some of them mutate - ie, they change the underlying array in-place. Luckily, most of them do not - they instead return an entirely distinct array. Since arrays are conceptually a contiguous list of items, it helps code clarity and maintainability a lot to be able to operate on them in a "functional" way. (I'll also insist on referring to an array as a "list" - although in some languages, List is a native data type, in JS and this post, I'm referring to the concept. Everywhere I use the word "list" you can assume I'm talking about a JS Array) This means, to perform a single operation on the list as a whole ("atomically"), and to return a new list - thus making it mu

// Counter Component
import React, { useReducer, createContext } from 'react'
import reducer, { initialState, actions } from './reducer'
const CounterContext = createContext()
function Counter() {
const [state, dispatch] = useReducer(reducer, initialState)
const { increment, decrement, reset } = actions(dispatch)
@kyleshevlin
kyleshevlin / memoizedHandlers.js
Created January 22, 2021 00:26
Using React.useMemo to create a `handlers` object
// One of my new favorite React Hook patternms is to create handler
// functions for a custom hook using `React.useMemo` instead of
// `React.useCallback`, like so:
function useBool(initialState = false) {
const [state, setState] = React.useState(initialState)
// Instead of individual React.useCallbacks gathered into an object
// Let's memoize the whole object. Then, we can destructure the
// methods we need in our consuming component.
@fdaciuk
fdaciuk / How to use async await without try-catch block.md
Last active April 22, 2024 14:31
How to use async/await without try/catch block

How to use async/await without try/catch block

We can use something like this:

async function resolveToNumber () {
  const promise = Promise.resolve(1)
  const [error, result] = await to(promise)
  console.log(error, result) // [null, 1] -> Here we have the result, and error will be null
}
@sibelius
sibelius / testRequest.ts
Created July 15, 2021 17:53
Test a request using fetch api
import 'isomorphic-fetch';
const run = async () => {
const payload = {
field: 'value'
}
const options = {
method: 'POST',
headers: {
@fdaciuk
fdaciuk / 00 - Tailwind Colors + Styled Components + TypeScript.md
Last active February 14, 2024 16:28
Tailwind Colors + Styled Components + TypeScript

Configuration to use TailwindCSS colors in a Styled Components theme with CRA + TypeScript.

Tailwind colors list: https://tailwindcss.com/docs/customizing-colors#generating-colors

Create files src/@types/styled.d.ts and src/resources/theme.ts with content below. Then add the theme on your project:

import { ThemeProvider } from 'styled-components'
import { theme } from 'resources/theme'
<div id="canvas"></div>
<style>
#canvas {
width: 500px;
height: 300px;
border: 5px solid black;
position: relative;
box-sizing: content-box;
}