This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public boolean isWithinRadius(Coordinates searchLocationCoordinates, int radius) { | |
| final int earthRadius = 6371; // Radius of the earth | |
| double latDistance = Math.toRadians(searchLocationCoordinates.latitude - latitude); | |
| double lonDistance = Math.toRadians(searchLocationCoordinates.longitude - longitude); | |
| double a = Math.sin(latDistance / 2) * Math.sin(latDistance / 2) | |
| + Math.cos(Math.toRadians(latitude)) * Math.cos(Math.toRadians(latitude)) | |
| * Math.sin(lonDistance / 2) * Math.sin(lonDistance / 2); | |
| double c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a)); | |
| double distanceInKm = earthRadius * c; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public Coordinates geocodeLocation(String location) throws LocationNotFoundException { | |
| JOpenCageGeocoder jOpenCageGeocoder = new JOpenCageGeocoder(apiKey); | |
| JOpenCageResponse geocodeResult = jOpenCageGeocoder.forward(new JOpenCageForwardRequest(location)); | |
| JOpenCageLatLng openCageLatLng = geocodeResult.getFirstPosition(); | |
| if(null == openCageLatLng) { | |
| throw new LocationNotFoundException("Could not find location " + location); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import i18n from "i18next"; | |
| import LanguageDetector from "i18next-browser-languagedetector"; | |
| import { initReactI18next } from "react-i18next"; | |
| i18n | |
| .use(initReactI18next) // passes i18n down to react-i18next | |
| .use(LanguageDetector) | |
| .init({ | |
| resources: { | |
| en: { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React from "react"; | |
| import { Trans } from "react-i18next"; | |
| export default function MyComponent() { | |
| return <Trans i18nKey="helloWorld" />; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React from 'react'; | |
| import { Translation } from 'react-i18next'; | |
| export function MyComponent() { | |
| return ( | |
| <Translation> | |
| { | |
| (t, { i18n }) => <p>{t('my translated text')}</p> | |
| } | |
| </Translation> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React from 'react'; | |
| import { withTranslation } from 'react-i18next'; | |
| function MyComponent({ t, i18n }) { | |
| return <p>{t('my translated text')}</p> | |
| } | |
| export default withTranslation()(MyComponent); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React from 'react'; | |
| import { useTranslation } from 'react-i18next'; | |
| export function MyComponent() { | |
| const [t, i18n] = useTranslation(); | |
| return <p>{t('helloWorld')}</p> | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React from 'react'; | |
| import { ToastContainer, toast } from 'react-toastify'; | |
| import 'react-toastify/dist/ReactToastify.css'; | |
| function App(){ | |
| const notify = () => toast("Wow so easy!"); | |
| return ( | |
| <div> | |
| <button onClick={notify}>Notify!</button> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React from 'react'; | |
| import { ToastContainer, toast } from 'react-toastify'; | |
| import 'react-toastify/dist/ReactToastify.css'; | |
| function App(){ | |
| const notify = () => toast("Wow so easy!"); | |
| return ( | |
| <div> | |
| <button onClick={notify}>Notify!</button> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React from "react"; | |
| import { LinkContainer } from "react-router-bootstrap"; | |
| import { Form, Input, Row, Col, FormGroup, Label, Button } from "reactstrap"; | |
| function MyForm(props) { | |
| const [inputs, setInputs] = React.useState({}); | |
| const onHandleInput = (e) => { | |
| setInputs({ ...inputs, [e.target.id]: e.target.value }); |
NewerOlder