Skip to content

Instantly share code, notes, and snippets.

View simbathesailor's full-sized avatar
🎯
Focusing

Anil Kumar Chaudhary simbathesailor

🎯
Focusing
View GitHub Profile
@simbathesailor
simbathesailor / aspectratio.js
Created June 16, 2021 09:28
getImageDimension.js
function getImageDimension(imgUrl) {
return new Promise((resolve, reject) => {
if (!imgUrl) {
reject({
status: "FAILURE"
});
}
try {
const img = new Image();
@simbathesailor
simbathesailor / Vscode.settings.json
Created June 8, 2021 10:55
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 16:54
Git hook to check for master change before allow to push
#!/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'
@simbathesailor
simbathesailor / useQRCodeScan.js
Last active April 25, 2021 12:58
useQRCodeScan.js
function useQRCodeScan({
qrcodeMountNodeID = "",
closeAfterScan = true,
getQrBoxDimension,
}) {
const [decodedQRData, setDecodedQrData] = useState({
isScanning: false,
isScanSuccess: false,
isScanFailure: false,
data: null,
@simbathesailor
simbathesailor / PdfPreviewComplete.js
Last active January 27, 2021 08:56
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 || ""}
@simbathesailor
simbathesailor / PdfPreviewComplete.js
Created January 27, 2021 04:53
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 {
@simbathesailor
simbathesailor / PdfPreviewComplete.js
Created January 27, 2021 04:53
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 {
@simbathesailor
simbathesailor / PdfPreviewboilerplate.js
Created January 27, 2021 04:46
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}