Skip to content

Instantly share code, notes, and snippets.

View RileyManda's full-sized avatar
😁
Coding

Riley Manda RileyManda

😁
Coding
View GitHub Profile
import styled from "styled-components";
import {
calculateDeltas,
calculateCanvasDimensions,
calculateControlPoints,
} from "./arrow-utils";
import {
ArrowConfig,
LineProps,
{
"name": "hello-react-front-end",
"version": "0.1.0",
"private": true,
"dependencies": {
"@reduxjs/toolkit": "^1.9.5",
"@testing-library/jest-dom": "^5.16.5",
"@testing-library/react": "^13.4.0",
"@testing-library/user-event": "^13.5.0",
"react": "^18.2.0",
@RileyManda
RileyManda / arrayOfProducts
Created September 6, 2023 10:33
Array of Products Solution
import java.io.*;
import java.util.*;
class Solution {
static int[] arrayOfArrayProducts(int[] arr) {
int n = arr.length;
int[] res = new int[n];
// bug fix:::::::::::
@RileyManda
RileyManda / gist:1b25f34d533e134122439ede6d383c34
Created August 10, 2023 07:33
Anagram solution-mob programming
module.exports = function (string1, string2) {
// Function to create a character frequency object
function createFrequencyObject(str) {
const obj = {};
for (const char of str) {
const sanitizedChar = char.toLowerCase();
if (/[a-z0-9]/.test(sanitizedChar)) {
obj[sanitizedChar] = (obj[sanitizedChar] || 0) + 1;
}
}
import React from 'react';
import { render, screen } from '@testing-library/react';
import { Provider } from 'react-redux';
import configureStore from 'redux-mock-store';
import Profile from '../components/Profile';
const mockStore = configureStore([]);
test('renders joined missions when missions are available', () => {
const missions = [
@RileyManda
RileyManda / app.css
Last active August 4, 2023 05:31
Flex align
/* Profile */
.profile-container {
display: flex;
flex-direction: row;
align-items: flex-start;
}
/* joined missions */
.joined-missions-container {
flex: 1;
@RileyManda
RileyManda / ProtectedRoutes
Created July 14, 2023 06:06
Protected routes functional component example
import React from "react";
import { Navigate, Route } from "react-router-dom";
function ProtectedRoute({ component: Component, ...restOfProps }) {
const isAuthenticated = localStorage.getItem("isAuthenticated");
console.log("this", isAuthenticated);
return (
<Route
{...restOfProps}
@RileyManda
RileyManda / .babelrc
Created June 22, 2023 13:39
Jest configurations with webpack
{
"presets": ["@babel/preset-env"]
}
The current implementation voilates the DRY principle:
const pets = ['Cat', 'Dog', 'Bird', 'Fish', 'Frog', 'Hamster', 'Pig', 'Horse', 'Lion', 'Dragon'];
// Print all pets
// console.log is called multiple times for each item in the array:This is redundant.
console.log(pets[0]);
console.log(pets[1]);
console.log(pets[2]);
console.log(pets[3]);
...
import * as React from 'react';
import { emphasize, styled } from '@mui/material/styles';
import Breadcrumbs from '@mui/material/Breadcrumbs';
import Chip from '@mui/material/Chip';
import HomeIcon from '@mui/icons-material/Home';
import ExpandMoreIcon from '@mui/icons-material/ExpandMore';
const StyledBreadcrumb = styled(Chip)(({ theme }) => {
const backgroundColor =
theme.palette.mode === 'light'