This file contains 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
{ | |
"basics": { | |
"name": "Thomas Edison", | |
"label": "Inventor and Businessman", | |
"picture": "https://example.com/photo.jpg", | |
"email": "[email protected]", | |
"phone": "(123) 456-7890", | |
"website": "https://thomasedison.com", | |
"summary": "Prolific inventor and businessman known for developing many devices that greatly influenced life around the world, including the phonograph, the motion picture camera, and the electric light bulb.", | |
"location": { |
This file contains 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
/** | |
* Based on this thread https://github.com/aws-samples/amazon-cloudfront-functions/issues/11 | |
*/ | |
function getQueryParamsAsString(querystring) { | |
if (!querystring || querystring.length < 1) { | |
return ''; // There is no query params | |
} | |
const str = []; | |
for (const param in querystring) { |
This file contains 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
'use client'; | |
import { useEffect, useState } from 'react'; | |
import { useMediaQuery } from 'react-responsive'; | |
export const IS_SERVER = typeof window === 'undefined'; | |
export const MOBILE_SCREEN_MAX_WIDTH = 640; | |
export const SERVER_SIDE_MOBILE_FIRST = true; // true - for mobile, false - for desktop | |
/** | |
* Hook to detect isMobile vs. isDesktop using Media Query |
This file contains 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
const LOG_LEVEL_FROM_ENV = process?.env?.REACT_APP_LOG_LEVEL ?? 'silent'; | |
/** | |
* Supported logging levels by names, the index is the level number. | |
*/ | |
export const LOG_LEVEL_NAMES = ['trace', 'debug', 'info', 'warn', 'error', 'silent']; | |
/** | |
* Lightweight logger with minimal log level restrictions | |
* @class Log |
This file contains 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 axios from 'axios'; | |
import { api } from '.'; | |
import { log } from '../utils/log'; | |
import { addTrailingSlash } from '../utils/path'; | |
// Note: Use Local storage to override API base path | |
export const API_URL = addTrailingSlash(process.env.REACT_APP_API || 'http://localhost:3030'); | |
/** |
This file contains 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
function solution(X, Y, colors) { | |
let countG = 0; | |
let countR = 0; | |
let points = [] | |
for (let i = 0; i < colors.length; i++) { | |
const distance = Math.sqrt(X[i]**2 + Y[i]**2) | |
const color = colors[i] | |
points.push({distance, color}) | |
if (color === 'R') { |
This file contains 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
const useAxios = ({ url, method, body = null, headers = null }) => { | |
const [response, setResponse] = useState(null); | |
const [error, setError] = useState(''); | |
const [loading, setLoading] = useState(true); | |
const fetchData = () => { | |
axios[method](url, JSON.parse(headers), JSON.parse(body)) | |
.then((res) => { | |
setResponse(res.data); | |
}) |
This file contains 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
export const useAxios = (axiosParams) => { | |
const [response, setResponse] = useState(undefined); | |
const [error, setError] = useState(''); | |
const [loading, setloading] = useState(true); | |
const fetchData = async (params) => { | |
try { | |
const result = await axios.request(params); | |
setResponse(result.data); | |
} catch (error) { |
This file contains 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
function getMetaTagContent(metaTagName: string): string | null { | |
const metaTags: HTMLCollectionOf<HTMLMetaElement> = document.getElementsByTagName('meta'); | |
const nameToFind = metaTagName.toLowerCase(); | |
for (const current of metaTags) { | |
if (current.getAttribute('name')?.toLowerCase() === nameToFind) { | |
return current.getAttribute('content'); | |
} | |
} | |
return ''; | |
} |
This file contains 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
const source = [20, 5, 100, 1, 90, 200, 40, 29]; | |
const sorted = []; | |
console.log('source:', source); | |
for (const value of source) { | |
setTimeout(() => { | |
sorted.push(value); | |
console.log('sorting:', value); // to see progress | |
}, value); |
NewerOlder