Skip to content

Instantly share code, notes, and snippets.

View rodrigonehring's full-sized avatar
🔋

Rodrigo Eduardo Nehring rodrigonehring

🔋
  • joinville - brazil
View GitHub Profile
@rodrigonehring
rodrigonehring / getData.js
Created November 10, 2016 18:34
Scraping kabum, terabyte and pichau product info
const request = require('request');
const cheerio = require('cheerio');
function priceToNumber(str) {
if (!str)
return 0;
if (typeof str !== 'string')
return str;
/*
A: Qual o typeof de result?
- string
- number
- object
- function
B: Qual o resultado do log?
- result is not a function
- 1
const initialState = {
project: "My-App",
lists: [
{
id: 1,
title: "A Fazer",
cards: [
{
id: 1,
description: "Comprar Pao"
@rodrigonehring
rodrigonehring / Snack.js
Created October 26, 2018 16:52
Snackbar to react 16.7 hooks (material-ui)
import React, { createContext, useState } from 'react'
import Snackbar from '@material-ui/core/Snackbar'
import Button from '@material-ui/core/Button'
import IconButton from '@material-ui/core/IconButton'
const Context = createContext()
function RenderSnack({ id, message, open, handleClose }) {
const messageId = `message-${id}`
return (
@rodrigonehring
rodrigonehring / wsl-ip.bat
Created July 10, 2019 21:11
Update etc/hosts with current wsl2 ip
echo OFF
set folder="C:\Users\rodri\Desktop\ip"
del "%folder%\hosts"
ubuntu1804 -c "ip addr | grep 'eth0' | grep 'inet' | grep -o -P 'inet.{0,14}' | grep -E -o '([0-9]{1,3}[\.]){3}[0-9]{1,3}'" > "%folder%\ip.txt"
set /p ip=<"%folder%\ip.txt"
echo %ip%
echo f | copy /Y "%folder%\hosts-copy" "%folder%\hosts"
(echo. & echo %ip% local.gofind) >> %folder%\hosts
copy /Y "%folder%\hosts" "C:\Windows\System32\drivers\etc\hosts"
PAUSE
import React, { useReducer, useEffect } from 'react';
import ReactDOM from 'react-dom';
const rowStyle = {
display: 'flex'
}
const squareStyle = {
'width':'60px',
'height':'60px',
@rodrigonehring
rodrigonehring / awsconnector.ts
Created January 14, 2021 17:16
Connect aws elasticsearch
import * as AWS from 'aws-sdk'
import { Connection } from '@elastic/elasticsearch'
class AwsConnector extends Connection {
async request(params, callback) {
const creds = await this.getAWSCredentials()
const req = this.createRequest(params)
const { request: signedRequest } = this.signRequest(req, creds)
super.request(signedRequest, callback)
@rodrigonehring
rodrigonehring / ConfirmationDialog.test.tsx
Last active May 19, 2022 21:45
mui/material v5 - confirmation dialog returns promise on open
import React from 'react';
import { fireEvent, render, screen, waitFor } from '@tests/utils';
import ConfirmationDialog, { useConfirmationDialog } from './ConfirmationDialog';
function fakePromise() {
let resolve;
const promise = new Promise((promiseResolve) => {
resolve = promiseResolve;
});