Skip to content

Instantly share code, notes, and snippets.

View arafathusayn's full-sized avatar
👨‍💻
Focusing

Arafat Husayn arafathusayn

👨‍💻
Focusing
View GitHub Profile
@arafathusayn
arafathusayn / urls-to-stream.js
Created July 27, 2021 18:53
Get a single readable stream of contents from multiple URLs on Node.js
const { Readable } = require("stream");
const { default: got } = require("got");
/**
* @param {string[]} [urls]
* @param {import("got").Options} [options]
* @return {Promise<Readable>} `Promise<Readable>`
*/
const getStreamFromUrls = async (urls = [], options = {}) => {
async function* generateChunk() {
const pipe = (...args: any[]) =>
args.reduce(
(prev, curr) => (typeof curr === "function" ? curr(prev) : curr),
args[0],
);
export default pipe;
@arafathusayn
arafathusayn / removing_script.js
Last active May 8, 2024 03:33
Remove Tawk.to Branding (2022)
var removeBranding = function() {
try {
var element = document.querySelector("iframe[title*=chat]:nth-child(2)").contentDocument.querySelector(`a[class*=tawk-branding]`)
if (element) {
element.remove()
}
} catch (e) {}
}
@arafathusayn
arafathusayn / parse-xml.js
Created March 3, 2021 09:52
Postman Test Script - Parse XML API response & set environment variables from the parsed data
var parseString = require("xml2js").parseString;
var xml = pm.response.text();
parseString(xml, (err, data) => {
if (err) throw err;
// traverse and set env variable
pm.environment.set("ENV_NAME_HERE", data.whatever);
});
@arafathusayn
arafathusayn / redirect.ts
Last active July 11, 2022 16:10
Vercel Serverless Function for getting redirected URL from short-link services
import got from "got";
import { VercelRequest, VercelResponse } from "@vercel/node";
const redirect = async (request: VercelRequest, response: VercelResponse) => {
const url: string | undefined =
(request.query && request.query.url) || (request.body && request.body.url);
if (
(request.method === "GET" || request.method === "POST") &&
typeof url === "string" &&
@arafathusayn
arafathusayn / apt-install-chrome-deps.sh
Created September 8, 2020 15:23
Chromium Linux Dependencies
sudo apt install -y ca-certificates fonts-liberation libappindicator3-1 libasound2 libatk-bridge2.0-0 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgbm1 libgcc1 libglib2.0-0 libgtk-3-0 libnspr4 libnss3 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 lsb-release wget xdg-utils
@arafathusayn
arafathusayn / worker.js
Last active September 6, 2020 10:40
Cloudflare Worker as Redirected URL Resolver
addEventListener("fetch", (event) => {
event.respondWith(handleRequest(event.request));
});
/**
* Respond to the request
* @param {Request} request
* @returns {Response}
*/
async function handleRequest(request) {
@arafathusayn
arafathusayn / Emoji-on-Ubuntu.md
Last active June 6, 2024 07:14
Guide to enable system-wide Emoji support on Ubuntu 🤩

1. Install Fonts

sudo apt install fonts-noto-color-emoji

2. Add Font Configuration

  • Open ~/.config/fontconfig/conf.d/01-emoji.conf file in an editor.
  • Copy-paste the lines below:
@arafathusayn
arafathusayn / eslint_prettier_airbnb.md
Last active July 9, 2020 14:23 — forked from bradtraversy/eslint_prettier_airbnb.md
ESLint, Prettier & Airbnb Setup

VSCode - ESLint, Prettier, Airbnb & Custom Rules Setup

1. Install ESLint & Prettier extensions for VSCode

Optional - Set format on save and any global prettier options

2. Install Packages

npm i -D eslint prettier eslint-plugin-prettier eslint-config-prettier eslint-plugin-node eslint-config-node
@arafathusayn
arafathusayn / make-encrypted-hls-vod.sh
Last active May 13, 2022 20:59
Bash script to create AES-encrypted HLS VOD using ffmpeg. Usage: ./make-encrypted-hls-vod.sh <path to video file>
#!/bin/bash
openssl rand 16 > enc.key
printf "enc.key\nenc.key\n$(openssl rand -hex 16)" > enc.keyinfo
mkdir -p ./hls
ffmpeg -y \
-i "$1" \