Skip to content

Instantly share code, notes, and snippets.

View lnmunhoz's full-sized avatar

Lucas N. Munhoz lnmunhoz

View GitHub Profile
@lnmunhoz
lnmunhoz / useElementOnScreen.tsx
Created February 22, 2023 20:51
useElementOnScreen hook
import { useEffect, useRef, useState } from 'react';
import * as React from 'react';
export type UseElementOnScreenProps = [React.MutableRefObject<any>, boolean];
export const useElementOnScreen = (options?: IntersectionObserverInit): UseElementOnScreenProps => {
const containerRef = useRef(null);
const [isVisible, setIsVisible] = useState(false);
const callbackFunction = (entries) => {
@lnmunhoz
lnmunhoz / refactor-apollo-query-components-data-prop.js
Last active May 2, 2020 22:33
Fix Apollo Query components expecting the data prop to be an empty object
/**
* This transformer adds an empty object assignment to every Query component in the codebase.
* It will only touch the file if it find a Query that has object destructuring assignment.
* https://astexplorer.net/#/gist/a52e94d33bf5329027fddc77b95d9fe5/7b18cb8ae69e0ab4413375276863632cf6307d52
*/
export default function transformer(file, api) {
const j = api.jscodeshift
return j(file.source)
.find(j.JSXElement, path => path.openingElement.name.name === 'Query')
@lnmunhoz
lnmunhoz / graphiql.css
Created July 22, 2019 10:44
GraphiQL with Explorer Tab in Dark Mode
.graphiql-container {
height: 100vh;
width: 100vw;
}
.graphiql-container .topBar,
.graphiql-container .docExplorerShow,
.graphiql-container .execute-button {
background: linear-gradient(#e2e2e2, #f7f7f7);
}
@lnmunhoz
lnmunhoz / README.md
Last active May 24, 2019 05:48
Moving data from local postgres to remote postgres using Hasura

A simple workflow to import your data from localhost to your remote Hasura instance. I think this is not the best way but this is how it worked from me after many tries.

From the localhost

hasura init --directory my-project --endpoint http://localhost:8080
cd my-project

hasura migrate create "init" --from-server
@lnmunhoz
lnmunhoz / .block
Last active March 16, 2019 07:25
d3: revenues scatter plots dynamic
license: mit
@lnmunhoz
lnmunhoz / .block
Last active March 16, 2019 07:20
d3: revenues bar chart dynamic
license: mit
@lnmunhoz
lnmunhoz / .block
Last active March 16, 2019 05:23
d3: revenues bar chart
license: mit
@lnmunhoz
lnmunhoz / .block
Created March 11, 2019 17:05
learning d3: axis
license: mit
@lnmunhoz
lnmunhoz / .block
Created February 22, 2019 05:39
learning d3: axis
license: mit
@lnmunhoz
lnmunhoz / .block
Last active February 22, 2019 05:39
learning d3: axis
license: mit