Skip to content

Instantly share code, notes, and snippets.

{"version":3,"file":"bundles/project.js","mappings":"iDAEA,IAAIA,EAAyB,EAAQ,GACrCC,OAAOC,eAAeC,EAAS,aAAc,CAC3CC,OAAO,IAETD,EAAQE,eAAiBA,EACzB,IAAIC,EAAe,EAAQ,GACvBC,EAAiB,EAAQ,IACzBC,EAA4B,EAAQ,IACpCC,EAAuB,EAAQ,KAC/BC,EAAoB,EAAQ,IAC5BC,EAA0B,EAAQ,IAClCC,EAAa,EAAQ,IACrBC,EAAgBb,EAAuB,EAAQ,KAC/Cc,EAAyB,EAAQ,IACjCC,EAAaf,EAAuB,EAAQ,KAC5CgB,EAAe,EAAQ,KACvBC,EAAc,EAAQ,KAC1B,MAAMC,EAA4B,KAEhCC,QAAQC,KAAK,mFAAmFR,EAAWS,yFAAyFT,EAAWU,6BAA6B,EAE9O,SAASC,GAAkB,aACzBC,EAAY,SACZC,IAEA,MAAMC,GAAqB,EAAIlB,EAA0BmB,4BACnDC,EAAc,IAAItB,EAAauB,YAAYH,EAAoBD,EAAUD,GAC/E,GAAKM,OAAOC,8BAKVZ,QAAQC,KAAK,sDAL4B,CACzCU,OAAOC,+BAAgC,EACvCH,EAAYI,OACd,CAIA,OAAOJ,CACT,CACA,SAASK,EAAKR,IACZ,EAAIlB,EAAe2B,eAAeC,UAClC,IAAK,EAAIxB,EAAwByB,0BAA0BC,gBAmCzDd,EAAkB,CAChBE,iBApCwE,CAC1E,MAAMD,EAAe,IAAIX,EAAcyB,QACjCC,EAAY,IAAIxB,EAAWuB,SACjC,EAAI5B,EAAkB8B,kBAAkB,CACtCC,MAAOvB,EACPwB,GAAIlB,EAAakB,GACjBC,IAAKnB,EAAamB,IAClBC,MAAO1B,EACP2B,qBAAsB3B,EACtB4B,OAAQ,CACNC,KAAM,KACgBxB,EAAkB,CACpCC,eACAC,aAEUuB,YAAY,EAE1BC,OAAQ/B,EACRgC,KAAMhC,EACNiC,M
@moekhalil
moekhalil / Array.prototype.mapKey.js
Last active September 20, 2024 23:18
Just playing with how a native Array.prototype.mapKey would look.
/**
*
* @name: Array.prototype.mapKey
* @author: @moekhalil (GitHub)
*
* @description: A prototype of a native Array.prototype.mapKey that
* would allow users to map over an array of objects
* and return the value of a specific key or nested key
*
* @param prop {string | string[]}
@moekhalil
moekhalil / downloadURLAsFilename.js
Last active September 6, 2022 12:13
Save any file at a url with a provided filename
// Created By : moe | mail is 𝚐𝚑𝚞𝚋-𝚊𝚝-𝚖𝚔𝚑𝚊𝚕𝚒𝚕.𝚘𝚛𝚐
// Uploaded To : https://gist.github.com/moekhalil
// Uploaded Date: 09/06/2022
// Notes : Save any file at a url with a provided filename.
// : Unlike download attribute, this even works with cross-origin urls
const downloadURLAsFilename = async ({ url, fileName }) => {
const mediaItem = await fetch(url);
const mediaBlob = await mediaItem.blob();
@moekhalil
moekhalil / getAllPermissions.js
Last active September 6, 2022 12:09
Get list of all browser permissions.
const getAvailablePermissions = async () => {
const allFeatures = document.featurePolicy
.features()
.sort()
.map((i) => ({ name: i }));
const availablePermissions = [];
const nonPermissionFeatures = [];
for (let index = 0; index < allFeatures.length; index++) {
const feature = allFeatures[index];
@moekhalil
moekhalil / folderFileCounter.sh
Created August 14, 2022 12:07
Nested Folder File Counter
#!/bin/sh
# Usually sitting in my .bash_alias file
folderFileCounter() {
echo -e Directory: .\\\nFiles: `(/usr/bin/find . -maxdepth 1 -type f) | wc -l`
/usr/bin/find . -mindepth 1 -maxdepth 1 -type d -exec sh -c "echo Directory: {}\\\nFiles: \`/usr/bin/find {} -type f | wc -l\`\\\n" \;
}
// Direcory Listing Downloader - "Index Of/" Downloader
// Moe Khalil - me@mkhalil.org
// This is to download files located in directories with directory list permissions enabled
// set MINIMUM_SIZE to filter smaller files.
// File names will be what they are on server with date prepended and host domain appended.
(() => {
// minimum file-size to download
const MINIMUM_SIZE = '800K';
@moekhalil
moekhalil / Craigslist-ImageDownloader.js
Created February 17, 2020 09:49
Craigslist-ImageDownloader.js
const list = document.createElement("ul");
const filenamePre = document.title.split("-")[0].replace(/ /g, ".");
imgList.forEach((i, k) => fetch(i.url).then(x => x.blob()).then(imgBlob => {
const url = URL.createObjectURL(imgBlob);
const imgNum = k + 1;
const item = document.createElement("li");
const ele = document.createElement("a");
ele.innerHTML = `Image ${imgNum} - Download<br />`;
@moekhalil
moekhalil / getSiteVars.js
Created February 25, 2019 10:48
Extract a websites custom global variables. Very not-tested.
const getSiteVars = () => {
const blankWindow = window.open('about:blank');
const defaultKeys = Object.keys(blankWindow);
blankWindow.close();
return Object
.keys(window)
.reduce((all, key) =>
blankWindow.hasOwnProperty(key) ? all : { ...all, [key]: window[key]}
, {}
);