Skip to content

Instantly share code, notes, and snippets.

View harshmaur's full-sized avatar
🎯
Focusing

Harsh Maur harshmaur

🎯
Focusing
View GitHub Profile
@harshmaur
harshmaur / get_sheet.py
Created November 5, 2022 07:58
Download Sheet and Get Records
credential_path = "credentials.json" # ensure the path is correct.
sheet_url = "https://docs.google.com/spreadsheets/d/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" # replace with the sheet url
worksheet_name = "Sheet1" # Name of the worksheet you want to access
gc = gspread.service_account(pkg_resources.resource_filename(__name__, credential_path))
sh = gc.open_by_url(sheet_url)
worksheet = sh.worksheet(worksheet_name)
records = worksheet.get_all_records()
df = pd.DataFrame(records)
@harshmaur
harshmaur / _app.tsx
Created October 29, 2022 06:44
GA Tracking _app.tsx
import App, { NextWebVitalsMetric } from 'next/app'
import '../styles/globals.css'
import type { AppProps, AppContext } from 'next/app'
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
function MyApp({ Component, pageProps }: AppProps) {
return (
<Component {…pageProps} />
)
}
@harshmaur
harshmaur / _document.tsx
Created October 29, 2022 06:41
GA Tracking
import Document, { Head, Html, Main, NextScript } from 'next/document'
// You can import from other folder based on your project.
import { GA_TRACKING_ID } from '../utils/constants'
export default class MyDocument extends Document {
render() {
return (
<Html>
<Head>
{/* Global Site Tag (gtag.js) - Google Analytics */}
@harshmaur
harshmaur / index.js
Last active April 9, 2022 09:00
Basic example to generate pdf receipts
const generate = require("@pdfme/generator").generate;
const fs = require('fs');
const path = require('path')
const PDFDocument = require('pdf-lib').PDFDocument
const degrees = require('pdf-lib').degrees
try {
(async () => {
const template = {
"schemas": [
@harshmaur
harshmaur / productlisting.js
Last active May 13, 2021 12:16
Dynamic SEO
const VirtualRefinement = connectRefinementList(() => null)
const ConnectedSort = connectSortBy(({ refine, items, currentRefinement }) => (
<div>
{map(items, item => (
<SortingLink key={item.label} selected={currentRefinement === item.value} onClick={() => refine(item.value)}>
{item.label}
</SortingLink>
))}
</div>