Skip to content

Instantly share code, notes, and snippets.

View aryankarim's full-sized avatar
🛰️

Aryan Karim aryankarim

🛰️
View GitHub Profile
@aryankarim
aryankarim / openMultipleAnchorsWithJavaScript.js
Created February 6, 2024 00:03
Open Multiple Tabs/Anchors with JavaScript
let anchorTags = document.getElementsByTagName('a')
let urls = []
for (let index = 0; index < anchorTags.length; index++) {
const regExp = new RegExp(/^\s*\n*folder-name/g) // use RegExp or water to get the currect anchors
if(regExp.test(anchorTags[index].innerHTML)){
urls.push(anchorTags[index].href)
}
}
for(let i = 0 ; i < urls.length ; i++){
let newWindow = window.open(urls[i])
@aryankarim
aryankarim / tailwind.html
Created September 20, 2023 07:30
Occupy Remaining Height with Tailwind
<div class="tw-h-96 tw-bg-blue-500 tw-flex tw-flex-col">
<div class="tw-h-12 tw-bg-yellow-400 ">close</div>
<div class="tw-h-12 tw-bg-orange-300">tabs</div>
<div class=" tw-flex-1 tw-bg-red-500">data</div>
</div>
https://play.tailwindcss.com/fVWkGy9snb
@aryankarim
aryankarim / webpack-version.txt
Last active September 29, 2022 23:26
get webpack version using NPM
npm view webpack version
@aryankarim
aryankarim / git
Created June 30, 2022 08:05
show number of added and removed lines git command
git log --format='%aN' | sort -u | while read name; do echo -en "$name\t"; git log --author="$name" --pretty=tformat: --numstat | awk '{ add += $1; subs += $2; loc += $1 - $2 } END { printf "added lines: %s, removed lines: %s, total lines: %s\n", add, subs, loc }' -; done
@aryankarim
aryankarim / formatAsTextValue.js
Created June 12, 2022 06:42
reformat array of objects in javascript
function formatAsTextValue(list, { text, value }) {
return list.map((item) => ({ text: item[text], value: item[value] }));
}
formatAsTextValue(
[
{ id: 1, name: "Adam" },
{ id: 2, name: "Alonso" },
],
{ text: "name", value: "id" }
@aryankarim
aryankarim / Debounce.js
Last active April 9, 2022 06:07
Debounce and Throttle
function debounce(cb, wait = 1000) {
let timeout;
return (...args) => {
clearTimeout(timeout);
timeout = setTimeout(cb(...args), wait);
}
}
@aryankarim
aryankarim / Vercel_Commands
Last active February 4, 2022 23:01
Cancel deployment when changes happen in a specific folder on Vercel.
git diff HEAD^ HEAD --quiet ':!<folder_name>'
// E.g. I wanted to stop deployment when changes occured in cypress folder
// I put below code in the Ignored Build Step Command on Vercel
git diff HEAD^ HEAD --quiet ':!cypress'