Skip to content

Instantly share code, notes, and snippets.

View ricardocanelas's full-sized avatar
🦈

Ricardo Canelas ricardocanelas

🦈
View GitHub Profile
@sibelius
sibelius / FormUseFormik.tsx
Last active March 10, 2025 03:04
Example showing how to useFormik and FormikProvider
type Props = {
};
const FormUseFormik = (props: Props) => {
const { enqueueSnackbar } = useSnackbar();
const onSubmit = (values) => {
enqueueSnackbar(`submit: ${JSON.stringify(values)}`, {
preventDuplicate: true,
persist: false,
});
@sibelius
sibelius / winston.js
Created June 28, 2019 01:50
winston.js __mocks__ for jest
const winston = jest.genMockFromModule('winston');
const format = jest.fn();
format.json = jest.fn();
const Winston = {
...winston,
format,
transports: {
File: jest.fn(),
@rogeriochaves
rogeriochaves / links.md
Last active July 14, 2022 01:55
Pt-BR Data Science Links Scrapping
@sibelius
sibelius / usePrompt.tsx
Last active October 27, 2022 19:05
Prompt user before leaving route or reload
import { useEffect, useRef } from 'react';
import { useHistory } from 'react-router-dom';
export const usePrompt = (when: boolean, message: string = 'Are you sure you want to quit without saving your changes?') => {
const history = useHistory();
const self = useRef(null);
const onWindowOrTabClose = event => {
if (!when) {
@Jaredk3nt
Jaredk3nt / context-thunk.js
Last active November 9, 2024 13:08
React Context Thunk Pattern
const MyContext = createContext();
function reducer(state, action) {
switch (action.type) {
case "COUNT_REQUEST":
return {
...state,
loading: true,
err: undefined
};
# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:/usr/local/bin:$PATH
export ANDROID_HOME=~/Android/Sdk
export PATH="$PATH:$ANDROID_HOME/tools"
export PATH="$PATH:$ANDROID_HOME/platform-tools"
# Path to your oh-my-zsh installation.
export ZSH="/Users/diegofernandes/.oh-my-zsh"
export PATH="$PATH:/usr/local/bin"
@RedHatter
RedHatter / DateMultiPicker.jsx
Last active August 4, 2021 02:14
Range and multi select for @dmtrKovalenko/material-ui-pickers
import React, { useState, useContext, useRef } from 'react'
import { DatePicker } from 'material-ui-pickers'
import { MuiPickersContext } from 'material-ui-pickers'
export default function DateMultiPicker({
value,
onChange,
labelFunc,
format,
emptyLabel,
@sibelius
sibelius / authenticatedMidldeware.tsx
Created February 15, 2019 12:16
Auth middleware to use with RR4
import * as React from 'react';
import { withRouter } from 'react-router-dom';
import { isLoggedIn } from '../../security/authentication';
import routeTo from '../utils/routeTo';
const authenticatedMiddleware = Component => {
class AuthenticatedMiddleware extends React.PureComponent {
componentDidMount() {
this.redirectIfNotAuthenticated();
@matvaleriano
matvaleriano / reactSummary.md
Last active June 5, 2020 23:03
React summary only examples #summary #react #examples

React Resume

Props

Props são atributos que podem ser passados para componentes (não mude eles dentro do component que vc está usando)

Pros are attributes that can be passed to components (don't change them into the component which is using them)

States

A melhor forma de manipular as props que foram passadas e outros atributos do seu component

@smoothml
smoothml / scikit-learn-predictions-on-spark.py
Last active October 18, 2023 19:07
How to apply a Scikit Learn machine learning model at scale using Apache Spark.
from pyspark.sql import functions as F
from pyspark.sql.types import DoubleType
import pandas as pd
from sklearn.externals import joblib
def make_predictions(sc, df, feature_cols, model_path):
"""
Make predictions.