Skip to content

Instantly share code, notes, and snippets.

Terminating a process on port 8081
Run the following command on a Mac to find the id for the process that is listening on port 8081:
$ sudo lsof -i :8081
Then run the following to terminate the process:
$ kill -9 <PID>
On Windows you can find the process using port 8081 using Resource Monitor and stop it using Task Manager.
@pablospaniard
pablospaniard / renderWithProvider.js
Last active November 20, 2023 09:36
rtl render method extended with Store and Context
import React from 'react';
import { createStore } from 'redux';
import { Provider as RRProvider } from 'react-redux';
import { render as rtlRender } from '@testing-library/react-native';
import { rootReducer } from 'store';
// you can provide initialState or the entire store that the ui is rendered with
export const renderWithStore = (
ui,
{
@pablospaniard
pablospaniard / rtl-renderWithStore.js
Last active February 3, 2021 15:56
Render method from RTL with Store and InitalState
import React from 'react';
import { createStore } from 'redux';
import { Provider } from 'react-redux';
import { render as rtlRender } from '@testing-library/react-native';
import { rootReducer } from 'store';
// you can provide initialState or the entire store that the ui is rendered with
export const renderWithStore = (
ui,
{
# source:
# https://discussions.apple.com/message/32354266#message32354266
sudo mdutil -Ea
sudo mdutil -ai off
sudo mdutil -ai on
jest.mock('../../../api', () => {
return {
getCurrencies: () =>
Promise.resolve({
data: [{ code: 1, label: 'EUR' }]
}),
getProducts: () =>
Promise.resolve({
data: [{ code: 1, label: 'Facebook' }]
})
export const roundDigit = (value, decimals) => {
const base = 10 ** decimals //** power of the given exponent
return Math.ceil(value * base) / base
}
/* eslint-disable consistent-return */
import { useEffect, useRef } from 'react'
export default function useInterval(callback, delay, running = false) {
const savedCallback = useRef()
// Remember the latest callback.
useEffect(() => {
savedCallback.current = callback
}, [callback])