Skip to content

Instantly share code, notes, and snippets.

View fmoliveira's full-sized avatar

Filipe Oliveira fmoliveira

  • Level Access
  • Toronto
  • 22:00 (UTC -04:00)
View GitHub Profile
@fmoliveira
fmoliveira / AutoFocusStory.tsx
Created May 28, 2020 19:25
Storybook Decorator for Auto Focus
import React, { useCallback } from 'react';
/**
* Storybook Decorator
*
* Auto click the first focusable element.
*/
const AutoFocusStory = (storyFn: () => {} | null | undefined) => {
const autofocus = useCallback((node: HTMLDivElement) => {
const element = node.querySelector('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])');
@fmoliveira
fmoliveira / slack-macro.js
Created December 18, 2019 18:26
Slack macro to quickly delete messages, activate this script and click on the messages you want to be deleted
document.addEventListener("click", event => {
const [element] = event.path;
console.warn({ element });
// click on more actions menu, which is only visible when you hover a message
if (
element.classList.contains("c-message__body") ||
element.classList.contains("c-message__content_header") ||
element.classList.contains("c-file_gallery") ||
@fmoliveira
fmoliveira / webscraping_nyc_mta.py
Created October 30, 2019 10:34 — forked from julia-git/webscraping_nyc_mta.py
webscraping_nyc_mta
# Import libraries
import requests
import urllib.request
import time
from bs4 import BeautifulSoup
# Set the URL you want to webscrape from
url = 'http://web.mta.info/developers/turnstile.html'
# Connect to the URL
@fmoliveira
fmoliveira / Container.js
Created October 18, 2019 18:40
styled-components media queries
/*
* source: https://react-brasil.slack.com/archives/C1EDVPBQC/p1571423188462000?thread_ts=1571421080.458800&cid=C1EDVPBQC
* author: João Paulo Siqueira Lins
*/
import styled from "styled-components"
import MediaPoint from "./MediaPoint"
const Container = styled.div`
@fmoliveira
fmoliveira / ErrorBoundaryWithRetry.tsx
Created September 20, 2019 13:05 — forked from sibelius/ErrorBoundaryWithRetry.tsx
ErrorBoundaryWithRetry to be used with relay useQuery hook
class ErrorBoundaryWithRetry extends React.Component<Props, State> {
state = {error: null};
static getDerivedStateFromError(error): State {
return {error: error};
}
_retry = () => {
this.setState({error: null});
}
@fmoliveira
fmoliveira / .zshrc
Created October 2, 2018 18:42
My Shell Helper Functions
whoport() {
lsof -nP -i4TCP:$@ | grep LISTEN
}
@fmoliveira
fmoliveira / webpack4upgrade.md
Created June 2, 2018 00:28 — forked from gricard/webpack4upgrade.md
Just some notes about my attempt to upgrade to webpack 4

This is not a complaint about Webpack or v4 in any way. This is just a record of my process trying it out so I could provide feedback to the webpack team

Hmm... I don't see any docs for 4.0 on https://webpack.js.org. I guess I'll just wing it. All I need to do is npm i -D webpack@next, right?

+ webpack@4.0.0-beta.2
added 1 package, removed 20 packages and updated 4 packages in 13.081s
@fmoliveira
fmoliveira / aoe2hd.md
Created May 30, 2018 17:32 — forked from yocontra/aoe2hd.md
Age of Empires II HD - For Mac OSX
@fmoliveira
fmoliveira / Ruby ORMs.md
Created March 10, 2018 19:14 — forked from booch/Ruby ORMs.md
Ruby ORMs

Ruby ORMs

Abstract

Rails is really a collection of pieces that can be put together to create a web app. You can enhance or replace many of the components - how you write views, how controllers work, and how you build models. While models are built on top of ActiveRecord in the

@fmoliveira
fmoliveira / frontendDevlopmentBookmarks.md
Created October 13, 2017 16:45 — forked from dypsilon/frontendDevlopmentBookmarks.md
A badass list of frontend development resources I collected over time.