Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

anil kumar chaudhary simbathesailor

🎯
Focusing
View GitHub Profile
View aspectratio.js
function getImageDimension(imgUrl) {
return new Promise((resolve, reject) => {
if (!imgUrl) {
reject({
status: "FAILURE"
});
}
try {
const img = new Image();
View Vscode.settings.json
{
"workbench.fontAliasing": "antialiased",
"window.zoomLevel": 3,
"[javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"editor.formatOnSave": true,
"eslint.validate": ["javascript", "javascriptreact"],
"eslint.codeAction.showDocumentation": {
"enable": true
@simbathesailor
simbathesailor / pre-push.sh
Created May 5, 2021
Git hook to check for master change before allow to push
View pre-push.sh
#!/bin/sh
# https://stackoverflow.com/questions/31992627/git-pre-commit-hook-error-color
# COLOR CODES
red='\033[0;41m'
white='\033[0;47m'
green='\033[0;32m'
yellow='\033[0;33m'
no_color='\033[0m'
View PdfPreviewComplete.js
import React, { useState, useEffect } from "react";
import styled from "styled-components";
import PropTypes from "prop-types";
function getCustomIdname(props) {
return props.uniqueContainerId ? `-${props.uniqueContainerId}` : "-";
}
export const PDFViewCustomContainer = styled.div`
// default css, not add it here to avoif large gist
${(props) => props.styles || ""}
View PdfPreviewComplete.js
import React, { useState, useEffect } from "react";
import styled from "styled-components";
import PropTypes from "prop-types";
// import './previewtest.css';
function getCustomIdname(props) {
return props.uniqueContainerId ? `-${props.uniqueContainerId}` : "-";
}
export const PDFViewCustomContainer = styled.div`
header {
View PdfPreviewComplete.js
import React, { useState, useEffect } from "react";
import styled from "styled-components";
import PropTypes from "prop-types";
// import './previewtest.css';
function getCustomIdname(props) {
return props.uniqueContainerId ? `-${props.uniqueContainerId}` : "-";
}
export const PDFViewCustomContainer = styled.div`
header {
View PdfPreviewboilerplate.js
function PdfPreview(props) {
const { docUrl, uniqueContainerId = "pdf-preview", styles } = props;
useEffect(() => {
// Plain javascript mozilla pdf.js initialization code can be placed here
}, [docUrl]);
return (
<PDFViewCustomContainer
styles={styles}
uniqueContainerId={uniqueContainerId}
View useQRCodeScan.js
function useQRCodeScan({
qrcodeMountNodeID = "",
closeAfterScan = true,
getQrBoxDimension,
}) {
const [decodedQRData, setDecodedQrData] = useState({
isScanning: false,
isScanSuccess: false,
isScanFailure: false,
data: null,