Skip to content

Instantly share code, notes, and snippets.

View tuhinpal's full-sized avatar
🤫
shh... working...

Tuhin Kanti Pal tuhinpal

🤫
shh... working...
View GitHub Profile
@tuhinpal
tuhinpal / drive-protected-pdf-downloader.js
Last active May 11, 2024 11:37
Download google drive protected PDF
// Ensure jsPDF is loaded only if not already present
if (typeof jsPDF === 'undefined') {
const jspdfScript = document.createElement('script');
jspdfScript.onload = function () {
generatePDF();
};
jspdfScript.src = 'https://cdnjs.cloudflare.com/ajax/libs/jspdf/1.3.2/jspdf.min.js';
document.body.appendChild(jspdfScript);
} else {
generatePDF();
@tuhinpal
tuhinpal / Groq.ts
Created February 20, 2024 09:46
Groq Unofficial Wrapper
/**
* Usage:
*
* const groq = new Groq({ initialMessages: [], systemPrompt: "Always give helpful and polite responses." });
* const response = await groq.sendMessage("Hello"); // response.message
*/
import axios from "axios";
const groqApi = axios.create({
@tuhinpal
tuhinpal / NextConf2023-Say-Hi.js
Created September 19, 2023 13:17
Next conf 2023, say hi (Browser Shell)
// This need to be pasted fast (before ws connects!)
let queue = [];
let initial = true;
function handler(wsUrl) {
const ws = new WebSocket(wsUrl);
console.log("Type hi('msg') to send a message!");
setInterval(() => {
@tuhinpal
tuhinpal / nhm-data-transformed.json
Created July 24, 2022 09:32
State/UT wise Central Allocation, Central Release and Expenditure under National Health Mission (NHM) from F.Y. 2013-14 to 2022-23
[
{
"state": "Andaman & Nicobar Islands",
"data": [
{
"fy": "13-14",
"release": 29.13,
"expenditure": 29.19
},
{
echo "Enter service name: "
read servicename
echo "Enter the domain: "
read domain
echo "Enter port: "
read port
echo 'server {
listen 80;
server_name '$domain';
@tuhinpal
tuhinpal / refrigerant-calculation.js
Last active June 4, 2022 15:42
Calculate C.O.P. Mass flow rate per ton, Suction volume, Power of a Refrigerant
let t1 = 20; // celcius
let t2 = 45; // celcius
let sgt1 = 2.4167; // eg sg-5°C
let sgt2 = 2.4368;
let cpgt2 = 1.945;
let hgt1 = 613.8;
let hgt2 = 649.31;
let hft2 = 309.68;
let vgt1 = 0.18823;
@tuhinpal
tuhinpal / index.html
Created October 7, 2021 17:48
Change route without refresh
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Route</title>
</head>
@tuhinpal
tuhinpal / vod-converter.sh
Last active April 16, 2021 22:23
Convert video to hls
echo "Enter input video path with extension (Ex. input.mp4)"
read input_path
echo "Enter output folder (Ex. output)"
read output_path
mkdir $output_path
ffmpeg -hide_banner -y -i $input_path \
-vf scale=w=640:h=360:force_original_aspect_ratio=decrease -c:a aac -ar 48000 -c:v h264 -profile:v main -crf 20 -sc_threshold 0 -g 48 -keyint_min 48 -hls_time 4 -hls_playlist_type vod -b:v 800k -maxrate 856k -bufsize 1200k -b:a 96k -hls_segment_filename $output_path/360p_%03d.ts $output_path/360p.m3u8 \
-vf scale=w=842:h=480:force_original_aspect_ratio=decrease -c:a aac -ar 48000 -c:v h264 -profile:v main -crf 20 -sc_threshold 0 -g 48 -keyint_min 48 -hls_time 4 -hls_playlist_type vod -b:v 1400k -maxrate 1498k -bufsize 2100k -b:a 128k -hls_segment_filename $output_path/480p_%03d.ts $output_path/480p.m3u8 \
@tuhinpal
tuhinpal / setcors.sh
Created March 6, 2021 08:37
Setup Cors for Firebase Storage
echo "Enter the cloud-storage-bucket URL (Starts with gs://): "
read cloud_storage_bucket
echo '[{"origin":["*"],"method":["GET"],"maxAgeSeconds":3600}]' > cors.json
gsutil cors set cors.json $cloud_storage_bucket
rm cors.json
echo "CORS Setted, Now go back to https://github.com/cachecleanerjeet/firecdn"
@tuhinpal
tuhinpal / 02-allow-colord.conf
Created February 21, 2021 11:50
polkit configuration
polkit.addRule(function(action, subject) {
if ((action.id == “org.freedesktop.color-manager.create-device” || action.id == “org.freedesktop.color-manager.create-profile” || action.id == “org.freedesktop.color-manager.delete-device” || action.id == “org.freedesktop.color-manager.delete-profile” || action.id == “org.freedesktop.color-manager.modify-device” || action.id == “org.freedesktop.color-manager.modify-profile”) && subject.isInGroup(“{group}”))
{
return polkit.Result.YES;
}
});