A collection of Python Scripts made for fun, while exploring Python 🐍

Overview

JFF-Python-Scripts

A collection of Python Scripts made for fun, while exploring Python 🐍

Inspiration 💡

Many of the programs in this repository are inspired from the projects given in Automate the Boring Stuff with Python by Al Sweigart and some other are born out of redundant curiosity of a boring mind during lazy afternoons.

This repository would contain python scripts, some of which might come of use occasionally. The purpose of creating this is to explore the various modules and implementations of the language through creating programs that are as much fun to use as they are to make.

How to Use? 😀

  • Clone the repository $ git clone https://github.com/thepushkarp/JFF-Python-Scripts.git
  • Create a virtual environment (click here to learn about Virtual Environment)
virtualenv env
  • Activate virtual environment (On macOS and Linux)
source env/bin/activate
  • Activate virtual environment (On Windows)
.\env\Scripts\activate
  • Install requirements
pip3 install -r requirements.txt
  • Run and explore the scripts!

NOTE: All the scripts are written in Python 3. So, make sure to use the appropriate version of pip and python.

Contents 📄

Code Destroyer

Code Destroyer, inspired by a tweet by Ben Johnson, replaces semicolon ";" (U+003B) in files with a Greek Question Mark ";" (U+037E), that looks alike, but shows syntax errors (since it is a different character) leaving the programmer scratching their heads in confusion. ;-)

Usage:

Put the file to be destroyed in the same folder as this script and run:

python3 codeDestroyer.py

Enter the full filename (like helloWorld.c) in the prompt that follows.

Disclaimer: Do not use this to prank on someone's hard-work. You know how frustating that feels.

Extract Phone Number and Email

Takes in the text from your clipboard and saves the Phone Numbers and Email Addresses found in it to .txt files. It searches for Indian Mobile Phone Numbers, Toll-Free Numbers, Telephone Numbers and Emails using Regular Expressions.

Useful if you have a large text data (like a website) and you are searching for phone numbers of emails in that text.

Usage:

python3 phoneAndEmail.py

Two files, emails.txt and phoneNumbers.txt would be created in the same directory containing the emails and phone numbers from the copied text.

Search files based on size

Lets you search through a folder based on file size. Asks user for folder path and size. Files and subfolders inside the folder, greater than or equal to the input size would be displayed.

Useful if you want to find large files and folders taking up space and wish to delete them.

Usage:

python3 searchSize.py

When prompted, enter the minimum size (in bytes) and the folder where files are to be searched. If the path entered is correct, the files, above and equal the size entered would be displayed.

Fill gaps in naming

Finds all files with a given prefix, such as spam001.txt, spam002.txt, and so on, in a single folder and locates any gaps in the numbering (such as if there is a spam001.txt and spam003.txt but no spam002.txt) and reanames all the files to close this gap.

Useful if you have a number of files with same prefix and numbering after it and by some case, there is irregularity in numbering (like after deleting unnecessary images from a camera) and you wish to get a ragular naming in those files.

Usage:

python3 fillGap.py

Enter the file prefix, extesion name and taret folder in the prompt that appears. The files would be named in order, closing gaps, if any.

Combine PDF files

Combines all the PDFs in the current working directory into a single PDF. The program also prompts user if they want to include the cover page of all the PDFs that are being merged.

It is recommended to rename files so that they are lexographically in the same order as they are to be combined and put them in the same directory as the script. The combined PDF would be saved as the name of the first file in the lexographic order prepended with 'combined'.

