Skip to content

Instantly share code, notes, and snippets.

View SwapnilSoni1999's full-sized avatar
👨‍💻
SGFoYSEgWW91IGRlY29kZWQgaXQuIGxldHMgY29ubmVjdC4K

Swapnil Soni SwapnilSoni1999

👨‍💻
SGFoYSEgWW91IGRlY29kZWQgaXQuIGxldHMgY29ubmVjdC4K
View GitHub Profile
@SwapnilSoni1999
SwapnilSoni1999 / libmagic.ts
Created May 30, 2024 05:57
Universal libmagic file validator, Multer Helper
import fs from 'fs'
import { FileMagic, MagicFlags } from '@npcz/magic'
import { extension } from 'mime-types'
import path from 'path'
import os from 'os'
FileMagic.magicFile = require.resolve(
'@npcz/magic/dist/magic.mgc'
)
@SwapnilSoni1999
SwapnilSoni1999 / validator.middleware.ts
Created May 30, 2024 05:54
Universal zod validator for express.js
import { AnyZodObject, ZodTypeAny } from 'zod'
import {
NextFunction,
Request,
RequestHandler,
Response
} from 'express'
import { HttpError } from '@/lib/errors.lib'
type RequestPayloadIn = 'body' | 'query' | 'params'
@SwapnilSoni1999
SwapnilSoni1999 / screenshot.md
Created November 24, 2023 08:18 — forked from davestewart/broadcast-channel.md
Example of using BroadcastChannel to communicate with pages in the same domain

screenshot

@SwapnilSoni1999
SwapnilSoni1999 / PROGRAMMING_FOR_BEGINNERS.md
Last active June 3, 2022 18:01
A newbie guide for becoming a programmer

Warning: Long post PROGRAMMING FOR BEGINNERS Here, I am going to share stuff how I learned programming and how i progress everyday. Inshort a guide to become self taught programmer. (Ps: I'm no pro or anything Im just a failure and complete noob and telling how to improve everyday and try to be better in your interest, and I also have an anime dp xD iykwim)

  • Before you begin... Get to know why you want to learn, is that to achieve anything? Such as building website or application or game or do some research or anything? Or is it like sharmaji ke ladke ne engineering kiya mai bhi karunga (this thing will never work)
  • Before you know how to code.... Nothing more I should say ... But atleast learn how to use the OS at enough level like commandline of the os (eg. cmd for win or terminal for linux or anything) aisa nahi hona chaiye ki yar ye chiz install karni nahi aati ya fir koi command run karna nahi aata And yes Googling... Believe me learning about your OS is best thing to progress at good speed.
@SwapnilSoni1999
SwapnilSoni1999 / vcf_countrycode.py
Last active January 30, 2022 19:05
Fix Contacts country code - Add country code to those numbers which have missing country code at start to your vcf file
import re
# Edit these
SOURCE_VCF = "27jan22.vcf" # Your source file
COUNTRY_CODE = "+91" # Country code you want to add (Tested for India only)
OUTPUT_VCF = "27jan22-modded.vcf" # The output file you want
# Dont edit below
to_save = []
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import print_function
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
def create_proxyauth_extension(proxy_host, proxy_port,
@SwapnilSoni1999
SwapnilSoni1999 / app.js
Created August 27, 2021 18:29
Express and Socket.io without http module's createServer
const express = require('express')
const socket = require('socket.io')
const PORT = 5000
const app = express()
const server = app.listen(PORT, () => console.log(`Server started on port ${PORT}`))
const io = new socket.Server(server)
@SwapnilSoni1999
SwapnilSoni1999 / README.md
Created May 30, 2020 07:20
google form auto filling script for MCQ.
  • paste in dev console
  • call autofillAnswers function
  • pass answer string eg. "DBCCBDBCADCBADBADABC"
  • eg.
autofillAnswers("DBCCBDBCADCBADBADABC")
@SwapnilSoni1999
SwapnilSoni1999 / extractor.js
Last active August 29, 2020 08:45
google form auto filling script
// extractor works after submitting form and clicking on [View Score] button
// once all correct answers are displayed use this script
function isCorrect(el) {
const val = el.querySelector('[aria-label="Incorrect"]')
return val ? false:true
}
function answerFromIncorrect(el) {
return el.querySelector("div.freebirdFormviewerViewItemsItemGradingCorrectAnswerBoxContent > div > label > div > div.docssharedWizToggleLabeledContent > div > span").innerText.split('.')[0]