Skip to content

Instantly share code, notes, and snippets.

View smashah's full-sized avatar
🏠
Working from home

Mohammed Shah smashah

🏠
Working from home
  • I don't know, yno
  • LHR/JED
View GitHub Profile
@smashah
smashah / gist:21a5c324ec6c02be1cc7f62c21f4a460
Created September 13, 2023 18:42
Simple Script to get the mount path of an SD card on Macbook Pro
system_profiler SPStorageDataType | awk 'BEGIN {RS=""; FS="\n"} /Built In SDXC Reader/ {print $0}' | grep 'Mount Point:' | awk -F': ' '{printf "%s", $2}'
@smashah
smashah / gumroad_docusaurus_cart_fix.js
Created October 13, 2022 02:43
Prevent gumroad cart messing with docusaurus. Reposition cart button sensibly on docusaurus.
(new MutationObserver((mutationList, observer) => {
for (const mutation of mutationList) {
if(mutation.type === "childList" && mutation.addedNodes.find(node=>node.className==="gumroad")) {
console.log('Gattem', mutation);
const grNode = mutation.addedNodes.find(node=>node.className==="gumroad")
const cartbtn = grNode.getElementsByClassName('cart-button')[0]
grNode.style.position = cartbtn.style.position = ''
grNode.style.padding = '4px'
const isMobile = !!document.getElementsByClassName('menu__list').length
const addTo = document.getElementsByClassName('menu__list')[0] || document.getElementsByClassName("navbar__items navbar__items--right")[0]
@smashah
smashah / proxmox-ubuntu-resize
Last active May 1, 2024 10:36
Resize Ubuntu on proxmox hd size
Based on:
https://gist.github.com/gjrdiesel/4e93d8743b71babb58dcba4ee049247c
https://www.reddit.com/r/Proxmox/comments/hkvl9a/cant_extend_ubuntu_20_lvm_after_expanding_raw_disk/
1.
`lsblk`
@smashah
smashah / socket_fallback.js
Created April 11, 2021 06:40
Socket client fallback URL implementation
//the url to try first
const socketUrl = `${window.location.origin}${window.location.pathname.split('/').filter(x=>!x.includes('.')).join('/')}`;
//the url to try next
const fallbackUrl = window.location.origin
//try with main socketUrl
let socket = io(socketUrl);
@smashah
smashah / gar-cleaner-setup.sh
Last active April 2, 2021 20:12 — forked from bhr/gcr-cleaner-setup.sh
gar-cleaner-setup - Google Artifact Registry clean up tool
PROJECT_ID="<YOUR_PROJECT_ID>"
REPO_NAME="<YOUR_REPO_ID>"
CLOUD_RUN_REGION='europe-west1' #us-central1
APP_REGION='europe-west' #us-central
ARTIFACTS_REGION='eu' #leave empty for us
IMAGE_NAMES=("YOUR_IMAGE_1" "YOUR_IMAGE_2") # a list of image names
echo "Step 1: Enable Services"
gcloud services enable --project "${PROJECT_ID}" \
appengine.googleapis.com \
@smashah
smashah / Collector.ts
Created March 16, 2021 16:45
Discord Base Collector implementation for typescript + EventEmitter2
/* eslint-disable @typescript-eslint/no-unused-vars */
/**
* This code is a copy of the Discord Collector: https://github.com/discordjs/discord.js/blob/stable/src/structures/interfaces/Collector.js
* Note: please run `npm i eventemitter2 @discordjs/collection`
* Please see: https://discord.js.org/#/docs/main/stable/class/Collector
*/
import { EventEmitter2 } from 'eventemitter2';
import BaseCollection from '@discordjs/collection';
export class Collection<K, V> extends BaseCollection<K, V> {
@smashah
smashah / lit-media-query.ts
Created January 19, 2021 01:21
Typescript implementation of lit-media-query (with initial test & listener cleanup)
import { LitElement, customElement, property } from 'lit-element';
@customElement('lit-media-query')
export class LitMediaQuery extends LitElement {
@property({ type: Boolean }) _match: boolean = false;
@property({ type: Boolean }) _initFired: boolean = false;
@property({ type: Boolean }) _registeredListeners: boolean = false;
@smashah
smashah / peepeepoopoo.js
Last active June 26, 2020 16:39
peepeepoopoo.js
const p =['oo','ee'];
export const pp = p.slice(0).reverse().map(p=>`p${p} `.repeat(p.length).trim()).join(' ')
//"pee pee poo poo"
console.log(`p${p[1]} p${p[1]} p${p[0]} p${p[0]}`)
//"pee pee poo poo"
@smashah
smashah / wa-magic.ts
Last active June 18, 2020 18:25
Easily get started with wa-automate
import {
create,
Client,
decryptMedia,
ev,
smartUserAgent
} from "@open-wa/wa-automate";
const mime = require("mime-types");
const fs = require("fs");
const ON_DEATH = require("death");
@smashah
smashah / starling_webhook_valid_express.js
Created January 14, 2020 17:01
Successfully validate a Starling Bank webhook signature
//https://stackoverflow.com/questions/56664705/nodejs-base-64-encoding-of-the-sha-512-digest/59738487#59738487
const express = require("express");
const crypto = require('crypto');
const app = express();
const bodyParser = require('body-parser');
app.use(bodyParser.json({
verify: (req, res, buf) => {
req.rawBody = buf