Useful if you have many PDF and you want to read them all one after the another (like all the PDFs of a professor's slides that you wish to read before exams). You won't need to go from one PDF to another after using this and would also have the option of adding or removing the coverpage of each PDF.

Ensure that none of the PDFs are encrypted.

Usage:

python3 combinePDF.py

Choose whether you want to include the cover page of each individual PDF by entering y or n.

Add Watermark to PDF

Add watermark to every page of a PDF document.

The watermark file should be a PDF too. If you want to make an image or text as a watermark, put them in a word file and stylize as per you want it to appear as the watermark and then export the file as PDF. This file would be the watermark file.

The usefullness of this script is straightforward - To add watermark to PDF files to prove its originality, make it harder to copy, and add authorship.

Ensure that none of the PDFs are encrypted.

Usage:

python3 addWatermarkPDF.py

Enter the filenames of the PDF to be watermarked and then of the watermark PDF.

Encrypt or Decrypt a PDF

Encrypt an unencrypted PDF file with a password or decrypt a password-protected PDF and save as an unencrypted file.

The usefullness of this script too is pretty straightforward - To add or remove privacy to PDF files.

Usage:

python3 encryptDecryptPDF.py

Choose whether you want to encrypt or decrypt a PDF and then enter the name of the file. You would be prompted to enter the password either to encrypt the PDF or decrypt it, as selected earlier.

Add Logo to Images

Adds logo to the lower-right corner of all the pngs, jpgs and jpegs in the directory. The size of logo is approximately 1/10 th of the size of the image and has a padding of 1/25 th to the right and bottom of the logo is added.

Useful to add logos to images to prove their originality, make them harder to copy, and add authorship.

Usage:

python3 addLogo.py

Enter the location of the logo file in the prompt that follows. All the images with added logo would be saved in the 'withLogo' directory.

License

MIT License


File Templates taken from awesome-bashrc and HackerRank-Test-Case-Generator.

Made with by Pushkar Patel

Owner
Pushkar Patel
Research Intern at SPIRE Labs, IISC Bangalore | GitHub Campus Expert @iiitv
Pushkar Patel
A Python program to easily solve the n-queens problem using min-conflicts algorithm

QueensProblem A program to easily solve the n-queens problem using min-conflicts algorithm Performances estimated with a sample of 1000 different rand

0 Oct 21, 2022
Genetic Algorithm for Robby Robot based on Complexity a Guided Tour by Melanie Mitchell

Robby Robot Genetic Algorithm A Genetic Algorithm based Robby the Robot in Chapter 9 of Melanie Mitchell's book Complexity: A Guided Tour Description

Matthew 2 Dec 01, 2022
FPE - Format Preserving Encryption with FF3 in Python

ff3 - Format Preserving Encryption in Python An implementation of the NIST approved FF3 and FF3-1 Format Preserving Encryption (FPE) algorithms in Pyt

Privacy Logistics 42 Dec 16, 2022
A custom prime algorithm, implementation, and performance code & review

Colander A custom prime algorithm, implementation, and performance code & review Pseudocode Algorithm 1. given a number of primes to find, the followi

Finn Lancaster 3 Dec 17, 2021
🧬 Training the car to do self-parking using a genetic algorithm

🧬 Training the car to do self-parking using a genetic algorithm

Oleksii Trekhleb 652 Jan 03, 2023
The test data, code and detailed description of the AW t-SNE algorithm

AW-t-SNE The test data, code and result of the AW t-SNE algorithm Structure of the folder Datasets: This folder contains two datasets, the MNIST datas

1 Mar 09, 2022
Visualisation for sorting algorithms. Version 2.0

Visualisation for sorting algorithms v2. Upped a notch from version 1. This program provides animates simple, common and popular sorting algorithms, t

Ben Woo 7 Nov 08, 2022
Algoritmos de busca:

Algoritmos-de-Buscas Algoritmos de busca: Abaixo está a interface da aplicação: Ao selecionar o tipo de busca e o caminho, então será realizado o cálc

Elielson Barbosa 5 Oct 04, 2021
How on earth can I ever think of a solution like that in an interview?!

fuck-coding-interviews This repository is created by an awkward programmer who always struggles with coding problems on LeetCode, even with some Easy

Vinta Chen 613 Jan 08, 2023
frePPLe - open source supply chain planning

frePPLe Open source supply chain planning FrePPLe is an easy-to-use and easy-to-implement open source advanced planning and scheduling tool for manufa

frePPLe 385 Jan 06, 2023
Ralebel is an interpreted, Haitian Creole programming language that aims to help Haitians by starting with the fundamental algorithm

Ralebel is an interpreted, Haitian Creole programming language that aims to help Haitians by starting with the fundamental algorithm

Lub Lorry Lamysère 5 Dec 01, 2022
This repository explores an implementation of Grover's Algorithm for knights on a chessboard.

Grover Knights Welcome to my Knights project! Project Description: I explore an implementation of a quantum oracle for knights on a chessboard.

Will Sun 8 Feb 22, 2022
implementation of the KNN algorithm on crab biometrics dataset for CS16

crab-knn implementation of the KNN algorithm in Python applied to biometrics data of purple rock crabs (leptograpsus variegatus) to classify the sex o

Andrew W. Chen 1 Nov 18, 2021
This repository provides some codes to demonstrate several variants of Markov-Chain-Monte-Carlo (MCMC) Algorithms.

Demo-of-MCMC These files are based on the class materials of AEROSP 567 taught by Prof. Alex Gorodetsky at University of Michigan. Author: Hung-Hsiang

Sean 1 Feb 05, 2022
Repository for data structure and algorithms in Python for coding interviews

Python Data Structures and Algorithms This repository contains questions requiring implementation of data structures and algorithms concepts. It is us

Prabhu Pant 1.9k Jan 01, 2023
Algorithmic trading backtest and optimization examples using order book imbalances. (bitcoin, cryptocurrency, bitmex)

Algorithmic trading backtest and optimization examples using order book imbalances. (bitcoin, cryptocurrency, bitmex)

172 Dec 21, 2022
Our implementation of Gillespie's Stochastic Simulation Algorithm (SSA)

SSA Our implementation of Gillespie's Stochastic Simulation Algorithm (SSA) Requirements python =3.7 numpy pandas matplotlib pyyaml Command line usag

Anoop Lab 1 Jan 27, 2022
Minimal examples of data structures and algorithms in Python

Pythonic Data Structures and Algorithms Minimal and clean example implementations of data structures and algorithms in Python 3. Contributing Thanks f

Keon 22k Jan 09, 2023
QDax is a tool to accelerate Quality-Diveristy (QD) algorithms through hardware accelerators and massive parallelism

QDax: Accelerated Quality-Diversity QDax is a tool to accelerate Quality-Diveristy (QD) algorithms through hardware accelerators and massive paralleli

Adaptive and Intelligent Robotics Lab 183 Dec 30, 2022
Path tracing obj - (taichi course final project) a path tracing renderer that can import and render obj files

Path tracing obj - (taichi course final project) a path tracing renderer that can import and render obj files

5 Sep 10, 2022