Skip to content

Instantly share code, notes, and snippets.

View ahmadthedev's full-sized avatar

Ahmad Tahir ahmadthedev

View GitHub Profile
@mrizwan47
mrizwan47 / lazy-load.html
Last active April 12, 2022 19:30
Minimal VanillaJS LazyLoad Images using Intersection Observer
<!DOCTYPE html>
<html>
<head>
<title>Title of the document</title>
</head>
<body>
<img loading="lazy" data-lazy
src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkqAcAAIUAgUW0RjgAAAAASUVORK5CYII="
@devidw
devidw / wc-variation-linking.js
Last active May 7, 2023 07:57
WooCommerce direct variation URL for variable products
/**
* Little JS snippet to automatically update the WooCommerce single product page URL with the needed parameters for the active variations' selection.
*
* Each time the user changes the variation selection, the URL is updated with the new parameters, so on hard refresh the selected variation is displayed.
*
* Also, fast way to get the direct URL to the selected variation.
*
* Paste it into your browser console and run it. Or use it in your theme/plugins.
*
* @see https://stackoverflow.com/a/73138077/13765033
@mrizwan47
mrizwan47 / pandas_df_to_csv_in_chunks.py
Created January 26, 2023 11:30
Save Pandas dataframe to csv in chunks
import pandas as pd
df = pd.read_csv('large_file.csv')
n = 49000 # Max number of rows you want each chunk to have
chunks = [df[i:i+n].copy() for i in range(0,df.shape[0],n)]
k = 1
for chunk in chunks:
chunk.to_csv('data/chunk_{}.csv'.format(k), index=False)