Skip to content

Instantly share code, notes, and snippets.

View anlisha-maharjan's full-sized avatar

Anlisha Maharjan anlisha-maharjan

View GitHub Profile
@anlisha-maharjan
anlisha-maharjan / laravel-github-actions-pipeline.yml
Last active January 8, 2023 16:32
Deploy Laravel app on shared hosting with SSH GitHub Action.
name: 🚀 Deploy on push master
on:
push:
branches:
- master
jobs:
web-deploy:
name: 🎉 Deploy
@anlisha-maharjan
anlisha-maharjan / laravel-deploy-script.sh
Created January 8, 2023 16:21
Laravel Deployment Script - To pull latest version of code and install composer dependencies and run migrations.
#!/bin/bash
set -e
echo "Deployment started ..."
# Enter maintenance mode or return true
# if already is in maintenance mode
(php artisan down) || true
# Pull the latest version of the app
@anlisha-maharjan
anlisha-maharjan / react-github-actions-pipeline.yml
Last active January 8, 2023 16:22
Deploy React app on shared hosting with FTP Deploy GitHub Action.
name: 🚀 Deploy on push master
on:
push:
branches:
- master
jobs:
web-deploy:
name: 🎉 Deploy
@anlisha-maharjan
anlisha-maharjan / YupValidation.js
Last active November 29, 2022 06:49
I need to validate objects in users array has unique name property.
import React from "react";
import * as Mui from "@mui/material";
import { Formik, Form, Field, FieldArray } from "formik";
import * as Yup from "yup";
import { get } from "lodash";
const YupValidation = () => {
Yup.addMethod(Yup.array, "unique", function (message, path) {
return this.test("unique", message, function (list) {
const mapper = (x) => get(x, path);
@anlisha-maharjan
anlisha-maharjan / react-bitbucket-pipelines.yml
Created November 2, 2022 04:59
The bitbucket-pipelines.yml defines Pipelines builds configuration for React application.
#bitbucket-pipelines.yml
image: node:14.0.0
pipelines:
branches:
master:
- step:
name: Build React (Prod Server)
script:
- npm cache clean --force
@anlisha-maharjan
anlisha-maharjan / map.js
Created August 24, 2022 11:44
A map component that uses Google Maps API Directions Service to plot efficient route on map with total distance and duration.
import React, { useState, useEffect } from "react";
import * as Mui from "@mui/material";
import { GoogleMap, DirectionsRenderer } from "@react-google-maps/api";
import moment from "moment";
import { IconClock, IconRoute } from "src/components/svg";
const Map = (props) => {
const [directions, setDirections] = useState(null);
const directionsService = new window.google.maps.DirectionsService();
@anlisha-maharjan
anlisha-maharjan / location.js
Created August 24, 2022 11:43
A basic form component with google places autocomplete fields to enter address.
import React from "react";
import * as Mui from "@mui/material";
import { Field, FieldArray } from "formik";
import { IconAdd, IconTrash } from "src/components/svg";
import GoogleAutocomplete from "src/components/autocomplete";
const Location = (props) => {
return (
<Mui.Card className="default-card-dark-card pos-relative">
<Mui.Grid container spacing={3}>
@anlisha-maharjan
anlisha-maharjan / App.js
Created August 24, 2022 11:40
A basic App.js initialized with formik.
import React from "react";
import { ThemeProvider } from "@mui/material/styles";
import * as Mui from "@mui/material";
import { Formik, Form } from "formik";
import theme from "src/configs/theme";
import Location from "src/components/location";
import Map from "src/components/map";
function App() {
return (
@anlisha-maharjan
anlisha-maharjan / custom-time-picker.scss
Created June 29, 2022 11:44
Scss for react custom time picker component.
* {
box-sizing: border-box;
}
html,
body {
margin: 0;
}
/* ##### Custom Timepicker InputMask & ReactDateTime ##### */
@anlisha-maharjan
anlisha-maharjan / custom-time-picker.js
Last active June 29, 2022 11:43
A custom react time-picker component combining react-datetime & react-input-mask packages.
import React, { useState } from "react";
import Datetime from "react-datetime";
import InputMask from "react-input-mask";
import moment from "moment";
const CustomTimePicker = ({ label, classes, ...props }) => {
const [selectedTime, setSelectedTime] = useState("00:00");
const [formatChars] = useState({
1: "[0-2]",
2: "[0-9]",