Skip to content

Instantly share code, notes, and snippets.

View pranavgade20's full-sized avatar

Pranav Gade pranavgade20

View GitHub Profile
@pranavgade20
pranavgade20 / merge-pdf.sh
Created November 13, 2022 09:19
A script to merge pdf files and add chapter annottions using ghostscript
#!/bin/bash
# usage: merge-pdf out.pdf `ls -v *.pdf`
merge-pdf() {
cumulative=1
for f in "${@:2}"
do
cnt=$(gs -q -dNODISPLAY -dNOSAFER -c "($f) (r) file runpdfbegin pdfpagecount = quit")
echo "[/Page $cumulative /Title ($f) /OUT pdfmark"
cumulative=$((cnt+cumulative))
@pranavgade20
pranavgade20 / statistics_toolkit.py
Created November 16, 2021 19:56
statistics_toolkit.py
import scipy.stats as stats
import numpy as np
def pearson_correlation_2tail(x: list[int], y: list[int]) -> (float, float):
"""
Calculates the Pearson correlation coefficient and the p-value. double the p val for 1 tailed
:param x: input array 1
:param y: corresponding input 2
:return: (pearson correlation coeff, p value for testing correlation)
@pranavgade20
pranavgade20 / webex_login.py
Last active February 14, 2021 15:12
Webex login script using selenium
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.keys import Keys
from selenium import webdriver
url = "https://meetingsapac33.webex.com/webappng/sites/meetingsapac33/meeting/download/fb2e65ba6d1f8
c7e620174a821a36ac0"
names = {"lci2020010 pranav":"lci2020010@iitl.ac.in"}
@pranavgade20
pranavgade20 / FileServer.java
Last active December 22, 2020 07:17
A simple, one-file HTTP file server(HFS) writen in Java without any external dependencies. I use this to stream videos from computer to other devices on the network.
import java.io.*;
import java.net.*;
import java.nio.file.Files;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
public class FileServer {
public static String BASE_DIR = "/";
public static final int PORT = 8080;
static ServerSocket server;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
public class UDPServer {
public static void main(String[] args) throws Exception {
DatagramSocket socket = new DatagramSocket(6969);
System.out.println("Started server");
while (true) {
byte[] req = new byte[128];
DatagramPacket request = new DatagramPacket(req, req.length);
@pranavgade20
pranavgade20 / server.c
Last active May 3, 2020 08:48
A very shitty server written in C. Do yourself a favour and do not try to use this.
#include <stdio.h>
#include <unistd.h>
#include <sys/socket.h>
#include <stdlib.h>
#include <netinet/in.h>
#include <string.h>
#include <errno.h>
#define PORT 8080
int main(int argc, char const *argv[])
@pranavgade20
pranavgade20 / SSLServer.java
Last active April 12, 2020 16:50
A file server written in java. This was an educational project, and likely has a lot of bugs/issues. I have not followed the specification because I am lazy. Use at your own risk. If you do have any issues though, feel free to reach out to me, I'd e happy to help :)
/* Instructions: generate a keystore using:
keytool -genkey -v -keystore keystore -storepass password -keyalg RSA -keysize 2048
If you change the keystore file name or the keystore password, make sure to do the same in code as well.
*/
import java.io.*;
import java.net.*;
import java.nio.file.Files;
import javax.net.ssl.KeyManagerFactory;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLServerSocket;
@pranavgade20
pranavgade20 / periodic_table.cpp
Created June 10, 2019 04:11
A program to print details about elements of the periodic table. A dirty hack thrown together in 30mins. Feel free to plagiarize!
#include <iostream>
std::string names[119] = {"Hydrogen", "Helium", "Lithium", "Beryllium", "Boron", "Carbon", "Nitrogen", "Oxygen", "Fluorine", "Neon", "Sodium", "Magnesium", "Aluminium", "Silicon", "Phosphorus", "Sulfur", "Chlorine", "Argon", "Potassium", "Calcium", "Scandium", "Titanium", "Vanadium", "Chromium", "Manganese", "Iron", "Cobalt", "Nickel", "Copper", "Zinc", "Gallium", "Germanium", "Arsenic", "Selenium", "Bromine", "Krypton", "Rubidium", "Strontium", "Yttrium", "Zirconium", "Niobium", "Molybdenum", "Technetium", "Ruthenium", "Rhodium", "Palladium", "Silver", "Cadmium", "Indium", "Tin", "Antimony", "Tellurium", "Iodine", "Xenon", "Cesium", "Barium", "Lanthanum", "Cerium", "Praseodymium", "Neodymium", "Promethium", "Samarium", "Europium", "Gadolinium", "Terbium", "Dysprosium", "Holmium", "Erbium", "Thulium", "Ytterbium", "Lutetium", "Hafnium", "Tantalum", "Tungsten", "Rhenium", "Osmium", "Iridium", "Platinum", "Gold", "Mercury", "Thallium", "Lead", "Bismuth", "Polonium", "Astatine", "Radon", "Fr
# This script Build GCompris from source for you, including the dependencies, hopefully without any errors.
# Installation is hone in the home directory. To change, replace the path below.
cd ~
# So that we have to enter the password only once
sudo -H su
# Install dependencies + Qt
apt-get install -y cmake g++ libgl1-mesa-dev qtdeclarative5-dev libqt5svg5-dev qml-module-qtquick-particles2 qttools5-dev-tools libqt5xmlpatterns5-dev qml-module-qtmultimedia qt5-default qml-module-qtgraphicaleffects qt5-qmake qtcreator qtmultimedia5-dev qttools5-dev qttools5-dev-tools libqt5multimedia5-plugins qml-module-qtsensors libqt5quickparticles5 qml-module-qtquick2 qml-module-qtquick-particles2 libqt5sensors5-dev libqt5sensors5