From 7e07a09c20ed93dc41e7c99e8b94c274defbabee Mon Sep 17 00:00:00 2001 From: Khushal Sharma Date: Tue, 7 Nov 2017 14:08:15 +0530 Subject: [PATCH 1/2] develop updation (#80) * added badge (#36) * Update README.md (#37) * image to vector data (#35) * image to vector data * added description * Develop (#38) * added badge * Added bullets to the script's headlines * add offline dictionary (#45) * Update README.md * add dictionary * Sort scripts alphabetically (#48) * Set theme jekyll-theme-minimal * Set theme jekyll-theme-architect * Updated readme.md * Update README.md * Update README.md * Added a python script to download high quality videos and audio using youtube-dl. (#49) * Added a python script to download high quality videos using youtube-dl. * Added Video Downloader and updated readme * Changed Readme. * fixed Readme. * Feature/ftp download (#51) * add ftp_download_file.py * Add help to README.md * Add ehnydeel to README.md as contributer * Change order of FTP-Download in README.md * added URL shortener (#55) * desciption of the Twitter_retweet_bot script (#54) This is the description for the twitter_retweet_bot script. * added script to download formatted tweets from a specific user (#50) * Meme density correction (#56) * added cloud script (#57) * Update README.md (#59) I adjusted the mark down, so that the scripts next to one another will be distinct. * Twitter retweet bot (#44) * Added a dice simulator * Added a twitter retweet bot * updated readme (#60) * Updated README.md (#61) * Update README.md (#62) * Sentiment Analysis of Twitter Feeds (#64) * Sentiment Analysis of Twitter Feeds * required installations added * Update readme.md * README.md (#72) added my name in contributors * Edited the readme and arranged alphabetically (#75) * Lost Robot script is added (#63) * Create quiz * Added Solution.py for Lost Robot * Add new Feature getExternalIp.py (#53) * Add getExternalIp.py script to bin/ * Update README.md Add getExternalIp.py to documentation README.md * Update README.md * Add fetch_html script (#52) * arranged root file directory * Added : readme.md (#78) added back to top button * Added : Readme.md (#79) added more badges --- README.md | 266 +++++++-- _config.yml | 1 + bin/Blog_reader.py | 36 +- bin/ImageData/encodeData.json | 2 +- bin/ImagetoData.py | 20 + bin/Lost Robot/Solution.py | 15 + bin/Lost Robot/quiz | 34 ++ bin/Pyfirebase.py | 36 +- bin/Video-downloader/license.txt | 201 +++++++ bin/Video-downloader/vid.py | 107 ++++ bin/bulk_add_twitter_list.py | 44 +- bin/caesar_cipher.py | 84 +-- bin/dice_simulator.py | 10 + bin/dictionary/app.py | 17 + bin/dictionary/dict_dialog.py | 56 ++ bin/dictionary/dictionary.py | 25 + bin/end_to_end.py | 78 +-- bin/expense_manager.py | 680 +++++++++++----------- bin/facebook-auto-post.py | 82 +-- bin/facebook-auto-post.requirements.txt | 2 +- bin/fetch_html.py | 15 + bin/ftp_download_file.py | 49 ++ bin/getExternalIp.py | 11 + bin/image_encoder.py | 50 +- bin/integrate-graph.py | 164 +++--- bin/locate-me.py | 60 +- bin/memedensity.py | 268 ++++----- bin/mi-community-bot.py | 98 ++-- bin/mi-community-bot.requirements.txt | 2 +- bin/missionaries_and_cannibals_problem.py | 206 +++---- bin/password-strength-checker.py | 38 +- bin/pi.py | 30 +- bin/plot_example.py | 16 +- bin/server_client/client.py | 32 +- bin/server_client/server.py | 28 +- bin/shortener.py | 24 + bin/tweetload.py | 59 ++ bin/twitter_retweet_bot.py | 31 + bin/youtube-bot-linux.py | 20 +- bin/youtube-bot-windows.py | 20 +- 40 files changed, 1934 insertions(+), 1083 deletions(-) create mode 100644 _config.yml create mode 100644 bin/ImagetoData.py create mode 100644 bin/Lost Robot/Solution.py create mode 100644 bin/Lost Robot/quiz create mode 100644 bin/Video-downloader/license.txt create mode 100644 bin/Video-downloader/vid.py create mode 100644 bin/dice_simulator.py create mode 100644 bin/dictionary/app.py create mode 100644 bin/dictionary/dict_dialog.py create mode 100644 bin/dictionary/dictionary.py create mode 100644 bin/fetch_html.py create mode 100644 bin/ftp_download_file.py create mode 100644 bin/getExternalIp.py create mode 100644 bin/shortener.py create mode 100644 bin/tweetload.py create mode 100644 bin/twitter_retweet_bot.py diff --git a/README.md b/README.md index dd5823d..47811a2 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,9 @@ +# [Python Scripts](https://logan1x.github.io/Python-Scripts/) # Python Scripts [![forthebadge](http://forthebadge.com/images/badges/made-with-python.svg)](http://forthebadge.com) - +[![forthebadge](http://forthebadge.com/images/badges/made-with-python.svg)](http://forthebadge.com) +[![forthebadge](http://forthebadge.com/images/badges/built-by-developers.svg)](http://forthebadge.com) +[![forthebadge](http://forthebadge.com/images/badges/check-it-out.svg)](http://forthebadge.com) > This Repo is a collection of Various python scripts. In this repo there are different kinds of python scripts for their respective uses. These all are open sourced and you can use them in any form for free. @@ -18,16 +21,65 @@ cd Python-Scripts/bin ``` ## Scripts +* ### Approximating *pi* + +This script is useful to show a way to approximate the value of pi using a Monte Carlo method. It is also optimized using the `@jit` (*just-in-time*) decorator from the [numba](https://numba.pydata.org/) library. + * ### Meme Density This script tells you the amount of memes in your facebook feed +To see different approximations you just need to modify the argument passed to the main function. ```bash -pip install memedensity +python pi.py +``` -memedensity +* ### Blog Reader + +Blog Reader is the terminal reader that scrapes the article from [planet dgplug](http://planet.dgplug.org/) and displays it on the terminal. + +It seprates the content accrding to the screen size. + +```bash +python Blog_reader.py +``` + +* ### Bulk add users to Twitter list + +Simple script helps you mass add users to your twitter list to follow (Ex: Bitcoin/Altcoins official account, news, traders...) + +- Prepare list screen names +- Setup your app and get an access token + +```bash +pip install twitter +python bulk_add_twitter_list.py +``` + + +* ### Caesar Cipher +Encrypts or Decrypts any message you want, simply enter the message and the rotation number +```bash +python caesar_cipher.py +``` + +* ### End To End Encryption +It is a simple program to implement and understand the basic of end_to_end encryption. +Here i am using caesar cipher to encrpt nbut in reality they Use algotihms lile SHA-1, RSA etc. +```bash +python end_to_end.py +``` + + +* ### Expense Manager +Simple GUI program which helps you calculate your expenses, monitor them just through mouse clicks. All you have to do is run the script and choose an option from the menu which will displayed when you run the script. Enter Your Expenses as eg: "Biscuits Rs 15" " rs " ignore the quotes. + +```bash +python expense_manger.py ``` + + * ### Facebook Auto Post This is python script that log in into facebook and post the status. @@ -39,6 +91,60 @@ pip install -r facebook-auto-post.requirements.txt python facebook-auto-post.py ``` + +* ### Find Large Files + +Searches a file location and subdirectories for files larger than a given size. +Useful for phones which might hide files in FileExplorer, but allow use as flash memory. +Directly prints results if run directly. +May also be imported, yielding results one by one. + +* ### FTP Download File +A simple application to download a file via FTP with the given remote and local path +Parameters: + * -hh hostname + * -u username + * -p password + * -rd remote directory + * -ld local directory +```bash +python ftp_download_file.py + +* ### Fetch HTML +This script fetch html response from the provided url and parse xml tag to get only text content and print out. + +```bash +python fetch_html.py https://github.com +`````` + +* ### Get External IP +Gets the external ip-address from the current machine and prints it to the console +```bash +python getExternalIp.py +``` + +* ### Handy offline dictionary +A tiny offline dictionary app based on nltk wordnet and pyqt5 +```bash +cd dictionary +python app.py +``` + + +* ### Image Encoder +It is a simple program to encode and decode images, which helps to reduce and handle images on server, as it is convertedto base64 address. +```bash +python image_encoder.py +``` + + +* ### Integrate to find area of a graph +The script takes a given graph along with the range within which the area is to be calculated. +It then calculates the area using two methods, the Simpson method and the Trapezoid method and displays the results on a graph. +```bash +python integrate-graph.py +``` + * ### Locate Me Run this script and it will locate you. @@ -57,6 +163,18 @@ This uses [Checkip](http://checkip.dyndns.com/) and [ipinfo.io](http://ipinfo.io python locate-me.py ``` + + +* ### Meme Density +This script tells you the amount of memes in your facebook feed + + +```bash +pip install memedensity + +memedensity +``` + * ### Mi Community Bot This python script uses selenium module in python to automate the thread posting. @@ -68,7 +186,11 @@ If you want to understand this code you can visit [here.](https://l0gan1x.quora. pip install -r mi-community-bot.requirements.txt python mi-community-bot.py ``` - +* ### Missionaires And Cannibals Problem +It is a simple program to mimic Missionaries And Cannibals River Crossing Problem. +```bash +python missionaries_and_cannibals_problem.py +``` * ### Password Strength Checker This code checks for your password strength. For the right password, password must contain mixture of an upper case letters, an digit (including 0-9), and a special characters with lower case letters. @@ -76,76 +198,104 @@ This code checks for your password strength. For the right password, password mu ```bash python password-strength-checker.py ``` +* ### Plotting a function +This script contains an example of plotting a function using [`matplotlib`](http://matplotlib.org/). Feel free to modify the value of `y` to obtain different functions that depend on `x`. * ### YouTube Bot This is a simple python script that increases your video count/ views. Log out from all google accounts and run this. - ```bash -# For Linux Users -python youtube-bot-linux.py - -# For Windows Users -python youtube-bot-windows.py +python plot_example.py ``` -#### NOTE: -In case your browser stoped working delete/comment the following line in the script. -#### _Linux_ - `os.system(" killall -9 " + brow)` -#### _Windows_ - `os.system("TASKKILL /F /IM " + brow + ".exe")` + +* ### Server And Client +It is simple client server communication script, will add more functionality in future. +```bash +cd server_client +python client.py +python server.py +``` +* ### Tweetload +Download latest tweets (default: up to 4000) from a specific twitter user. The script will create a file with one tweet per line, stripped from mentions, hashtags and links. +
+For that to work, create a json file with your twitter credentials (see source) and define the twitter user in source code. +```bash +python3 tweetload.py +``` * ### Blog Reader -Blog Reader is the terminal reader that scrapes the article from [planet dgplug](http://planet.dgplug.org/) and displays it on the terminal. +* ### Twitter_retweet_bot +It is a simple script that retweets any hashtag provided in it. +```bash +python twitter_retweet_bot.py +``` +* ### Twitter Sentiment Analysis +A python script that goes through the twitter feeds and calculates the sentiment of the users on the topic of Demonetization in India. +Sentiments are calculated to be positive, negative or neutral. +Various other analyses are represented using graphs. + +```bash +pip install -r analyseTweets-requirements.txt +python analyseTweets.py +``` -It seprates the content accrding to the screen size. + +* ### URL Shortener +This is python script that shortens any URL provided to it. ```bash -python Blog_reader.py +# Takes multiple inputs and returns shortened URL for both +python shortener.py url1 url2 + +#Stores shortened URLs in a file +python shortener.py url1 url2 > file.txt ``` * ### Find Large Files -Searches a file location and subdirectories for files larger than a given size. -Useful for phones which might hide files in FileExplorer, but allow use as flash memory. -Directly prints results if run directly. -May also be imported, yielding results one by one. +* ### Video-downloader v1.1 -* ### Approximating *pi* +#### About -This script is useful to show a way to approximate the value of pi using a Monte Carlo method. It is also optimized using the `@jit` (*just-in-time*) decorator from the [numba](https://numba.pydata.org/) library. -To see different approximations you just need to modify the argument passed to the main function. +This file allows the user to download videos off of the web. +* ### Approximating *pi* +as of version 1 the user is able to download highquality videos as a playlist or single file as well as audio files from the supported -```bash -python pi.py -``` +websites given here http://rg3.github.io/youtube-dl/supportedsites.html are supported. +More features will be added in the future iterations of the project. +a simple video downloader using youtube-dl Library, a starter script for making use +of youtube-dl. +#### Requirements +* You will need to install youtube_dl + * This can be installed using pip on windows, + * if you do not know how to use pip please read the installation instructions +* requests library + * can be downloaded using pip on windows and respective package managers on different operating systems. +* ffmpeg in order to convert the downloaded files to the right format * ### Plotting a function -This script contains an example of plotting a function using [`matplotlib`](http://matplotlib.org/). Feel free to modify the value of `y` to obtain different functions that depend on `x`. - -```bash -python plot_example.py -``` +#### Installation +clone this repo and run `python vid.py` script! +assuming you already have the other requirements. +#### FFmpeg * ### Bulk add users to Twitter list +Follow this wiki-How tutorial -Simple script helps you mass add users to your twitter list to follow (Ex: Bitcoin/Altcoins official account, news, traders...) +http://www.wikihow.com/Install-FFmpeg-on-Windows -- Prepare list screen names -- Setup your app and get an access token +#### PIP -```bash -pip install twitter -python bulk_add_twitter_list.py -``` +Extensive information on how to set up virtual env and pip. +https://www.dabapps.com/blog/introduction-to-pip-and-virtualenv-python/ * ### Expense Manager Simple GUI program which helps you calculate your expenses, monitor them just through mouse clicks. All you have to do is run the script and choose an option from the menu which will displayed when you run the script. Enter Your Expenses as eg: "Biscuits Rs 15" " rs " ignore the quotes. @@ -175,8 +325,14 @@ Here i am using caesar cipher to encrpt nbut in reality they Use algotihms lile ```bash python end_to_end.py ``` +#### Commands +Just run the script and follow the interface! Videos downloaded in same folder as the script. + +* ### YouTube Bot +This is a simple python script that increases your video count/ views. +Log out from all google accounts and run this. * ### Server And Client It is simple client server communication script, will add more functionality in future. ```bash @@ -189,8 +345,18 @@ python server.py The script takes a given graph along with the range within which the area is to be calculated. It then calculates the area using two methods, the Simpson method and the Trapezoid method and displays the results on a graph. ```bash -python integrate-graph.py +# For Linux Users +python youtube-bot-linux.py + +# For Windows Users +python youtube-bot-windows.py ``` +#### NOTE: +In case your browser stoped working delete/comment the following line in the script. +#### _Linux_ + `os.system(" killall -9 " + brow)` +#### _Windows_ + `os.system("TASKKILL /F /IM " + brow + ".exe")` ## Release History @@ -198,6 +364,7 @@ python integrate-graph.py * 0.0.1 * Work in progress + ## Meta Khushal Sharma – [@Khushal](https://twitter.com/herkuch) – sharmakhushal78@gmail.com @@ -220,7 +387,7 @@ Distributed under the MIT LICENSE license. See [``LICENSE``](https://github.com/ ## Contributors The following people helped in creating the above content. - +* Niharika Krishnan * Khushal Sharma * Kayvan Mazaheri * Lakshay Kalbhor @@ -232,6 +399,15 @@ The following people helped in creating the above content. * Madhav Bahl * Ishank Arora * Vishal Sharma -* Shivam Pachaori +* Apurva Nitanjay +* Surya K +* Peter L. +* Andreas K. +* Jetsada Machom +* Lukas S. +* Iyanu Ashiri + +### If you like the project give a star [Star button](https://github.com/Logan1x/Python-Scripts/stargazers) + -### If you like the project give a star Star button +[`Back to Top`](https://github.com/Logan1x/Python-Scripts#python-scripts) diff --git a/_config.yml b/_config.yml new file mode 100644 index 0000000..3397c9a --- /dev/null +++ b/_config.yml @@ -0,0 +1 @@ +theme: jekyll-theme-architect \ No newline at end of file diff --git a/bin/Blog_reader.py b/bin/Blog_reader.py index a88f952..c1d9a14 100644 --- a/bin/Blog_reader.py +++ b/bin/Blog_reader.py @@ -1,18 +1,18 @@ -from bs4 import BeautifulSoup -import requests -import shutil -page = requests.get("http://planet.dgplug.org/") -soup = BeautifulSoup(page.content, 'html.parser') -data = soup.find_all(class_="entrygroup") -columns = shutil.get_terminal_size().columns -size = len(data)-1 -for i in range(0, size): - piu = data[i] - heading = piu.find("a").get_text() - for n in range(84): - print ("-", end=" ") - print ('{}{}'.format(' ' * (int(columns / 2 - len(heading) / 2)), heading)) - for n in range(84): - print ("-", end=" ") - main_content = piu.find(class_="content").get_text() - print (main_content) +from bs4 import BeautifulSoup +import requests +import shutil +page = requests.get("http://planet.dgplug.org/") +soup = BeautifulSoup(page.content, 'html.parser') +data = soup.find_all(class_="entrygroup") +columns = shutil.get_terminal_size().columns +size = len(data)-1 +for i in range(0, size): + piu = data[i] + heading = piu.find("a").get_text() + for n in range(84): + print ("-", end=" ") + print ('{}{}'.format(' ' * (int(columns / 2 - len(heading) / 2)), heading)) + for n in range(84): + print ("-", end=" ") + main_content = piu.find(class_="content").get_text() + print (main_content) diff --git a/bin/ImageData/encodeData.json b/bin/ImageData/encodeData.json index 7a73a41..e02aef2 100644 --- a/bin/ImageData/encodeData.json +++ b/bin/ImageData/encodeData.json @@ -1,2 +1,2 @@ -{ +{ } \ No newline at end of file diff --git a/bin/ImagetoData.py b/bin/ImagetoData.py new file mode 100644 index 0000000..eadcb7e --- /dev/null +++ b/bin/ImagetoData.py @@ -0,0 +1,20 @@ +import os, os.path +import numpy as np +from PIL import Image + +if __name__ == '__main__': + def image_classifier(path): + valid_images = [".jpg", ".gif", ".png", ".tga"] + imgs = [] + for f in os.listdir(path): + ext = os.path.splitext(f)[1] + if ext.lower() not in valid_images: + continue + img = Image.open(os.path.join(path, f)) + img = np.array(img.resize((64, 64), Image.ANTIALIAS)) + imgs.append(img) + + return np.array(imgs) + + # converts all images in a particular directory to a 64*64*3 (3 for the rgb value of image) dimension vector + # use - in machine learning and image processing diff --git a/bin/Lost Robot/Solution.py b/bin/Lost Robot/Solution.py new file mode 100644 index 0000000..e314a03 --- /dev/null +++ b/bin/Lost Robot/Solution.py @@ -0,0 +1,15 @@ +#According to question we can only instruct robot up or down or left or right. So in his current coordiantes and home coordinates one of the/ +#coordinate either X or Y must be same. +for _ in range(int(input()): + x1,y1,x2,y2=map(int,input().split())#This will parse input to x1,y1,x2 and y2 + if x1!=x2 and y1!=y2: + print('sad') + elif x1==x2 and y1y2: + print('down') + elif y1==y2 and x1x2: + print('left') + diff --git a/bin/Lost Robot/quiz b/bin/Lost Robot/quiz new file mode 100644 index 0000000..02f35da --- /dev/null +++ b/bin/Lost Robot/quiz @@ -0,0 +1,34 @@ + +Robot Bunny is lost. It wants to reach its home as soon as possible. Currently it is standing at coordinates (x1, y1) in 2-D plane. +Its home is at coordinates (x2, y2). Bunny is extremely worried. Please help it by giving a command by telling the direction in which it +should to go so as to reach its home. If you give it a direction, it will keep moving in that direction till it reaches its home. +There are four possible directions you can give as command - "left", "right", "up", "down". It might be possible that you can't instruct +the robot in such a way that it reaches its home. In that case, output "sad". + +Input +First line of the input contains an integer T denoting the number of test cases. T test cases follow. + +First line of each test case contains four space separated integers x1, y1, x2, y2. + +Output +For each test case, output a single line containing "left" or "right" or "up" or "down" or "sad" (without quotes). + +Constraints +1 ≤ T ≤ 5000 +0 ≤ x1, y1, x2, y2. ≤ 100 +It's guaranteed that the initial position of robot is not his home. +Example + +Input +3 +0 0 1 0 +0 0 0 1 +0 0 1 1 + +Output: +right +up +sad + +Explanation +Test case 1. If you give Bunny the command to move to the right, it will reach its home. diff --git a/bin/Pyfirebase.py b/bin/Pyfirebase.py index ae520dc..333b304 100644 --- a/bin/Pyfirebase.py +++ b/bin/Pyfirebase.py @@ -1,18 +1,18 @@ -import requests.packages.urllib3 -requests.packages.urllib3.disable_warnings() -import serial -import json - -arduinoData = serial.Serial('com31',9600) - -from firebase import firebase - -firebase = firebase.FirebaseApplication('https://___YOUR_PROJECT_NAME____.firebaseio.com/') - -while 1: - myData = (arduinoData.readline().strip()) - myData = (myData.decode('utf-8')) - myData = float(myData) - result = firebase.put('MainNode/Leaf','temp',myData) - print 'Data : ',result - +import requests.packages.urllib3 +requests.packages.urllib3.disable_warnings() +import serial +import json + +arduinoData = serial.Serial('com31',9600) + +from firebase import firebase + +firebase = firebase.FirebaseApplication('https://___YOUR_PROJECT_NAME____.firebaseio.com/') + +while 1: + myData = (arduinoData.readline().strip()) + myData = (myData.decode('utf-8')) + myData = float(myData) + result = firebase.put('MainNode/Leaf','temp',myData) + print 'Data : ',result + diff --git a/bin/Video-downloader/license.txt b/bin/Video-downloader/license.txt new file mode 100644 index 0000000..8dada3e --- /dev/null +++ b/bin/Video-downloader/license.txt @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "{}" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright {yyyy} {name of copyright owner} + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/bin/Video-downloader/vid.py b/bin/Video-downloader/vid.py new file mode 100644 index 0000000..64ef37a --- /dev/null +++ b/bin/Video-downloader/vid.py @@ -0,0 +1,107 @@ +from __future__ import unicode_literals +import youtube_dl +import sys +import requests +# Master dictionary--will be expanding in future iterations of the project +# version 1 of vid.py +master = { + 'Audio': { + 'format': 'bestaudio/best', + 'noplaylist': True, + 'postprocessors': [{ + 'key': 'FFmpegExtractAudio', + 'preferredcodec': 'mp3', + 'preferredquality': '192', + }] + }, + 'Video': { + 'format': 'bestvideo+bestaudio/best', + 'noplaylist': True, + 'postprocessors': [{ + 'key': 'FFmpegVideoConvertor', + 'preferedformat': 'mp4', + # 'preferredquality': '137', + }] + }, + 'list': { + 'listsubtitles': True + }, + 'listformat': { + 'lisformats': True + } +} + + +def net(url): + """ + check if the user has connected to the internet. + """ + try: + requests.get(url) + except requests.exceptions.ConnectionError: + print("Please check your network connection.") + return False + except requests.exceptions.Timeout: + print("Site is taking too long to load, TimeOut.") + return False + except requests.exceptions.TooManyRedirects: + print("Too many Redirects.") + return False + except requests.exceptions.RequestException as e: + # catastrophic error. bail. + print(e) + sys.exit(1) + return True + + +def check(link): + """ + checking the validity of the link. + """ + try: + requests.get(link) + return True + except requests.exceptions.ConnectionError: + print("disconnected from network.") + return False + except requests.exceptions.HTTPError as err: + print(err) + return False + + +def download(link,data): + try: + with youtube_dl.YoutubeDL(data) as ydl: + ydl.download([link]) + except youtube_dl.utils.DownloadError as err: + print(err) + + +def main(): + ch = 'Y' + if net(r"https://www.youtube.com/"): + if ch == 'Y': + link = str(input("Enter the link: ")) + if check(link): + print("1.Download an Audio playlist") + print("2.Download a Video playlist") + print("3.Download a Single Audio") + print("4.Download a single video file") + ch=int(input("Enter your choice: ")) + if ch in [1,2,3,4]: + if ch == 1: + master['Audio']['noplaylist'] = False + download(link,master['Audio']) + elif ch == 2: + master['Video']['noplaylist'] = False + download(link,master['Video']) + elif ch == 4: + download(link,master['Video']) + else: + download(link,master['Audio']) + else: + print("Bad choice") + ch = str(input("do you want to continue?(Y/n)")) + +if __name__=="__main__": + main() diff --git a/bin/bulk_add_twitter_list.py b/bin/bulk_add_twitter_list.py index eb9d99d..1bbb8d5 100644 --- a/bin/bulk_add_twitter_list.py +++ b/bin/bulk_add_twitter_list.py @@ -1,22 +1,22 @@ -from twitter import * - -# install with: pip install twitter -# Create new app and access token from https://apps.twitter.com/ - -token = '' -token_secret = '' - -consumer_key = '' -consumer_secret = '' - -chunk_size = 20 - - -tw = Twitter(auth=OAuth(token, token_secret, consumer_key, consumer_secret)) - -screen_name = 'iEx_ec,LunyrInc,DECENTplatform,musicoins,CoinMagi,augurproject,LiskHQ,dogecoin,monerocurrency,Ripple,Dashpay,omise_go,neo_blockchain,tenxwallet,tokesplatform,WavesPlatform,IncentLoyalty,KomodoPlatform,tokencard_io,monaco_card,eboostcoin,geo_coin,Crowncoin1,MonetaryUnit,ionomics,Golos_Gold,goloschain,ubiqsmart,QtumOfficial,DECENTplatform,bancornetwork,FunFairTech,NxtCommunity,golemproject,wingsplatform,ArkEcosystem,_pivx,vergecurrency,ArdorPlatform,AdEx_Network,AragonProject,civickey,firstbloodio,darcrus,gnosisPM,EOS_io,2givecoin,ad_chain,apx_ventures,officialaur,AttentionToken,BitBayofficial,bitcolncash,BitBeanCoin,bitalize,coinblack,the_blocknet,ArtByteMe,aeoncoin,synereo,spellsofgenesis,breakoutcoin,bit_send,breakoutgaming,bata_money,bitcoindark,bitshares,burstcoin_dev,bytecent_byc,cannabiscoins,cofound_it,clamclient,cloakcoin,clubcoin_co,circuitsofvalue,creditbit,CapriCoinTeam,curecoin_team,decredproject,digibytecoin,digixdao,digixglobal,dgxio,dmdcoin,dopecoingold,E_Drachma,augmentorsgame,dualitychain,edgelessproject,elecgulden,evergreencoin_,emercoin,einsteiniumcoin,energycoin,europecoineuorg,eth_classic,ethereumproject,exclusivecoin,expanseofficial,faircointeam,fair_coop,factom,foldingcoin,official_florin,feathercoin,gambitcrypto,gamecredits,byteballorg,gcrworldwide,goldcoin,gridcoinnetwork,groestlcointeam,matchpool,Humaniq,infxcoin,io_coin,Fermat_ORG,newkorecoin,lbryio,legendsroom,coinlomo,litecoin,maidsafe,pepecoins,melonport,metalpaysme,mysteriumnet,navcoin,officialnubits,neoscoin,gulden,numerai,BeyondVoidGame,nxsearth,okcashcrypto,omni_layer,particlproject,ParticlDev,pinkcoin_,parkbyte_pkb,potcoin,peercoinppc,pesetacoinofic,patientory,qrledger,qwarktoken,radiumcore,rubycoinorg,reddcoin,risevisionteam,safe_Exchange,siatechhq,dualitychain,ShiftNrg,sibchervonec,solarcoin_slr,singulardtv,synergycoin,ethstatus,ProjectSPHR,spreadcointeam,start_coin,StartJOIN,Startwallet,steemit,steemchain,storjproject,stratisplatform,bit_swift,swarmcitydapp,syndicatelabs_,syscoin,thehempcoin,chronobanknews,blocksafe,wetrustplatform,trustplus,transfer_dev,unbreakablcoin,unobtanium_uno,viacoin,voxelus,vericoin,veriumreserve,Vertcoin,vtorrentcrypto,urumproject,XaurumOfficial,counterpartyxcp,digitalnote_xdn,elastic_coin,NEMofficial,stellarorg,myriadcoin,stealthcoin,xvcnews,whitecoiner,zcoinofficial,zcoinproject,zclassiccoin,zcashco,zencashofficial' -screen_name = screen_name.split(',') -for i in range(len(screen_name))[::chunk_size]: - # split to chunk size - sn = ','.join(screen_name[i:i+chunk_size]) - tw.lists.members.create_all(owner_screen_name='your_screen_name_here', slug='your_list', screen_name=sn) +from twitter import * + +# install with: pip install twitter +# Create new app and access token from https://apps.twitter.com/ + +token = '' +token_secret = '' + +consumer_key = '' +consumer_secret = '' + +chunk_size = 20 + + +tw = Twitter(auth=OAuth(token, token_secret, consumer_key, consumer_secret)) + +screen_name = 'iEx_ec,LunyrInc,DECENTplatform,musicoins,CoinMagi,augurproject,LiskHQ,dogecoin,monerocurrency,Ripple,Dashpay,omise_go,neo_blockchain,tenxwallet,tokesplatform,WavesPlatform,IncentLoyalty,KomodoPlatform,tokencard_io,monaco_card,eboostcoin,geo_coin,Crowncoin1,MonetaryUnit,ionomics,Golos_Gold,goloschain,ubiqsmart,QtumOfficial,DECENTplatform,bancornetwork,FunFairTech,NxtCommunity,golemproject,wingsplatform,ArkEcosystem,_pivx,vergecurrency,ArdorPlatform,AdEx_Network,AragonProject,civickey,firstbloodio,darcrus,gnosisPM,EOS_io,2givecoin,ad_chain,apx_ventures,officialaur,AttentionToken,BitBayofficial,bitcolncash,BitBeanCoin,bitalize,coinblack,the_blocknet,ArtByteMe,aeoncoin,synereo,spellsofgenesis,breakoutcoin,bit_send,breakoutgaming,bata_money,bitcoindark,bitshares,burstcoin_dev,bytecent_byc,cannabiscoins,cofound_it,clamclient,cloakcoin,clubcoin_co,circuitsofvalue,creditbit,CapriCoinTeam,curecoin_team,decredproject,digibytecoin,digixdao,digixglobal,dgxio,dmdcoin,dopecoingold,E_Drachma,augmentorsgame,dualitychain,edgelessproject,elecgulden,evergreencoin_,emercoin,einsteiniumcoin,energycoin,europecoineuorg,eth_classic,ethereumproject,exclusivecoin,expanseofficial,faircointeam,fair_coop,factom,foldingcoin,official_florin,feathercoin,gambitcrypto,gamecredits,byteballorg,gcrworldwide,goldcoin,gridcoinnetwork,groestlcointeam,matchpool,Humaniq,infxcoin,io_coin,Fermat_ORG,newkorecoin,lbryio,legendsroom,coinlomo,litecoin,maidsafe,pepecoins,melonport,metalpaysme,mysteriumnet,navcoin,officialnubits,neoscoin,gulden,numerai,BeyondVoidGame,nxsearth,okcashcrypto,omni_layer,particlproject,ParticlDev,pinkcoin_,parkbyte_pkb,potcoin,peercoinppc,pesetacoinofic,patientory,qrledger,qwarktoken,radiumcore,rubycoinorg,reddcoin,risevisionteam,safe_Exchange,siatechhq,dualitychain,ShiftNrg,sibchervonec,solarcoin_slr,singulardtv,synergycoin,ethstatus,ProjectSPHR,spreadcointeam,start_coin,StartJOIN,Startwallet,steemit,steemchain,storjproject,stratisplatform,bit_swift,swarmcitydapp,syndicatelabs_,syscoin,thehempcoin,chronobanknews,blocksafe,wetrustplatform,trustplus,transfer_dev,unbreakablcoin,unobtanium_uno,viacoin,voxelus,vericoin,veriumreserve,Vertcoin,vtorrentcrypto,urumproject,XaurumOfficial,counterpartyxcp,digitalnote_xdn,elastic_coin,NEMofficial,stellarorg,myriadcoin,stealthcoin,xvcnews,whitecoiner,zcoinofficial,zcoinproject,zclassiccoin,zcashco,zencashofficial' +screen_name = screen_name.split(',') +for i in range(len(screen_name))[::chunk_size]: + # split to chunk size + sn = ','.join(screen_name[i:i+chunk_size]) + tw.lists.members.create_all(owner_screen_name='your_screen_name_here', slug='your_list', screen_name=sn) diff --git a/bin/caesar_cipher.py b/bin/caesar_cipher.py index df9fc40..0bdbc95 100644 --- a/bin/caesar_cipher.py +++ b/bin/caesar_cipher.py @@ -1,42 +1,42 @@ -key = 'abcdefghijklmnopqrstuvwxyz' - -def encrypt(n, plaintext): - """Encrypt the string and return the ciphertext""" - result = '' - - for l in plaintext.lower(): - try: - i = (key.index(l) + n) % 26 - result += key[i] - except ValueError: - result += l - - return result.lower() - - -def decrypt(n, ciphertext): - """Decrypt the string and return the plaintext""" - result = '' - - for l in ciphertext: - try: - i = (key.index(l) - n) % 26 - result += key[i] - except ValueError: - result += l - - return result - -print("Encrypt or decrypt?") -ans = input() -ans = ans.lower() -print("Enter message") -k = input() -print("Enter rotation number") -nn = int(input()) -if ans == 'encrypt': - ret = encrypt(nn,k) - print ('Encrytped: %s' % ret) -else: - ret = decrypt(nn,k) - print ('Decrytped: %s' % ret) +key = 'abcdefghijklmnopqrstuvwxyz' + +def encrypt(n, plaintext): + """Encrypt the string and return the ciphertext""" + result = '' + + for l in plaintext.lower(): + try: + i = (key.index(l) + n) % 26 + result += key[i] + except ValueError: + result += l + + return result.lower() + + +def decrypt(n, ciphertext): + """Decrypt the string and return the plaintext""" + result = '' + + for l in ciphertext: + try: + i = (key.index(l) - n) % 26 + result += key[i] + except ValueError: + result += l + + return result + +print("Encrypt or decrypt?") +ans = input() +ans = ans.lower() +print("Enter message") +k = input() +print("Enter rotation number") +nn = int(input()) +if ans == 'encrypt': + ret = encrypt(nn,k) + print ('Encrytped: %s' % ret) +else: + ret = decrypt(nn,k) + print ('Decrytped: %s' % ret) diff --git a/bin/dice_simulator.py b/bin/dice_simulator.py new file mode 100644 index 0000000..e215d67 --- /dev/null +++ b/bin/dice_simulator.py @@ -0,0 +1,10 @@ +import random # random is a python built-in module + + +def roll_dice(): + dice_side = random.randrange(1, 7) + print(dice_side) + + +if __name__ == '__main__': + roll_dice() \ No newline at end of file diff --git a/bin/dictionary/app.py b/bin/dictionary/app.py new file mode 100644 index 0000000..245101c --- /dev/null +++ b/bin/dictionary/app.py @@ -0,0 +1,17 @@ +from dict_dialog import Dict_Dialog +from PyQt5.QtWidgets import QApplication, QDialog +import sys + + +class AppWindow(QDialog): + def __init__(self): + super().__init__() + self.ui = Dict_Dialog() + self.ui.setupUi(self) + self.show() + + +app = QApplication(sys.argv) +w = AppWindow() +w.show() +sys.exit(app.exec_()) diff --git a/bin/dictionary/dict_dialog.py b/bin/dictionary/dict_dialog.py new file mode 100644 index 0000000..f788069 --- /dev/null +++ b/bin/dictionary/dict_dialog.py @@ -0,0 +1,56 @@ +from dictionary import definition +from PyQt5 import QtCore, QtWidgets + + +class Dict_Dialog(object): + def setupUi(self, Dialog): + Dialog.setObjectName("Dictionary") + Dialog.resize(344, 249) + self.widget = QtWidgets.QWidget(Dialog) + self.widget.setGeometry(QtCore.QRect(10, 10, 321, 236)) + self.widget.setObjectName("widget") + self.verticalLayout = QtWidgets.QVBoxLayout(self.widget) + self.verticalLayout.setContentsMargins(0, 0, 0, 0) + self.verticalLayout.setObjectName("verticalLayout") + self.horizontalLayout = QtWidgets.QHBoxLayout() + self.horizontalLayout.setContentsMargins(-1, -1, -1, 4) + self.horizontalLayout.setSpacing(6) + self.horizontalLayout.setObjectName("horizontalLayout") + self.searchText = QtWidgets.QLineEdit(self.widget) + self.searchText.setText("") + self.searchText.setObjectName("searchText") + self.horizontalLayout.addWidget(self.searchText) + self.searchButton = QtWidgets.QPushButton(self.widget) + self.searchButton.setObjectName("searchButton") + self.horizontalLayout.addWidget(self.searchButton) + self.verticalLayout.addLayout(self.horizontalLayout) + self.resultText = QtWidgets.QTextBrowser(self.widget) + self.resultText.setObjectName("resultText") + self.verticalLayout.addWidget(self.resultText) + + # output fonts + font = self.resultText.font() + font.setPointSize(20) + + self.retranslateUi(Dialog) + QtCore.QMetaObject.connectSlotsByName(Dialog) + Dialog.setTabOrder(self.searchText, self.searchButton) + + # events + self.searchButton.clicked.connect(self.show_definition) + + def show_definition(self): + word = self.searchText.text() + defn = definition(word) + + if defn != '': + self.resultText.setText(defn) + else: + self.resultText.setText('definition not found') + + def retranslateUi(self, Dialog): + _translate = QtCore.QCoreApplication.translate + Dialog.setWindowTitle(_translate("Dialog", "Dialog")) + self.searchText.setPlaceholderText( + _translate("Dialog", "word to search")) + self.searchButton.setText(_translate("Dialog", "search")) diff --git a/bin/dictionary/dictionary.py b/bin/dictionary/dictionary.py new file mode 100644 index 0000000..063801a --- /dev/null +++ b/bin/dictionary/dictionary.py @@ -0,0 +1,25 @@ +from nltk.corpus import wordnet as wn + + +def extractInfo(synset): + """ + get string containing definition from a synset + """ + out = synset.pos() + ' : ' + out += synset.definition() + + return out + + +def definition(word): + ssets = wn.synsets(word) + defns = list() + + for i in ssets: + # ensure words in synsets are same + if i.name().split('.')[0] == word: + info = extractInfo(i) + defns.append(info) + + # return defns + return '\n'.join(defns) diff --git a/bin/end_to_end.py b/bin/end_to_end.py index 264ca3d..ac360d8 100644 --- a/bin/end_to_end.py +++ b/bin/end_to_end.py @@ -1,39 +1,39 @@ -import time -a = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'] -def encrypt(msg): - off = 3 - enc = "" - for i in msg: - enc = enc + (a[(a.index(i)+off)%26]) - return enc -def decrypt(msg): - off = 3 - dec = "" - for i in msg: - dec = dec + (a[(a.index(i)-off)%26]) - return dec - -#Client Side(Sender) -msg = input("Enter Message To Send: ") -f = open('server.txt','w+') -print("Encrypting..........") -time.sleep(2) -enc = encrypt(msg) -print("Message Sent Is: ",enc) - -#Server Side -f.write(enc) -f.close() - -print() -#Client Side(Reciever) -print("Reciever Is Recieving.........") -time.sleep(2) -f = open('server.txt','r+') -msg = f.read() -print("Message Recieved Is: ",msg) -print("Decrypting........") -time.sleep(2) -dec = decrypt(msg) -print("Message Displayed Is: ",dec) - +import time +a = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'] +def encrypt(msg): + off = 3 + enc = "" + for i in msg: + enc = enc + (a[(a.index(i)+off)%26]) + return enc +def decrypt(msg): + off = 3 + dec = "" + for i in msg: + dec = dec + (a[(a.index(i)-off)%26]) + return dec + +#Client Side(Sender) +msg = input("Enter Message To Send: ") +f = open('server.txt','w+') +print("Encrypting..........") +time.sleep(2) +enc = encrypt(msg) +print("Message Sent Is: ",enc) + +#Server Side +f.write(enc) +f.close() + +print() +#Client Side(Reciever) +print("Reciever Is Recieving.........") +time.sleep(2) +f = open('server.txt','r+') +msg = f.read() +print("Message Recieved Is: ",msg) +print("Decrypting........") +time.sleep(2) +dec = decrypt(msg) +print("Message Displayed Is: ",dec) + diff --git a/bin/expense_manager.py b/bin/expense_manager.py index 469b2ff..dad8299 100644 --- a/bin/expense_manager.py +++ b/bin/expense_manager.py @@ -1,340 +1,340 @@ -#General Function: - -def combine_funcs(*funcs): - def combined_func(*args, **kwargs): - for f in funcs: - f(*args, **kwargs) - return combined_func - - - -#Defining the create function: - -def create(): - def sub_create(): - def sub1(): - def sub2(): - f1.destroy() - b=TextArea.get("1.0",'end') - if(b!='0'): - f.write(b) - f.write("\n") - f2.destroy() - f1=tkinter.Frame(bg="#CCCCFF") - f1.pack(fill="both",expand="true") - l1=tkinter.Label(f1,text="Congratulations! Your Entry Is Made.",bg="#330033",fg="#FFFFFF",relief="groove",pady=30,font=16) - l1.pack(fill="x",expand="true") - b1=tkinter.Button(f1,text="Return To MainMenu",bg="#FFFFFF",fg="blue",relief="groove",command=combine_funcs(sub2,start),height=2,width=25) - b1.pack(side="right") - a=e.get() - a=a.upper() - f1.destroy() - f=open(a,"w") - f2=tkinter.Frame(bg="#CCCCFF") - f2.pack(fill="both",expand="true") - l1=tkinter.Label(f2,text="Make An Entry:\n\nExample: Item1 Rs amount\nItem2 Rs amount",bg="#FFFFFF",fg="#680000",relief="groove",anchor="n",pady=50,font=25) - l1.pack(fill="x",expand="true") - TextArea = tkinter.Text(f2) - ScrollBar = tkinter.Scrollbar(f2,bg="white") - ScrollBar.config(command=TextArea.yview) - TextArea.config(yscrollcommand=ScrollBar.set) - ScrollBar.pack(side="right", fill="y") - TextArea.pack(fill="x") - b1=tkinter.Button(f2,text="Submit",bg="#FFFFFF",fg="blue",relief="groove",command=sub1) - b1.pack() - frame.destroy() - f1=tkinter.Frame(bg="#CCCCFF") - f1.pack(fill="both",expand="true") - l1=tkinter.Label(f1,text="Welcome To Expense Manager",bg="#330033",fg="#FFFFFF",relief="groove",pady=30,font=16) - l1.pack(fill="x",expand="true",anchor="n") - l1=tkinter.Label(f1,text="Enter Date:",bg="#330033",fg="#FFFFFF",relief="groove",font=9,padx=50) - l1.place(relx=0.35,rely=0.5) - e=tkinter.Entry(f1) - e.place(relx=0.52,rely=0.5) - b1=tkinter.Button(f1,text="Make Entry",bg="#9999FF",fg="#660099",relief="groove",command=sub_create,height=2,width=10) - b1.place(relx=0.45,rely=0.56) - - -#Defining the get function: - -def get(): - def sub_get(): - def sub2(): - f2.destroy() - a=e.get() - a=a.upper() - f1.destroy() - f=open(a,'r') - f2=tkinter.Frame() - f2.pack(fill="both",expand="true") - l1=tkinter.Label(f2,text="Your Entries For The Date "+a+" Are: ",bg="#FFFFFF",fg="#680000",relief="groove",anchor="center",pady=50) - l1.pack(fill="x",expand="true") - TextArea = tkinter.Text(f2) - ScrollBar = tkinter.Scrollbar(f2) - ScrollBar.config(command=TextArea.yview) - ScrollBar.pack(side="right", fill="y") - TextArea.insert('insert',f.read()) - TextArea.config(yscrollcommand=ScrollBar.set,state="disabled") - TextArea.pack(fill="both",expand="true") - b1=tkinter.Button(f2,text="Return To MainMenu",bg="#FFFFFF",fg="blue",relief="groove",command=combine_funcs(sub2,start),height=2,width=25) - b1.pack(side="right") - frame.destroy() - f1=tkinter.Frame(bg="#CCCCFF") - f1.pack(fill="both",expand="true") - l1=tkinter.Label(f1,text="Welcome To Expense Manager",bg="#330033",fg="#FFFFFF",relief="groove",pady=30,font=16) - l1.pack(fill="x",expand="true",anchor="n") - l1=tkinter.Label(f1,text="Enter Date:",bg="#330033",fg="#FFFFFF",relief="groove",font=9,padx=50) - l1.place(relx=0.35,rely=0.5) - e=tkinter.Entry(f1) - e.place(relx=0.52,rely=0.5) - b1=tkinter.Button(f1,text="Get Entry",bg="#9999FF",fg="#660099",relief="groove",command=sub_get,height=2,width=10) - b1.place(relx=0.45,rely=0.56) - -#Defining the get entry by month function: - -def getm(): - def sub_getm(): - def sub2(): - f2.destroy() - a=e.get() - a=a.upper() - f1.destroy() - f2=tkinter.Frame() - f2.pack(fill="both",expand="true") - l1=tkinter.Label(f2,text="Your Entries For The Month Are: ",bg="#FFFFFF",fg="#680000",relief="groove",anchor="center",pady=50) - l1.pack(fill="x",expand="true") - TextArea = tkinter.Text(f2) - ScrollBar = tkinter.Scrollbar(f2) - ScrollBar.config(command=TextArea.yview) - ScrollBar.pack(side="right", fill="y") - for i in range(1,32): - try: - f=open(str(i)+' '+a,'r') - except IOError: - continue - TextArea.insert('insert',"\n"+str(i)+' '+a+": \n\n"+f.read()) - TextArea.config(yscrollcommand=ScrollBar.set,state="disabled") - TextArea.pack(fill="both",expand="true") - b1=tkinter.Button(f2,text="Return To MainMenu",bg="#FFFFFF",fg="blue",relief="groove",command=combine_funcs(sub2,start),height=2,width=25) - b1.pack(side="right") - frame.destroy() - f1=tkinter.Frame(bg="#CCCCFF") - f1.pack(fill="both",expand="true") - l1=tkinter.Label(f1,text="Welcome To Expense Manager",bg="#330033",fg="#FFFFFF",relief="groove",pady=30,font=16) - l1.pack(fill="x",expand="true",anchor="n") - l1=tkinter.Label(f1,text="Enter Month And Year:",bg="#330033",fg="#FFFFFF",relief="groove",font=9,padx=50) - l1.place(relx=0.3,rely=0.5) - e=tkinter.Entry(f1) - e.place(relx=0.52,rely=0.5) - b1=tkinter.Button(f1,text="Get Entry",bg="#9999FF",fg="#660099",relief="groove",command=sub_getm,height=2,width=10) - b1.place(relx=0.47,rely=0.56) - - - - -#Get Total Expense By Date: - - -def Sum(): - def sub_Sum(): - def sub2(): - f2.destroy() - t=e.get() - t=t.upper() - try: - f=open(t,'r') - a=f.readlines() - c=0 - for i in range(0,len(a)): - b='' - for j in range(len(a[i])-1,0,-1): - if(a[i][j]!=' ' and a[i][j]>='0' and a[i][j]<='9'): - b=b+a[i][j] - if(a[i][j]>='9'): - break - if(b!=''): - c=c+int(b[::-1]) - f1.destroy() - f2=tkinter.Frame() - f2.pack(fill="both",expand="true") - l1=tkinter.Label(f2,text="Total Expenses On "+t+" Are: \nRs "+str(c),bg="#FFFFFF",fg="#680000",relief="groove",anchor="center",pady=50,font=50) - l1.pack(fill="both",expand="true") - except IOError: - l1=tkinter.Label(f2,text="No Such Entry Is Made "+t+" Are: \nRs "+str(c),bg="#FFFFFF",fg="#680000",relief="groove",anchor="center",pady=50,font=50) - l1.pack(fill="both",expand="true") - b1=tkinter.Button(f2,text="Return To MainMenu",bg="#FFFFFF",fg="blue",relief="groove",command=combine_funcs(sub2,start),height=2,width=25) - b1.pack(side="right") - frame.destroy() - f1=tkinter.Frame(bg="#CCCCFF") - f1.pack(fill="both",expand="true") - l1=tkinter.Label(f1,text="Welcome To Expense Manager",bg="#330033",fg="#FFFFFF",relief="groove",pady=30,font=16) - l1.pack(fill="x",expand="true",anchor="n") - l1=tkinter.Label(f1,text="Enter Date:",bg="#330033",fg="#FFFFFF",relief="groove",font=9,padx=50) - l1.place(relx=0.35,rely=0.5) - e=tkinter.Entry(f1) - e.place(relx=0.52,rely=0.5) - b1=tkinter.Button(f1,text="Get Expenses",bg="#9999FF",fg="#660099",relief="groove",command=sub_Sum,height=2,width=10) - b1.place(relx=0.47,rely=0.56) - -#Defining Get total expense in a month: - -def Summ(): - def sub_Summ(): - def sub2(): - f2.destroy() - a=e.get() - a=a.upper() - c=0 - for i in range(1,32): - try: - f=open(str(i)+' '+a,'r') - t=f.readlines() - for i in range(0,len(t)): - b='' - for j in range(len(t[i])-1,0,-1): - if(t[i][j]!=' ' and t[i][j]>='0' and t[i][j]<='9'): - b=b+t[i][j] - if(b!=''): - c=c+int(b[::-1]) - except IOError: - continue - f1.destroy() - f2=tkinter.Frame() - f2.pack(fill="both",expand="true") - l1=tkinter.Label(f2,text="Total Expenses In "+a+" Are: \nRs "+str(c),bg="#FFFFFF",fg="#680000",relief="groove",anchor="center",pady=50,font=50) - l1.pack(fill="both",expand="true") - b1=tkinter.Button(f2,text="Return To MainMenu",bg="#FFFFFF",fg="blue",relief="groove",command=combine_funcs(sub2,start),height=2,width=25) - b1.pack(side="right") - frame.destroy() - f1=tkinter.Frame(bg="#CCCCFF") - f1.pack(fill="both",expand="true") - l1=tkinter.Label(f1,text="Welcome To Expense Manager",bg="#330033",fg="#FFFFFF",relief="groove",pady=30,font=16) - l1.pack(fill="x",expand="true",anchor="n") - l1=tkinter.Label(f1,text="Enter Month And Year:",bg="#330033",fg="#FFFFFF",relief="groove",font=9,padx=50) - l1.place(relx=0.3,rely=0.5) - e=tkinter.Entry(f1) - e.place(relx=0.52,rely=0.5) - b1=tkinter.Button(f1,text="Get Expenses",bg="#9999FF",fg="#660099",relief="groove",command=sub_Summ,height=2,width=10) - b1.place(relx=0.47,rely=0.56) - - - -# Defining Add to entry: - -def add(): - def sub_add(): - def sub1(): - def sub2(): - f1.destroy() - b=TextArea.get("1.0",'end') - if(b!='0'): - f.write(b) - f.write("\n") - f2.destroy() - f1=tkinter.Frame(bg="#CCCCFF") - f1.pack(fill="both",expand="true") - l1=tkinter.Label(f1,text="Congratulations! Your Entry Is Made.",bg="#330033",fg="#FFFFFF",relief="groove",pady=30,font=16) - l1.pack(fill="x",expand="true") - b1=tkinter.Button(f1,text="Return To MainMenu",bg="#FFFFFF",fg="blue",relief="groove",command=combine_funcs(sub2,start),height=2,width=25) - b1.pack(side="right") - a=e.get() - a=a.upper() - f1.destroy() - f=open(a,"a") - f2=tkinter.Frame(bg="#CCCCFF") - f2.pack(fill="both",expand="true") - l1=tkinter.Label(f2,text="Make An Entry:\n\nExample: Item1 Rs amount\nItem2 Rs amount",bg="#FFFFFF",fg="#680000",relief="groove",anchor="n",pady=50,font=25) - l1.pack(fill="x",expand="true") - TextArea = tkinter.Text(f2) - ScrollBar = tkinter.Scrollbar(f2,bg="white") - ScrollBar.config(command=TextArea.yview) - TextArea.config(yscrollcommand=ScrollBar.set) - ScrollBar.pack(side="right", fill="y") - TextArea.pack(fill="x") - b1=tkinter.Button(f2,text="Submit",bg="#FFFFFF",fg="blue",relief="groove",command=sub1) - b1.pack() - frame.destroy() - f1=tkinter.Frame(bg="#CCCCFF") - f1.pack(fill="both",expand="true") - l1=tkinter.Label(f1,text="Welcome To Expense Manager",bg="#330033",fg="#FFFFFF",relief="groove",pady=30,font=16) - l1.pack(fill="x",expand="true",anchor="n") - l1=tkinter.Label(f1,text="Enter Date:",bg="#330033",fg="#FFFFFF",relief="groove",font=9,padx=50) - l1.place(relx=0.35,rely=0.5) - e=tkinter.Entry(f1) - e.place(relx=0.52,rely=0.5) - b1=tkinter.Button(f1,text="Make Entry",bg="#9999FF",fg="#660099",relief="groove",command=sub_add,height=2,width=10) - b1.place(relx=0.45,rely=0.56) - -# Defining Delete Existing Entry: - -def delete(): - import os - delete=lambda x:os.remove(x) - def sub_delete(): - def sub2(): - f2.destroy() - a=e.get() - a=a.upper() - delete(a) - f1.destroy() - f2=tkinter.Frame(bg="#CCCCFF") - f2.pack(fill="both",expand="true") - l1=tkinter.Label(f2,text="Congratulations! Your Entry Is Deleted.",bg="#330033",fg="#FFFFFF",relief="groove",pady=30,font=16) - l1.pack(fill="x",expand="true") - b1=tkinter.Button(f2,text="Return To MainMenu",bg="#FFFFFF",fg="blue",relief="groove",command=combine_funcs(sub2,start),height=2,width=25) - b1.pack(side="right") - frame.destroy() - f1=tkinter.Frame(bg="#CCCCFF") - f1.pack(fill="both",expand="true") - l1=tkinter.Label(f1,text="Welcome To Expense Manager",bg="#330033",fg="#FFFFFF",relief="groove",pady=30,font=16) - l1.pack(fill="x",expand="true",anchor="n") - l1=tkinter.Label(f1,text="Enter Date:",bg="#330033",fg="#FFFFFF",relief="groove",font=9,padx=50) - l1.place(relx=0.35,rely=0.5) - e=tkinter.Entry(f1) - e.place(relx=0.52,rely=0.5) - b1=tkinter.Button(f1,text="Delete",bg="#9999FF",fg="#660099",relief="groove",command=sub_delete,height=2,width=10) - b1.place(relx=0.47,rely=0.56) - - - -import tkinter -root=tkinter.Tk() -root.geometry('1250x700') -def start(): - global frame - frame=tkinter.Frame(bg="#CCCCFF") - frame.pack(fill="both",expand="true",) - l1=tkinter.Label(frame,text="Welcome To Expense Manager",bg="#330033",fg="#FFFFFF",relief="groove",pady=30,font=16) - l1.pack(fill="x",expand="true",anchor="n") - l1=tkinter.Label(frame,text="Press To Create A new Entry",bg="#330066",fg="#66FFFF",relief="groove",pady=15,font=16,padx=16) - l1.place(relx=0.2,rely=0.2,anchor="n") - b1=tkinter.Button(frame,text="Create Entry Sheet",bg="#9999FF",fg="#660099",relief="solid",command=create,font=11,pady=16,cursor="dot") - b1.place(relx=0.2,rely=0.3,anchor="n") - l1=tkinter.Label(frame,text="Press To Get Entry By Date",bg="#330066",fg="#66FFFF",relief="groove",pady=15,font=16,padx=16) - l1.place(relx=0.4,rely=0.2,anchor="n") - b1=tkinter.Button(frame,text="Get Entry Sheet",bg="#9999FF",fg="#660099",relief="solid",command=get,font=11,pady=16,cursor="dot") - b1.place(relx=0.4,rely=0.3,anchor="n") - l1=tkinter.Label(frame,text="Press To Get Entry By Month",bg="#330066",fg="#66FFFF",relief="groove",pady=15,font=16,padx=7) - l1.place(relx=0.6,rely=0.2,anchor="n") - b1=tkinter.Button(frame,text="Get Monthly Entry Sheet",bg="#9999FF",fg="#660099",relief="solid",command=getm,font=11,pady=16,cursor="dot") - b1.place(relx=0.6,rely=0.3,anchor="n") - l1=tkinter.Label(frame,text="Press To Get Total Expense On Date",bg="#330066",fg="#66FFFF",relief="groove",pady=15,font=16) - l1.place(relx=0.8,rely=0.2,anchor="n") - b1=tkinter.Button(frame,text="Get Total Expense On Date",bg="#9999FF",fg="#660099",relief="solid",command=Sum,font=11,pady=16,cursor="dot") - b1.place(relx=0.8,rely=0.3,anchor="n") - l1=tkinter.Label(frame,text="Press To Get Total Expense In A Month",bg="#330066",fg="#66FFFF",relief="groove",pady=15,font=16) - l1.place(relx=0.3,rely=0.5,anchor="n") - b1=tkinter.Button(frame,text="Get Total Expense",bg="#9999FF",fg="#660099",relief="solid",command=Summ,font=11,pady=16,cursor="dot") - b1.place(relx=0.3,rely=0.6,anchor="n") - l1=tkinter.Label(frame,text="Press To Add To Existing Entry",bg="#330066",fg="#66FFFF",relief="groove",pady=15,font=16) - l1.place(relx=0.51,rely=0.5,anchor="n") - b1=tkinter.Button(frame,text="Add To Entry",bg="#9999FF",fg="#660099",relief="solid",command=add,font=11,pady=16,cursor="dot") - b1.place(relx=0.51,rely=0.6,anchor="n") - l1=tkinter.Label(frame,text="Press To Delete Existing Entry",bg="#330066",fg="#66FFFF",relief="groove",pady=15,font=16) - l1.place(relx=0.7,rely=0.5,anchor="n") - b1=tkinter.Button(frame,text="Delete Entry",bg="#9999FF",fg="#660099",relief="solid",command=delete,font=11,pady=16,cursor="dot") - b1.place(relx=0.7,rely=0.6,anchor="n") - l1=tkinter.Label(frame,text="\u00a9"+" copyright 2016\t\t\t\t\t\t\t\t\t\t\t\t"+"Developed By: Akshit Grover",bg="#330033",fg="#FFFFFF",relief="groove",pady=30,font=16) - l1.pack(fill="x",expand="true",anchor="s") - root.mainloop() -start() +#General Function: + +def combine_funcs(*funcs): + def combined_func(*args, **kwargs): + for f in funcs: + f(*args, **kwargs) + return combined_func + + + +#Defining the create function: + +def create(): + def sub_create(): + def sub1(): + def sub2(): + f1.destroy() + b=TextArea.get("1.0",'end') + if(b!='0'): + f.write(b) + f.write("\n") + f2.destroy() + f1=tkinter.Frame(bg="#CCCCFF") + f1.pack(fill="both",expand="true") + l1=tkinter.Label(f1,text="Congratulations! Your Entry Is Made.",bg="#330033",fg="#FFFFFF",relief="groove",pady=30,font=16) + l1.pack(fill="x",expand="true") + b1=tkinter.Button(f1,text="Return To MainMenu",bg="#FFFFFF",fg="blue",relief="groove",command=combine_funcs(sub2,start),height=2,width=25) + b1.pack(side="right") + a=e.get() + a=a.upper() + f1.destroy() + f=open(a,"w") + f2=tkinter.Frame(bg="#CCCCFF") + f2.pack(fill="both",expand="true") + l1=tkinter.Label(f2,text="Make An Entry:\n\nExample: Item1 Rs amount\nItem2 Rs amount",bg="#FFFFFF",fg="#680000",relief="groove",anchor="n",pady=50,font=25) + l1.pack(fill="x",expand="true") + TextArea = tkinter.Text(f2) + ScrollBar = tkinter.Scrollbar(f2,bg="white") + ScrollBar.config(command=TextArea.yview) + TextArea.config(yscrollcommand=ScrollBar.set) + ScrollBar.pack(side="right", fill="y") + TextArea.pack(fill="x") + b1=tkinter.Button(f2,text="Submit",bg="#FFFFFF",fg="blue",relief="groove",command=sub1) + b1.pack() + frame.destroy() + f1=tkinter.Frame(bg="#CCCCFF") + f1.pack(fill="both",expand="true") + l1=tkinter.Label(f1,text="Welcome To Expense Manager",bg="#330033",fg="#FFFFFF",relief="groove",pady=30,font=16) + l1.pack(fill="x",expand="true",anchor="n") + l1=tkinter.Label(f1,text="Enter Date:",bg="#330033",fg="#FFFFFF",relief="groove",font=9,padx=50) + l1.place(relx=0.35,rely=0.5) + e=tkinter.Entry(f1) + e.place(relx=0.52,rely=0.5) + b1=tkinter.Button(f1,text="Make Entry",bg="#9999FF",fg="#660099",relief="groove",command=sub_create,height=2,width=10) + b1.place(relx=0.45,rely=0.56) + + +#Defining the get function: + +def get(): + def sub_get(): + def sub2(): + f2.destroy() + a=e.get() + a=a.upper() + f1.destroy() + f=open(a,'r') + f2=tkinter.Frame() + f2.pack(fill="both",expand="true") + l1=tkinter.Label(f2,text="Your Entries For The Date "+a+" Are: ",bg="#FFFFFF",fg="#680000",relief="groove",anchor="center",pady=50) + l1.pack(fill="x",expand="true") + TextArea = tkinter.Text(f2) + ScrollBar = tkinter.Scrollbar(f2) + ScrollBar.config(command=TextArea.yview) + ScrollBar.pack(side="right", fill="y") + TextArea.insert('insert',f.read()) + TextArea.config(yscrollcommand=ScrollBar.set,state="disabled") + TextArea.pack(fill="both",expand="true") + b1=tkinter.Button(f2,text="Return To MainMenu",bg="#FFFFFF",fg="blue",relief="groove",command=combine_funcs(sub2,start),height=2,width=25) + b1.pack(side="right") + frame.destroy() + f1=tkinter.Frame(bg="#CCCCFF") + f1.pack(fill="both",expand="true") + l1=tkinter.Label(f1,text="Welcome To Expense Manager",bg="#330033",fg="#FFFFFF",relief="groove",pady=30,font=16) + l1.pack(fill="x",expand="true",anchor="n") + l1=tkinter.Label(f1,text="Enter Date:",bg="#330033",fg="#FFFFFF",relief="groove",font=9,padx=50) + l1.place(relx=0.35,rely=0.5) + e=tkinter.Entry(f1) + e.place(relx=0.52,rely=0.5) + b1=tkinter.Button(f1,text="Get Entry",bg="#9999FF",fg="#660099",relief="groove",command=sub_get,height=2,width=10) + b1.place(relx=0.45,rely=0.56) + +#Defining the get entry by month function: + +def getm(): + def sub_getm(): + def sub2(): + f2.destroy() + a=e.get() + a=a.upper() + f1.destroy() + f2=tkinter.Frame() + f2.pack(fill="both",expand="true") + l1=tkinter.Label(f2,text="Your Entries For The Month Are: ",bg="#FFFFFF",fg="#680000",relief="groove",anchor="center",pady=50) + l1.pack(fill="x",expand="true") + TextArea = tkinter.Text(f2) + ScrollBar = tkinter.Scrollbar(f2) + ScrollBar.config(command=TextArea.yview) + ScrollBar.pack(side="right", fill="y") + for i in range(1,32): + try: + f=open(str(i)+' '+a,'r') + except IOError: + continue + TextArea.insert('insert',"\n"+str(i)+' '+a+": \n\n"+f.read()) + TextArea.config(yscrollcommand=ScrollBar.set,state="disabled") + TextArea.pack(fill="both",expand="true") + b1=tkinter.Button(f2,text="Return To MainMenu",bg="#FFFFFF",fg="blue",relief="groove",command=combine_funcs(sub2,start),height=2,width=25) + b1.pack(side="right") + frame.destroy() + f1=tkinter.Frame(bg="#CCCCFF") + f1.pack(fill="both",expand="true") + l1=tkinter.Label(f1,text="Welcome To Expense Manager",bg="#330033",fg="#FFFFFF",relief="groove",pady=30,font=16) + l1.pack(fill="x",expand="true",anchor="n") + l1=tkinter.Label(f1,text="Enter Month And Year:",bg="#330033",fg="#FFFFFF",relief="groove",font=9,padx=50) + l1.place(relx=0.3,rely=0.5) + e=tkinter.Entry(f1) + e.place(relx=0.52,rely=0.5) + b1=tkinter.Button(f1,text="Get Entry",bg="#9999FF",fg="#660099",relief="groove",command=sub_getm,height=2,width=10) + b1.place(relx=0.47,rely=0.56) + + + + +#Get Total Expense By Date: + + +def Sum(): + def sub_Sum(): + def sub2(): + f2.destroy() + t=e.get() + t=t.upper() + try: + f=open(t,'r') + a=f.readlines() + c=0 + for i in range(0,len(a)): + b='' + for j in range(len(a[i])-1,0,-1): + if(a[i][j]!=' ' and a[i][j]>='0' and a[i][j]<='9'): + b=b+a[i][j] + if(a[i][j]>='9'): + break + if(b!=''): + c=c+int(b[::-1]) + f1.destroy() + f2=tkinter.Frame() + f2.pack(fill="both",expand="true") + l1=tkinter.Label(f2,text="Total Expenses On "+t+" Are: \nRs "+str(c),bg="#FFFFFF",fg="#680000",relief="groove",anchor="center",pady=50,font=50) + l1.pack(fill="both",expand="true") + except IOError: + l1=tkinter.Label(f2,text="No Such Entry Is Made "+t+" Are: \nRs "+str(c),bg="#FFFFFF",fg="#680000",relief="groove",anchor="center",pady=50,font=50) + l1.pack(fill="both",expand="true") + b1=tkinter.Button(f2,text="Return To MainMenu",bg="#FFFFFF",fg="blue",relief="groove",command=combine_funcs(sub2,start),height=2,width=25) + b1.pack(side="right") + frame.destroy() + f1=tkinter.Frame(bg="#CCCCFF") + f1.pack(fill="both",expand="true") + l1=tkinter.Label(f1,text="Welcome To Expense Manager",bg="#330033",fg="#FFFFFF",relief="groove",pady=30,font=16) + l1.pack(fill="x",expand="true",anchor="n") + l1=tkinter.Label(f1,text="Enter Date:",bg="#330033",fg="#FFFFFF",relief="groove",font=9,padx=50) + l1.place(relx=0.35,rely=0.5) + e=tkinter.Entry(f1) + e.place(relx=0.52,rely=0.5) + b1=tkinter.Button(f1,text="Get Expenses",bg="#9999FF",fg="#660099",relief="groove",command=sub_Sum,height=2,width=10) + b1.place(relx=0.47,rely=0.56) + +#Defining Get total expense in a month: + +def Summ(): + def sub_Summ(): + def sub2(): + f2.destroy() + a=e.get() + a=a.upper() + c=0 + for i in range(1,32): + try: + f=open(str(i)+' '+a,'r') + t=f.readlines() + for i in range(0,len(t)): + b='' + for j in range(len(t[i])-1,0,-1): + if(t[i][j]!=' ' and t[i][j]>='0' and t[i][j]<='9'): + b=b+t[i][j] + if(b!=''): + c=c+int(b[::-1]) + except IOError: + continue + f1.destroy() + f2=tkinter.Frame() + f2.pack(fill="both",expand="true") + l1=tkinter.Label(f2,text="Total Expenses In "+a+" Are: \nRs "+str(c),bg="#FFFFFF",fg="#680000",relief="groove",anchor="center",pady=50,font=50) + l1.pack(fill="both",expand="true") + b1=tkinter.Button(f2,text="Return To MainMenu",bg="#FFFFFF",fg="blue",relief="groove",command=combine_funcs(sub2,start),height=2,width=25) + b1.pack(side="right") + frame.destroy() + f1=tkinter.Frame(bg="#CCCCFF") + f1.pack(fill="both",expand="true") + l1=tkinter.Label(f1,text="Welcome To Expense Manager",bg="#330033",fg="#FFFFFF",relief="groove",pady=30,font=16) + l1.pack(fill="x",expand="true",anchor="n") + l1=tkinter.Label(f1,text="Enter Month And Year:",bg="#330033",fg="#FFFFFF",relief="groove",font=9,padx=50) + l1.place(relx=0.3,rely=0.5) + e=tkinter.Entry(f1) + e.place(relx=0.52,rely=0.5) + b1=tkinter.Button(f1,text="Get Expenses",bg="#9999FF",fg="#660099",relief="groove",command=sub_Summ,height=2,width=10) + b1.place(relx=0.47,rely=0.56) + + + +# Defining Add to entry: + +def add(): + def sub_add(): + def sub1(): + def sub2(): + f1.destroy() + b=TextArea.get("1.0",'end') + if(b!='0'): + f.write(b) + f.write("\n") + f2.destroy() + f1=tkinter.Frame(bg="#CCCCFF") + f1.pack(fill="both",expand="true") + l1=tkinter.Label(f1,text="Congratulations! Your Entry Is Made.",bg="#330033",fg="#FFFFFF",relief="groove",pady=30,font=16) + l1.pack(fill="x",expand="true") + b1=tkinter.Button(f1,text="Return To MainMenu",bg="#FFFFFF",fg="blue",relief="groove",command=combine_funcs(sub2,start),height=2,width=25) + b1.pack(side="right") + a=e.get() + a=a.upper() + f1.destroy() + f=open(a,"a") + f2=tkinter.Frame(bg="#CCCCFF") + f2.pack(fill="both",expand="true") + l1=tkinter.Label(f2,text="Make An Entry:\n\nExample: Item1 Rs amount\nItem2 Rs amount",bg="#FFFFFF",fg="#680000",relief="groove",anchor="n",pady=50,font=25) + l1.pack(fill="x",expand="true") + TextArea = tkinter.Text(f2) + ScrollBar = tkinter.Scrollbar(f2,bg="white") + ScrollBar.config(command=TextArea.yview) + TextArea.config(yscrollcommand=ScrollBar.set) + ScrollBar.pack(side="right", fill="y") + TextArea.pack(fill="x") + b1=tkinter.Button(f2,text="Submit",bg="#FFFFFF",fg="blue",relief="groove",command=sub1) + b1.pack() + frame.destroy() + f1=tkinter.Frame(bg="#CCCCFF") + f1.pack(fill="both",expand="true") + l1=tkinter.Label(f1,text="Welcome To Expense Manager",bg="#330033",fg="#FFFFFF",relief="groove",pady=30,font=16) + l1.pack(fill="x",expand="true",anchor="n") + l1=tkinter.Label(f1,text="Enter Date:",bg="#330033",fg="#FFFFFF",relief="groove",font=9,padx=50) + l1.place(relx=0.35,rely=0.5) + e=tkinter.Entry(f1) + e.place(relx=0.52,rely=0.5) + b1=tkinter.Button(f1,text="Make Entry",bg="#9999FF",fg="#660099",relief="groove",command=sub_add,height=2,width=10) + b1.place(relx=0.45,rely=0.56) + +# Defining Delete Existing Entry: + +def delete(): + import os + delete=lambda x:os.remove(x) + def sub_delete(): + def sub2(): + f2.destroy() + a=e.get() + a=a.upper() + delete(a) + f1.destroy() + f2=tkinter.Frame(bg="#CCCCFF") + f2.pack(fill="both",expand="true") + l1=tkinter.Label(f2,text="Congratulations! Your Entry Is Deleted.",bg="#330033",fg="#FFFFFF",relief="groove",pady=30,font=16) + l1.pack(fill="x",expand="true") + b1=tkinter.Button(f2,text="Return To MainMenu",bg="#FFFFFF",fg="blue",relief="groove",command=combine_funcs(sub2,start),height=2,width=25) + b1.pack(side="right") + frame.destroy() + f1=tkinter.Frame(bg="#CCCCFF") + f1.pack(fill="both",expand="true") + l1=tkinter.Label(f1,text="Welcome To Expense Manager",bg="#330033",fg="#FFFFFF",relief="groove",pady=30,font=16) + l1.pack(fill="x",expand="true",anchor="n") + l1=tkinter.Label(f1,text="Enter Date:",bg="#330033",fg="#FFFFFF",relief="groove",font=9,padx=50) + l1.place(relx=0.35,rely=0.5) + e=tkinter.Entry(f1) + e.place(relx=0.52,rely=0.5) + b1=tkinter.Button(f1,text="Delete",bg="#9999FF",fg="#660099",relief="groove",command=sub_delete,height=2,width=10) + b1.place(relx=0.47,rely=0.56) + + + +import tkinter +root=tkinter.Tk() +root.geometry('1250x700') +def start(): + global frame + frame=tkinter.Frame(bg="#CCCCFF") + frame.pack(fill="both",expand="true",) + l1=tkinter.Label(frame,text="Welcome To Expense Manager",bg="#330033",fg="#FFFFFF",relief="groove",pady=30,font=16) + l1.pack(fill="x",expand="true",anchor="n") + l1=tkinter.Label(frame,text="Press To Create A new Entry",bg="#330066",fg="#66FFFF",relief="groove",pady=15,font=16,padx=16) + l1.place(relx=0.2,rely=0.2,anchor="n") + b1=tkinter.Button(frame,text="Create Entry Sheet",bg="#9999FF",fg="#660099",relief="solid",command=create,font=11,pady=16,cursor="dot") + b1.place(relx=0.2,rely=0.3,anchor="n") + l1=tkinter.Label(frame,text="Press To Get Entry By Date",bg="#330066",fg="#66FFFF",relief="groove",pady=15,font=16,padx=16) + l1.place(relx=0.4,rely=0.2,anchor="n") + b1=tkinter.Button(frame,text="Get Entry Sheet",bg="#9999FF",fg="#660099",relief="solid",command=get,font=11,pady=16,cursor="dot") + b1.place(relx=0.4,rely=0.3,anchor="n") + l1=tkinter.Label(frame,text="Press To Get Entry By Month",bg="#330066",fg="#66FFFF",relief="groove",pady=15,font=16,padx=7) + l1.place(relx=0.6,rely=0.2,anchor="n") + b1=tkinter.Button(frame,text="Get Monthly Entry Sheet",bg="#9999FF",fg="#660099",relief="solid",command=getm,font=11,pady=16,cursor="dot") + b1.place(relx=0.6,rely=0.3,anchor="n") + l1=tkinter.Label(frame,text="Press To Get Total Expense On Date",bg="#330066",fg="#66FFFF",relief="groove",pady=15,font=16) + l1.place(relx=0.8,rely=0.2,anchor="n") + b1=tkinter.Button(frame,text="Get Total Expense On Date",bg="#9999FF",fg="#660099",relief="solid",command=Sum,font=11,pady=16,cursor="dot") + b1.place(relx=0.8,rely=0.3,anchor="n") + l1=tkinter.Label(frame,text="Press To Get Total Expense In A Month",bg="#330066",fg="#66FFFF",relief="groove",pady=15,font=16) + l1.place(relx=0.3,rely=0.5,anchor="n") + b1=tkinter.Button(frame,text="Get Total Expense",bg="#9999FF",fg="#660099",relief="solid",command=Summ,font=11,pady=16,cursor="dot") + b1.place(relx=0.3,rely=0.6,anchor="n") + l1=tkinter.Label(frame,text="Press To Add To Existing Entry",bg="#330066",fg="#66FFFF",relief="groove",pady=15,font=16) + l1.place(relx=0.51,rely=0.5,anchor="n") + b1=tkinter.Button(frame,text="Add To Entry",bg="#9999FF",fg="#660099",relief="solid",command=add,font=11,pady=16,cursor="dot") + b1.place(relx=0.51,rely=0.6,anchor="n") + l1=tkinter.Label(frame,text="Press To Delete Existing Entry",bg="#330066",fg="#66FFFF",relief="groove",pady=15,font=16) + l1.place(relx=0.7,rely=0.5,anchor="n") + b1=tkinter.Button(frame,text="Delete Entry",bg="#9999FF",fg="#660099",relief="solid",command=delete,font=11,pady=16,cursor="dot") + b1.place(relx=0.7,rely=0.6,anchor="n") + l1=tkinter.Label(frame,text="\u00a9"+" copyright 2016\t\t\t\t\t\t\t\t\t\t\t\t"+"Developed By: Akshit Grover",bg="#330033",fg="#FFFFFF",relief="groove",pady=30,font=16) + l1.pack(fill="x",expand="true",anchor="s") + root.mainloop() +start() diff --git a/bin/facebook-auto-post.py b/bin/facebook-auto-post.py index 39656f7..8f02a23 100644 --- a/bin/facebook-auto-post.py +++ b/bin/facebook-auto-post.py @@ -1,41 +1,41 @@ -from selenium import webdriver -from selenium.webdriver.common.keys import Keys -from time import sleep -from selenium.common.exceptions import TimeoutException -from selenium.webdriver.support.ui import WebDriverWait -from selenium.webdriver.support.ui import Select -from selenium.webdriver.common.by import By -from selenium.webdriver.support import expected_conditions -from selenium.common.exceptions import NoSuchElementException -import time -import getpass - -driver = webdriver.Firefox() -driver.get('https://www.facebook.com/') -print("facebook opened...") -time.sleep(2) -Email = raw_input("Enter your Email ID:") -email = driver.find_element_by_xpath("//input[@id='email' or @name='email']") -email.send_keys(Email) -print("Email Id entered...") -password1=getpass.getpass("Enter your Facebook password: ") -password = driver.find_element_by_xpath("//input[@id='pass']") -password.send_keys(password1) -print("Password entered...") -button = driver.find_element_by_xpath("//input[@id='u_0_r']") -button.click() -print("signed in") -time.sleep(7) -inputbox = driver.find_element_by_css_selector("span._5qtp") -inputbox.click() -time.sleep(3) -Text = raw_input("\tWhats on your mind? Enter here: \n") -text = driver.find_element_by_css_selector("#composer_text_input_box") -text.click() -text.send_keys(Text) -postbutton = driver.find_element_by_xpath("//*[text()='Post']") -postbutton.click() -time.sleep(10) -driver.close() - -#Thank You Stackoverflow and Jio for help +from selenium import webdriver +from selenium.webdriver.common.keys import Keys +from time import sleep +from selenium.common.exceptions import TimeoutException +from selenium.webdriver.support.ui import WebDriverWait +from selenium.webdriver.support.ui import Select +from selenium.webdriver.common.by import By +from selenium.webdriver.support import expected_conditions +from selenium.common.exceptions import NoSuchElementException +import time +import getpass + +driver = webdriver.Firefox() +driver.get('https://www.facebook.com/') +print("facebook opened...") +time.sleep(2) +Email = raw_input("Enter your Email ID:") +email = driver.find_element_by_xpath("//input[@id='email' or @name='email']") +email.send_keys(Email) +print("Email Id entered...") +password1=getpass.getpass("Enter your Facebook password: ") +password = driver.find_element_by_xpath("//input[@id='pass']") +password.send_keys(password1) +print("Password entered...") +button = driver.find_element_by_xpath("//input[@id='u_0_r']") +button.click() +print("signed in") +time.sleep(7) +inputbox = driver.find_element_by_css_selector("span._5qtp") +inputbox.click() +time.sleep(3) +Text = raw_input("\tWhats on your mind? Enter here: \n") +text = driver.find_element_by_css_selector("#composer_text_input_box") +text.click() +text.send_keys(Text) +postbutton = driver.find_element_by_xpath("//*[text()='Post']") +postbutton.click() +time.sleep(10) +driver.close() + +#Thank You Stackoverflow and Jio for help diff --git a/bin/facebook-auto-post.requirements.txt b/bin/facebook-auto-post.requirements.txt index fa9d52e..3e45060 100644 --- a/bin/facebook-auto-post.requirements.txt +++ b/bin/facebook-auto-post.requirements.txt @@ -1 +1 @@ -selenium==3.4.3 +selenium==3.4.3 diff --git a/bin/fetch_html.py b/bin/fetch_html.py new file mode 100644 index 0000000..5131a2d --- /dev/null +++ b/bin/fetch_html.py @@ -0,0 +1,15 @@ +import urllib.request +import sys +from lxml import html + +if len(sys.argv) < 2: + print('Usage example: python fetch_html.py https://github.com') + sys.exit(1) + +url = sys.argv[1] +response = urllib.request.urlopen(url) +html_text = response.read().decode('UTF-8') +text = html.fromstring(html_text).text_content() + +print(text) + diff --git a/bin/ftp_download_file.py b/bin/ftp_download_file.py new file mode 100644 index 0000000..8dbdee4 --- /dev/null +++ b/bin/ftp_download_file.py @@ -0,0 +1,49 @@ +import argparse +import os +from ftplib import FTP + +def parse_args(): + ''' parse and check command line arguments ''' + ap = argparse.ArgumentParser(description="FTP Utility") + ap.add_argument('-hh', dest='host', help="Host name") + ap.add_argument('-u', dest='username', help="user name") + ap.add_argument('-p', dest='password', help="user password") + ap.add_argument('-rd', dest='remote_dir', help="Path to remote directory") + ap.add_argument('-ld', dest='local_dir', help="Path to local directory") + ap.add_argument(dest='files', help="File names", nargs='+') + return ap.parse_args() + +def is_empty(file): + file_size = os.stat(file).st_size + if file_size == 0: + print('The file {} is empty'.format(file)) + return True + return False + + +args=parse_args() + +host = args.host +username = args.username +password = args.password +remote_dir = args.remote_dir +local_dir = args.local_dir +files = args.files + +ftp = FTP(host) +ftp.login(username, password) +ftp.cwd(remote_dir) + +for file in files: + try: + local_filename = os.path.join(local_dir, file) + print('Getting filename: ' + file) + ftp.retrbinary('RETR %s' % file, open(local_filename, 'wb').write) + print('Saving at %s' % local_filename) + except Exception as err: + print(err) + if (is_empty(local_filename)): + os.remove(local_filename) + continue + +ftp.quit() diff --git a/bin/getExternalIp.py b/bin/getExternalIp.py new file mode 100644 index 0000000..9aaba61 --- /dev/null +++ b/bin/getExternalIp.py @@ -0,0 +1,11 @@ +import requests +import re + +try: + res = requests.get("http://whatismyip.org") + myIp = re.compile('(\d{1,3}\.){3}\d{1,3}').search(res.text).group() + if myIp != "": + print(myIp) +except: + print('N/A') + pass diff --git a/bin/image_encoder.py b/bin/image_encoder.py index a03ec5f..552372c 100644 --- a/bin/image_encoder.py +++ b/bin/image_encoder.py @@ -1,25 +1,25 @@ -import base64 -import json -import time - -def b64_encode(source_filepath): - with open(source_filepath, 'rb') as f: - data = f.read() - dest = open('ImageData/encodeData.json','r') - flag = json.loads(dest.read()) - key = (str(int(time.time()))).decode('utf-8') - d = {"data":base64.b64encode(data).decode('utf-8'),"ext":source_filepath[source_filepath.index('.'):]} - flag[key] = d - dest.close() - dest = open('ImageData/encodeData.json','w') - json.dump(flag,dest) - return key - -def b64_decode(key,dest_path): - source = open('ImageData/encodeData.json','r') - flag = json.loads(source.read()) - name = key+str(flag[key]["ext"]) - dest = open(dest_path+name,'wb') - dest.write(base64.b64decode((flag[key]["data"]).encode('utf-8'))) - dest.close() - return dest_path+name +import base64 +import json +import time + +def b64_encode(source_filepath): + with open(source_filepath, 'rb') as f: + data = f.read() + dest = open('ImageData/encodeData.json','r') + flag = json.loads(dest.read()) + key = (str(int(time.time()))).decode('utf-8') + d = {"data":base64.b64encode(data).decode('utf-8'),"ext":source_filepath[source_filepath.index('.'):]} + flag[key] = d + dest.close() + dest = open('ImageData/encodeData.json','w') + json.dump(flag,dest) + return key + +def b64_decode(key,dest_path): + source = open('ImageData/encodeData.json','r') + flag = json.loads(source.read()) + name = key+str(flag[key]["ext"]) + dest = open(dest_path+name,'wb') + dest.write(base64.b64decode((flag[key]["data"]).encode('utf-8'))) + dest.close() + return dest_path+name diff --git a/bin/integrate-graph.py b/bin/integrate-graph.py index 17bd179..218ed66 100644 --- a/bin/integrate-graph.py +++ b/bin/integrate-graph.py @@ -1,82 +1,82 @@ -# -*- coding: utf-8 -*- - -import numpy as np -import matplotlib.pyplot as plt -from matplotlib import animation - -def f(order, coefficients, x): - s = sum([coefficients[i]*(x**(order-i)) for i in range(order+1)]) - return s - -class Integrate(object): - def __init__(self): - self.N = None - self.I = None - - def graph(self, order, coefficients, low, high, interval, ans): - fig=plt.figure() - plt.axes(xlim=(low-5, high+5)) - lines = [plt.plot([], [], color='r')[0] for i in range(30)] - plt.title('Trapezoid Method\nRequired area is %0.2f units' %(ans)) - plt.xlabel('X-axis') - plt.ylabel('Y-axis') - plt.axhline(y=0, color='k') - plt.axvline(x=0, color='k') - x=np.linspace(low, high, 500) - y=f(order, coefficients, x) - s='' - for i in range(order+1): - if coefficients[i]>=0: - s=s+(' +'+str(coefficients[i])+'x^'+str(order-i)) - else: - s=s+(' '+str(coefficients[i])+'x^'+str(order-i)) - s=s+' = 0' - plt.plot(x, y, 'darkslateblue', label=s) - - def init(): - for line in lines: - line.set_data([], []) - return lines - - def animate(i): - if i<2: - for j in range(30): - lines[j].set_data([], []) - else: - x = np.linspace(low, high, i) - y = f(order, coefficients, x) - lines[29].set_data(x, y) - for j in range(i): - lines[j].set_data([x[j], x[j]], [y[j], 0]) - for j in range(i, 29): - lines[j].set_data([], []) - return lines - - animation.FuncAnimation(fig, animate, init_func=init, frames=30, interval=500, blit=True) - plt.legend(loc='upper right', numpoints=1) - plt.show() - - def Trapezoid(self, order, coefficients, low, high, interval): - self.N = (high - low)/interval - self.I = sum([2*f(order, coefficients, low + (i*interval)) for i in range(1, int(self.N))]) - self.I += (f(order, coefficients, low) + f(order, coefficients, high)) - ans = (self.I*(high - low))/(2*self.N) - self.graph(order, coefficients, low, high, interval, ans) - return ans - - def Simpson(self, order, coefficients, low, high, interval): - self.N = (high - low)/(2*interval) - self.I = sum([4*f(order, coefficients, low + (i*interval)) if i%2==1 else 2*f(order, coefficients, low + (i*interval)) for i in range(1, int(2*self.N))]) - self.I += (f(order, coefficients, low) + f(order, coefficients, high)) - return (self.I*(high - low))/(6*self.N) - - def solve(self, order, coefficients, low, high, method, interval = 1e-3): - if method == 'trapezoid': - return self.Trapezoid(order, coefficients, low, high, interval) - elif method == 'simpson': - return self.Simpson(order, coefficients, low, high, interval) - -igr = Integrate() -for method in ['trapezoid'] : - solution = igr.solve(3, [7, 3, -6, 10], -50, 65, method=method) - print (solution) +# -*- coding: utf-8 -*- + +import numpy as np +import matplotlib.pyplot as plt +from matplotlib import animation + +def f(order, coefficients, x): + s = sum([coefficients[i]*(x**(order-i)) for i in range(order+1)]) + return s + +class Integrate(object): + def __init__(self): + self.N = None + self.I = None + + def graph(self, order, coefficients, low, high, interval, ans): + fig=plt.figure() + plt.axes(xlim=(low-5, high+5)) + lines = [plt.plot([], [], color='r')[0] for i in range(30)] + plt.title('Trapezoid Method\nRequired area is %0.2f units' %(ans)) + plt.xlabel('X-axis') + plt.ylabel('Y-axis') + plt.axhline(y=0, color='k') + plt.axvline(x=0, color='k') + x=np.linspace(low, high, 500) + y=f(order, coefficients, x) + s='' + for i in range(order+1): + if coefficients[i]>=0: + s=s+(' +'+str(coefficients[i])+'x^'+str(order-i)) + else: + s=s+(' '+str(coefficients[i])+'x^'+str(order-i)) + s=s+' = 0' + plt.plot(x, y, 'darkslateblue', label=s) + + def init(): + for line in lines: + line.set_data([], []) + return lines + + def animate(i): + if i<2: + for j in range(30): + lines[j].set_data([], []) + else: + x = np.linspace(low, high, i) + y = f(order, coefficients, x) + lines[29].set_data(x, y) + for j in range(i): + lines[j].set_data([x[j], x[j]], [y[j], 0]) + for j in range(i, 29): + lines[j].set_data([], []) + return lines + + animation.FuncAnimation(fig, animate, init_func=init, frames=30, interval=500, blit=True) + plt.legend(loc='upper right', numpoints=1) + plt.show() + + def Trapezoid(self, order, coefficients, low, high, interval): + self.N = (high - low)/interval + self.I = sum([2*f(order, coefficients, low + (i*interval)) for i in range(1, int(self.N))]) + self.I += (f(order, coefficients, low) + f(order, coefficients, high)) + ans = (self.I*(high - low))/(2*self.N) + self.graph(order, coefficients, low, high, interval, ans) + return ans + + def Simpson(self, order, coefficients, low, high, interval): + self.N = (high - low)/(2*interval) + self.I = sum([4*f(order, coefficients, low + (i*interval)) if i%2==1 else 2*f(order, coefficients, low + (i*interval)) for i in range(1, int(2*self.N))]) + self.I += (f(order, coefficients, low) + f(order, coefficients, high)) + return (self.I*(high - low))/(6*self.N) + + def solve(self, order, coefficients, low, high, method, interval = 1e-3): + if method == 'trapezoid': + return self.Trapezoid(order, coefficients, low, high, interval) + elif method == 'simpson': + return self.Simpson(order, coefficients, low, high, interval) + +igr = Integrate() +for method in ['trapezoid'] : + solution = igr.solve(3, [7, 3, -6, 10], -50, 65, method=method) + print (solution) diff --git a/bin/locate-me.py b/bin/locate-me.py index d9c6a33..bdf282a 100644 --- a/bin/locate-me.py +++ b/bin/locate-me.py @@ -1,30 +1,30 @@ -import urllib2 -from urllib2 import urlopen -import json -import re -import requests -# Get Public IP - - -def getPublicIP(): - data = requests.get('http://checkip.dyndns.com/').content - return re.compile(r'Address: (\d+.\d+.\d+.\d+)').search(data).group(1) - -IP = str(getPublicIP()) - -# Get Location -url = 'http://ipinfo.io/' + IP + '/json' -response = urlopen(url) -data = json.load(response) -city = data['city'] -region = data['region'] -country = data['country'] -location = data['loc'] -org = data['org'] - -# Print Extracted Details -print "Your City : " + city -print "Your Region : " + region -print "Your Country : " + country -print "Your Location : " + location -print "Your ISP : " + org +import urllib2 +from urllib2 import urlopen +import json +import re +import requests +# Get Public IP + + +def getPublicIP(): + data = requests.get('http://checkip.dyndns.com/').content + return re.compile(r'Address: (\d+.\d+.\d+.\d+)').search(data).group(1) + +IP = str(getPublicIP()) + +# Get Location +url = 'http://ipinfo.io/' + IP + '/json' +response = urlopen(url) +data = json.load(response) +city = data['city'] +region = data['region'] +country = data['country'] +location = data['loc'] +org = data['org'] + +# Print Extracted Details +print "Your City : " + city +print "Your Region : " + region +print "Your Country : " + country +print "Your Location : " + location +print "Your ISP : " + org diff --git a/bin/memedensity.py b/bin/memedensity.py index 2af6c20..1ad7a15 100644 --- a/bin/memedensity.py +++ b/bin/memedensity.py @@ -1,134 +1,134 @@ - -ASCII = """ - __ __ _____ _ _ - | \/ | | __ \ (_) | - | \ / | ___ _ __ ___ ___| | | | ___ _ __ ___ _| |_ _ _ - | |\/| |/ _ \ '_ ` _ \ / _ \ | | |/ _ \ '_ \/ __| | __| | | | - | | | | __/ | | | | | __/ |__| | __/ | | \__ \ | |_| |_| | - |_| |_|\___|_| |_| |_|\___|_____/ \___|_| |_|___/_|\__|\__, | - __/ | - |___/ -""" - -DESC = """ -- Tells you approximately how many memes are currently in your facebook -newsfeed. Provides % memes in newsfeed. -- Provides memes in newsfeed urls -""" - -import os -import argparse -import requests -import six -from selenium import webdriver -from selenium.webdriver.common.keys import Keys -from time import sleep -from getpass import getpass -from argparse import RawTextHelpFormatter - -if six.PY2: - input = raw_input -else: - pass - -def _login_fb(): - - email = input('> Email or Phone: ') - password = getpass('> Password: ') - - return email,password - -def _xkcd(): - - r = requests.get('http://xkcd.com/info.0.json').json() - return r['img'] - -def _execute_script(email, password, count): - - - print("\nLoading..\nCheck out today's xkcd comic till then : %s \n\n" %(_xkcd())) - - driver = webdriver.PhantomJS() - driver.get('https://www.facebook.com') - - email_ID = driver.find_element_by_id('email') - pass_ID = driver.find_element_by_id('pass') - - - email_ID.send_keys(email) - pass_ID.send_keys(password) - pass_ID.send_keys(Keys.ENTER) - sleep(5) - - for i in range(0,count): - driver.execute_script("window.scrollBy(0, document.body.scrollHeight);") - sleep(1) - - sleep(5) - - driver_tags = driver.execute_script('return document.getElementsByClassName("scaledImageFitWidth img")') - - driver_img_list = { - 'src' : [x.get_attribute('src') for x in driver_tags], - 'alt' : [x.get_attribute('alt') for x in driver_tags], - } - - driver.quit() - - return driver_img_list - - -def _check_memes(driver_img_list, verbose): - - alt_list = driver_img_list['alt'] - if len(alt_list) == 0: - print("Error getting newsfeed. Possibly username or password was incorrect") - return - - output = "\n{} memes in your newsfeed.\n{} total images in your newsfeed.\n{}% memes in newsfeed.\n" - count = 0 - - for key,alt in enumerate(alt_list): - if "text" in alt or "meme" in alt : - count += 1 - if verbose: - print(driver_img_list['src'][key]) - - print(output.format(count,len(alt_list),round(count*100/len(alt_list),2))) - - -def main(): - - print('\n') - - parser = argparse.ArgumentParser( - description='\n{}\n{}\n'.format(ASCII,DESC), formatter_class=RawTextHelpFormatter) - parser.add_argument('-C', '--count', action='store', dest='count', - help='How many times to scroll newsfeed (default = 5)') - parser.add_argument('-L', '--login', action='store_true', - help='Input login credentials') - parser.add_argument('-v', '--verbose', action='store_true', - help='Shows meme urls') - args = parser.parse_args() - - count = int(args.count or '5') - login_bool = args.login - verbose_bool = args.verbose - - if login_bool: - email,password = _login_fb() - else: - try: - email=os.environ['fb_email'] - password=os.environ['fb_pass'] - except KeyError: - print("Couldn't find fb_email and fb_pass in environment variables") - email,password = _login_fb() - - driver_img_list = _execute_script(email, password, count) - _check_memes(driver_img_list, verbose_bool) - - -if __name__ == '__main__': - - main() + +ASCII = """ + __ __ _____ _ _ + | \/ | | __ \ (_) | + | \ / | ___ _ __ ___ ___| | | | ___ _ __ ___ _| |_ _ _ + | |\/| |/ _ \ '_ ` _ \ / _ \ | | |/ _ \ '_ \/ __| | __| | | | + | | | | __/ | | | | | __/ |__| | __/ | | \__ \ | |_| |_| | + |_| |_|\___|_| |_| |_|\___|_____/ \___|_| |_|___/_|\__|\__, | + __/ | + |___/ +""" + +DESC = """ +- Tells you approximately how many memes are currently in your facebook +newsfeed. Provides % memes in newsfeed. +- Provides memes in newsfeed urls +""" + +import os +import argparse +import requests +import six +from selenium import webdriver +from selenium.webdriver.common.keys import Keys +from time import sleep +from getpass import getpass +from argparse import RawTextHelpFormatter + +if six.PY2: + input = raw_input +else: + pass + +def _login_fb(): + + email = input('> Email or Phone: ') + password = getpass('> Password: ') + + return email,password + +def _xkcd(): + + r = requests.get('http://xkcd.com/info.0.json').json() + return r['img'] + +def _execute_script(email, password, count): + + + print("\nLoading..\nCheck out today's xkcd comic till then : %s \n\n" %(_xkcd())) + + driver = webdriver.PhantomJS() + driver.get('https://www.facebook.com') + + email_ID = driver.find_element_by_id('email') + pass_ID = driver.find_element_by_id('pass') + + + email_ID.send_keys(email) + pass_ID.send_keys(password) + pass_ID.send_keys(Keys.ENTER) + sleep(5) + + for i in range(0,count): + driver.execute_script("window.scrollBy(0, document.body.scrollHeight);") + sleep(1) + + sleep(5) + + driver_tags = driver.execute_script('return document.getElementsByClassName("scaledImageFitWidth img")') + + driver_img_list = { + 'src' : [x.get_attribute('src') for x in driver_tags], + 'alt' : [x.get_attribute('alt') for x in driver_tags], + } + + driver.quit() + + return driver_img_list + + +def _check_memes(driver_img_list, verbose): + + alt_list = driver_img_list['alt'] + if len(alt_list) == 0: + print("Error getting newsfeed. Possibly username or password was incorrect") + return + + output = "\n{} memes in your newsfeed.\n{} total images in your newsfeed.\n{}% memes in newsfeed.\n" + count = 0 + + for key,alt in enumerate(alt_list): + if "text" in alt or "meme" in alt : + count += 1 + if verbose: + print(driver_img_list['src'][key]) + + print(output.format(count,len(alt_list),round(count*100/len(alt_list),2))) + + +def main(): + + print('\n') + + parser = argparse.ArgumentParser( + description='\n{}\n{}\n'.format(ASCII,DESC), formatter_class=RawTextHelpFormatter) + parser.add_argument('-C', '--count', action='store', dest='count', + help='How many times to scroll newsfeed (default = 5)') + parser.add_argument('-L', '--login', action='store_true', + help='Input login credentials') + parser.add_argument('-v', '--verbose', action='store_true', + help='Shows meme urls') + args = parser.parse_args() + + count = int(args.count or '5') + login_bool = args.login + verbose_bool = args.verbose + + if login_bool: + email,password = _login_fb() + else: + try: + email=os.environ['fb_email'] + password=os.environ['fb_pass'] + except KeyError: + print("Couldn't find fb_email and fb_pass in environment variables") + email,password = _login_fb() + + driver_img_list = _execute_script(email, password, count) + _check_memes(driver_img_list, verbose_bool) + + +if __name__ == '__main__': + + main() diff --git a/bin/mi-community-bot.py b/bin/mi-community-bot.py index 46196c9..d509f17 100644 --- a/bin/mi-community-bot.py +++ b/bin/mi-community-bot.py @@ -1,49 +1,49 @@ -from selenium import webdriver -from selenium.webdriver.common.keys import Keys -from time import sleep -from selenium.common.exceptions import TimeoutException -from selenium.webdriver.support.ui import WebDriverWait -from selenium.webdriver.support.ui import Select -from selenium.webdriver.common.by import By -from selenium.webdriver.support import expected_conditions -from selenium.common.exceptions import NoSuchElementException -import time -import getpass - -driver = webdriver.Firefox() -driver.get('http://c.mi.com/') -print("Opened MI community...") -signin = driver.find_element_by_css_selector(".sign-action > a:nth-child(1)") -signin.click() -time.sleep(10) -email = driver.find_element_by_xpath("//input[@id='username' or @name='email']") -email.send_keys('Email id') -print("Email Id entered...") -password = driver.find_element_by_xpath("//input[@id='pwd']") -password_input = getpass.getpass("Enter your password:") -password.send_keys(password_input) -print("Password entered...") -button = driver.find_element_by_xpath("//input[@id='login-button']") -button.click() -print('login successfully') -time.sleep(7) -threadbutton = driver.find_element_by_css_selector(".thread-box > h4:nth-child(1) > a:nth-child(2)") -threadbutton.click() -print("clicked on new thread button") -time.sleep(2) -selectforum = Select(driver.find_element_by_name('fid')) - -selectforum.select_by_value('41') -print("Forum selected") -time.sleep(8) -selecttag = Select(driver.find_element_by_name('typeid')) -selecttag.select_by_value('62') -print("Catagory selected") - -title = driver.find_element_by_css_selector("#subject") -title.send_keys('Bot Typing Here....') -print('Title Entered waiting for your contant' ) -time.sleep(10) -submit = driver.find_element_by_css_selector(".btn-orange") -submit.click() -print('submitted') +from selenium import webdriver +from selenium.webdriver.common.keys import Keys +from time import sleep +from selenium.common.exceptions import TimeoutException +from selenium.webdriver.support.ui import WebDriverWait +from selenium.webdriver.support.ui import Select +from selenium.webdriver.common.by import By +from selenium.webdriver.support import expected_conditions +from selenium.common.exceptions import NoSuchElementException +import time +import getpass + +driver = webdriver.Firefox() +driver.get('http://c.mi.com/') +print("Opened MI community...") +signin = driver.find_element_by_css_selector(".sign-action > a:nth-child(1)") +signin.click() +time.sleep(10) +email = driver.find_element_by_xpath("//input[@id='username' or @name='email']") +email.send_keys('Email id') +print("Email Id entered...") +password = driver.find_element_by_xpath("//input[@id='pwd']") +password_input = getpass.getpass("Enter your password:") +password.send_keys(password_input) +print("Password entered...") +button = driver.find_element_by_xpath("//input[@id='login-button']") +button.click() +print('login successfully') +time.sleep(7) +threadbutton = driver.find_element_by_css_selector(".thread-box > h4:nth-child(1) > a:nth-child(2)") +threadbutton.click() +print("clicked on new thread button") +time.sleep(2) +selectforum = Select(driver.find_element_by_name('fid')) + +selectforum.select_by_value('41') +print("Forum selected") +time.sleep(8) +selecttag = Select(driver.find_element_by_name('typeid')) +selecttag.select_by_value('62') +print("Catagory selected") + +title = driver.find_element_by_css_selector("#subject") +title.send_keys('Bot Typing Here....') +print('Title Entered waiting for your contant' ) +time.sleep(10) +submit = driver.find_element_by_css_selector(".btn-orange") +submit.click() +print('submitted') diff --git a/bin/mi-community-bot.requirements.txt b/bin/mi-community-bot.requirements.txt index fa9d52e..3e45060 100644 --- a/bin/mi-community-bot.requirements.txt +++ b/bin/mi-community-bot.requirements.txt @@ -1 +1 @@ -selenium==3.4.3 +selenium==3.4.3 diff --git a/bin/missionaries_and_cannibals_problem.py b/bin/missionaries_and_cannibals_problem.py index bd51b91..674622c 100644 --- a/bin/missionaries_and_cannibals_problem.py +++ b/bin/missionaries_and_cannibals_problem.py @@ -1,103 +1,103 @@ -shore = {1:['m1','m2','m3','c1','c2','c3'],2:[]} -boat = {1:True,2:False} -boat_cap = 0 -boat_hold = [] -choice = 'y' -count = 0 -glob = 1 -def pick(): - print("Pick a person to put on boat/or press enter") - return input() -def check(person,flag,avail_p): - if(person in shore[flag] or person == "" or person in boat_hold): - return True - else: - return False -def check_conditions(shore,flag,cflag,boatf): - num_m = 0 - num_c = 0 - true = 0 - for i in shore[flag]: - if(i[0] == 'm'): - num_m = num_m + 1 - else: - num_c = num_c + 1 - if(num_m < num_c and num_m > 0): - return False - else: - true = 1 - num_m = 0 - num_c = 0 - for i in shore[cflag]+boatf: - if(i[0] == 'm'): - num_m = num_m + 1 - else: - num_c = num_c + 1 - if(num_m < num_c and num_m > 0): - return False - elif(true == 1): - return true -while(choice == 'Y' or choice == 'y'): - count = 0 - win = 0 - while(count <= 25): - def again(shore,boat_hold): - print("People On Shore "+str(flag)+ " are: ") - print() - print(shore[flag] + boat_hold) - shore[flag] = shore[flag] + boat_hold - avail_p = shore[flag] + boat_hold - boat_hold =[] - for i in range(2): - print("For Person " + str(i+1)) - print() - person = pick() - if(i == 0 and person == ""): - while(person == ""): - print("Boat Cannot Be Empty") - person = pick() - if((not person == "") and person in avail_p): - boat_hold.append(person) - del avail_p[avail_p.index(person)] - del shore[flag][shore[flag].index(person)] - elif(person not in avail_p and not person == ""): - print("Invalid Choice") - person = pick() - while(not check(person,flag,avail_p)): - person = pick() - if(person == ""): - break - glob = 0 - return boat_hold - if(boat[1]): - flag = 1 - cflag = 2 - else: - flag = 2 - cflag = 1 - if(glob == 1): - boat_hold = again(shore,boat_hold) - while(not check_conditions(shore,flag,cflag,boat_hold)): - print() - print("** Invalid Move,Try Again **") - print() - boat_hold = again(shore,boat_hold) - print("Sending Boat") - print() - avail_p = shore[cflag] + boat_hold - boat[cflag] = True - boat[flag] = False - glob = 1 - if(len(shore[1]) == 0): - win = 1 - print("Congratulation, You Solved The Problem.") - break - count = count + 1 - if(win == 0): - print() - print("*** Sorry, Number of moves exceeeded ***") - print() - print("Do You Want To Replay? Y/N",end=" ") - choice = input() - - +shore = {1:['m1','m2','m3','c1','c2','c3'],2:[]} +boat = {1:True,2:False} +boat_cap = 0 +boat_hold = [] +choice = 'y' +count = 0 +glob = 1 +def pick(): + print("Pick a person to put on boat/or press enter") + return input() +def check(person,flag,avail_p): + if(person in shore[flag] or person == "" or person in boat_hold): + return True + else: + return False +def check_conditions(shore,flag,cflag,boatf): + num_m = 0 + num_c = 0 + true = 0 + for i in shore[flag]: + if(i[0] == 'm'): + num_m = num_m + 1 + else: + num_c = num_c + 1 + if(num_m < num_c and num_m > 0): + return False + else: + true = 1 + num_m = 0 + num_c = 0 + for i in shore[cflag]+boatf: + if(i[0] == 'm'): + num_m = num_m + 1 + else: + num_c = num_c + 1 + if(num_m < num_c and num_m > 0): + return False + elif(true == 1): + return true +while(choice == 'Y' or choice == 'y'): + count = 0 + win = 0 + while(count <= 25): + def again(shore,boat_hold): + print("People On Shore "+str(flag)+ " are: ") + print() + print(shore[flag] + boat_hold) + shore[flag] = shore[flag] + boat_hold + avail_p = shore[flag] + boat_hold + boat_hold =[] + for i in range(2): + print("For Person " + str(i+1)) + print() + person = pick() + if(i == 0 and person == ""): + while(person == ""): + print("Boat Cannot Be Empty") + person = pick() + if((not person == "") and person in avail_p): + boat_hold.append(person) + del avail_p[avail_p.index(person)] + del shore[flag][shore[flag].index(person)] + elif(person not in avail_p and not person == ""): + print("Invalid Choice") + person = pick() + while(not check(person,flag,avail_p)): + person = pick() + if(person == ""): + break + glob = 0 + return boat_hold + if(boat[1]): + flag = 1 + cflag = 2 + else: + flag = 2 + cflag = 1 + if(glob == 1): + boat_hold = again(shore,boat_hold) + while(not check_conditions(shore,flag,cflag,boat_hold)): + print() + print("** Invalid Move,Try Again **") + print() + boat_hold = again(shore,boat_hold) + print("Sending Boat") + print() + avail_p = shore[cflag] + boat_hold + boat[cflag] = True + boat[flag] = False + glob = 1 + if(len(shore[1]) == 0): + win = 1 + print("Congratulation, You Solved The Problem.") + break + count = count + 1 + if(win == 0): + print() + print("*** Sorry, Number of moves exceeeded ***") + print() + print("Do You Want To Replay? Y/N",end=" ") + choice = input() + + diff --git a/bin/password-strength-checker.py b/bin/password-strength-checker.py index 98a4d85..e12c7ea 100644 --- a/bin/password-strength-checker.py +++ b/bin/password-strength-checker.py @@ -1,19 +1,19 @@ -def checkx(): - email = raw_input('Enter the email:') - if '@' in email and '.' in email: - pass1() - else : - print ('Check you email') - checkx() - -def pass1(): - password = raw_input('Enter the password ') - special = '!@#$%^&*()?' - if len(password) >= 8 and not password.islower() and not password.isupper() and not password.isalpha() and not password.isdigit() and any((c in special) for c in password): - print ('Strong Password') - return 1 - else: - print ('Weak Password') - pass1() - -checkx() +def checkx(): + email = raw_input('Enter the email:') + if '@' in email and '.' in email: + pass1() + else : + print ('Check you email') + checkx() + +def pass1(): + password = raw_input('Enter the password ') + special = '!@#$%^&*()?' + if len(password) >= 8 and not password.islower() and not password.isupper() and not password.isalpha() and not password.isdigit() and any((c in special) for c in password): + print ('Strong Password') + return 1 + else: + print ('Weak Password') + pass1() + +checkx() diff --git a/bin/pi.py b/bin/pi.py index 4500089..2b8672b 100644 --- a/bin/pi.py +++ b/bin/pi.py @@ -1,15 +1,15 @@ -import numpy as np -from numba import jit - -@jit -def aprox_pi(N): - points = 2 * np.random.rand(N, 2) - 1 - M = 0 - - for k in range(N): - if points[k,0]**2 + points[k,1]**2 < 1.: - M += 1 - - return 4.*M/N - -print(aprox_pi(1e8)) +import numpy as np +from numba import jit + +@jit +def aprox_pi(N): + points = 2 * np.random.rand(N, 2) - 1 + M = 0 + + for k in range(N): + if points[k,0]**2 + points[k,1]**2 < 1.: + M += 1 + + return 4.*M/N + +print(aprox_pi(1e8)) diff --git a/bin/plot_example.py b/bin/plot_example.py index 4aec0a2..ca59742 100644 --- a/bin/plot_example.py +++ b/bin/plot_example.py @@ -1,8 +1,8 @@ -import numpy as np -import matplotlib.pyplot as plt - -x = np.linspace(-3, 3, 100) -y = x**2 - -plt.plot(x, y) -plt.show() +import numpy as np +import matplotlib.pyplot as plt + +x = np.linspace(-3, 3, 100) +y = x**2 + +plt.plot(x, y) +plt.show() diff --git a/bin/server_client/client.py b/bin/server_client/client.py index 94f2654..83ef666 100644 --- a/bin/server_client/client.py +++ b/bin/server_client/client.py @@ -1,16 +1,16 @@ -import sys -from socket import socket, AF_INET, SOCK_DGRAM, SOL_SOCKET, SO_REUSEADDR - -SERVER_IP = '127.0.0.1' -PORT_NUMBER = 5000 -SIZE = 1024 -print ("Test client sending packets to IP {0}, via port {1}\n".format(SERVER_IP,PORT_NUMBER)) - -mySocket = socket( SOCK_DGRAM ) -mySocket.connect((SERVER_IP,PORT_NUMBER)) - -while True: - data = mySocket.recv(SIZE) - print(data) -sys.exit() -mySocket.close() +import sys +from socket import socket, AF_INET, SOCK_DGRAM, SOL_SOCKET, SO_REUSEADDR + +SERVER_IP = '127.0.0.1' +PORT_NUMBER = 5000 +SIZE = 1024 +print ("Test client sending packets to IP {0}, via port {1}\n".format(SERVER_IP,PORT_NUMBER)) + +mySocket = socket( SOCK_DGRAM ) +mySocket.connect((SERVER_IP,PORT_NUMBER)) + +while True: + data = mySocket.recv(SIZE) + print(data) +sys.exit() +mySocket.close() diff --git a/bin/server_client/server.py b/bin/server_client/server.py index c02d6c4..0ff2ccc 100644 --- a/bin/server_client/server.py +++ b/bin/server_client/server.py @@ -1,14 +1,14 @@ -from socket import socket, gethostbyname, AF_INET, SOCK_DGRAM, SOL_SOCKET, SO_REUSEADDR -import sys -PORT_NUMBER = 5000 -SIZE = 1024 - -hostName = gethostbyname( 'localhost' ) - -mySocket = socket( SOCK_DGRAM ) -mySocket.bind((hostName, PORT_NUMBER)) -mySocket.listen(1) -while True: - client, addr = mySocket.accept() - data = client.send("Connection Established: ") -sys.exit() +from socket import socket, gethostbyname, AF_INET, SOCK_DGRAM, SOL_SOCKET, SO_REUSEADDR +import sys +PORT_NUMBER = 5000 +SIZE = 1024 + +hostName = gethostbyname( 'localhost' ) + +mySocket = socket( SOCK_DGRAM ) +mySocket.bind((hostName, PORT_NUMBER)) +mySocket.listen(1) +while True: + client, addr = mySocket.accept() + data = client.send("Connection Established: ") +sys.exit() diff --git a/bin/shortener.py b/bin/shortener.py new file mode 100644 index 0000000..ad55e51 --- /dev/null +++ b/bin/shortener.py @@ -0,0 +1,24 @@ +from __future__ import with_statement +import contextlib +try: + from urllib.parse import urlencode +except ImportError: + from urllib import urlencode +try: + from urllib.request import urlopen +except ImportError: + from urllib2 import urlopen +import sys + +def make_tiny(url): + request_url = ('http://tinyurl.com/api-create.php?' + + urlencode({'url':url})) + with contextlib.closing(urlopen(request_url)) as response: + return response.read().decode('utf-8') + +def main(): + for tinyurl in map(make_tiny, sys.argv[1:]): + print(tinyurl) + +if __name__ == '__main__': + main() diff --git a/bin/tweetload.py b/bin/tweetload.py new file mode 100644 index 0000000..bea1cce --- /dev/null +++ b/bin/tweetload.py @@ -0,0 +1,59 @@ +import twitter +import json +import re + +# replace 'default' with twitter user +user = 'default' +# path to json file with your twitter credentials (see https://python-twitter.readthedocs.io/en/latest/) +creds = 'creds.json' +file_name = 'tweets.txt' + + +def init_twitter(): + # load twitter API tokens + with open(creds) as data_file: + data = json.load(data_file) + + api = twitter.Api(consumer_key=data["consumer_key"], + consumer_secret=data["consumer_secret"], + access_token_key=data["access_token_key"], + access_token_secret=data["access_token_secret"]) + + return api + + +def main(): + if user == 'default': + print("Please define the twitter user's screenname to download content from in source code.") + return + + api = init_twitter() + + # get up to 4000 latest tweets + tweets = api.GetUserTimeline(screen_name=user, count=200) + curr_id = tweets[-1].id + for i in range(19): + tweets = tweets + api.GetUserTimeline(screen_name=user, count=200, max_id=curr_id) + curr_id = tweets[-1].id + + print("Tweets: " + str(len(tweets))) + + # write tweets to file + with open(file_name, 'w') as file_o: + for tweet in tweets: + tweet_cont = tweet.text + # strip links + tweet_cont = re.sub(r'http\S+', '', tweet_cont) + # strip mentions + tweet_cont = re.sub(r'@\S+', '', tweet_cont) + # strip hashtags + tweet_cont = re.sub(r'#\S+', '', tweet_cont) + tweet_cont = tweet_cont.replace('RT: ', '') + tweet_cont = tweet_cont.replace('RT', '') + file_o.write(tweet_cont + '\n') + + + + +if __name__ == "__main__": + main() diff --git a/bin/twitter_retweet_bot.py b/bin/twitter_retweet_bot.py new file mode 100644 index 0000000..9d80be4 --- /dev/null +++ b/bin/twitter_retweet_bot.py @@ -0,0 +1,31 @@ +import tweepy # This is a Twitter API helper library. +import time + + +# You should get the following keys and authentication codes for your Twitter account +# Visit apps.twitter.com +consumer_key = 'consumer_key' +consumer_secret = 'consumer_secret' +access_token = 'access_token' +access_token_secret = 'access_token_secret' + + +# Twitter requires 0Auth2 authentication. You can readup about this. +auth = tweepy.OAuthHandler(consumer_key, consumer_secret) +auth.set_access_token(access_token, access_token_secret) +api = tweepy.API(auth) + + +def retweet_bot(): + for tweet in tweepy.Cursor(api.search, q='Hashtag to listen for').items(10): + try: + print('Twitter user: ' + '@' + tweet.user.screen_name) + tweet.retweet() + print('\nDone') + time.sleep(5) # You can remove the time module, if you want the program to continuously retweet + except tweepy.error.TweepError: + pass + + +if __name__ == '__main__': + retweet_bot() diff --git a/bin/youtube-bot-linux.py b/bin/youtube-bot-linux.py index 969f000..ba107d4 100644 --- a/bin/youtube-bot-linux.py +++ b/bin/youtube-bot-linux.py @@ -1,10 +1,10 @@ -import time,webbrowser,os - -url = str(input("Enter your video url in ->\"url here \"<- : ")) -n = input("Enter refresh rate(seconds) : ") -brow = input("Enter your default browser in ->\"browser here \"<- : ") -while (1): - os.system(" killall -9 " + brow) - time.sleep(int(n)) - webbrowser.open(url) - print('Successfully Viewd') +import time,webbrowser,os + +url = str(input("Enter your video url in ->\"url here \"<- : ")) +n = input("Enter refresh rate(seconds) : ") +brow = input("Enter your default browser in ->\"browser here \"<- : ") +while (1): + os.system(" killall -9 " + brow) + time.sleep(int(n)) + webbrowser.open(url) + print('Successfully Viewd') diff --git a/bin/youtube-bot-windows.py b/bin/youtube-bot-windows.py index 473756f..a459292 100644 --- a/bin/youtube-bot-windows.py +++ b/bin/youtube-bot-windows.py @@ -1,10 +1,10 @@ -import time,webbrowser,os - -url = str(input("Enter your video url in ->\"url here \"<- : ")) -n = input("Enter refresh rate(seconds) : ") -brow = input("Enter your default browser in ->\"browser here \"<- : ") -while (1): - os.system("TASKKILL /F /IM " + brow + ".exe") - time.sleep(int(n)) - webbrowser.open(url) - print('Successfully Viewd') +import time,webbrowser,os + +url = str(input("Enter your video url in ->\"url here \"<- : ")) +n = input("Enter refresh rate(seconds) : ") +brow = input("Enter your default browser in ->\"browser here \"<- : ") +while (1): + os.system("TASKKILL /F /IM " + brow + ".exe") + time.sleep(int(n)) + webbrowser.open(url) + print('Successfully Viewd') From 65468e9ff2961ca9b7cbf13737f1a3d5651dd416 Mon Sep 17 00:00:00 2001 From: Khushal Sharma Date: Tue, 7 Nov 2017 14:15:40 +0530 Subject: [PATCH 2/2] Revert "develop updation (#80)" (#81) This reverts commit 7e07a09c20ed93dc41e7c99e8b94c274defbabee. --- README.md | 266 ++------- _config.yml | 1 - bin/Blog_reader.py | 36 +- bin/ImageData/encodeData.json | 2 +- bin/ImagetoData.py | 20 - bin/Lost Robot/Solution.py | 15 - bin/Lost Robot/quiz | 34 -- bin/Pyfirebase.py | 36 +- bin/Video-downloader/license.txt | 201 ------- bin/Video-downloader/vid.py | 107 ---- bin/bulk_add_twitter_list.py | 44 +- bin/caesar_cipher.py | 84 +-- bin/dice_simulator.py | 10 - bin/dictionary/app.py | 17 - bin/dictionary/dict_dialog.py | 56 -- bin/dictionary/dictionary.py | 25 - bin/end_to_end.py | 78 +-- bin/expense_manager.py | 680 +++++++++++----------- bin/facebook-auto-post.py | 82 +-- bin/facebook-auto-post.requirements.txt | 2 +- bin/fetch_html.py | 15 - bin/ftp_download_file.py | 49 -- bin/getExternalIp.py | 11 - bin/image_encoder.py | 50 +- bin/integrate-graph.py | 164 +++--- bin/locate-me.py | 60 +- bin/memedensity.py | 268 ++++----- bin/mi-community-bot.py | 98 ++-- bin/mi-community-bot.requirements.txt | 2 +- bin/missionaries_and_cannibals_problem.py | 206 +++---- bin/password-strength-checker.py | 38 +- bin/pi.py | 30 +- bin/plot_example.py | 16 +- bin/server_client/client.py | 32 +- bin/server_client/server.py | 28 +- bin/shortener.py | 24 - bin/tweetload.py | 59 -- bin/twitter_retweet_bot.py | 31 - bin/youtube-bot-linux.py | 20 +- bin/youtube-bot-windows.py | 20 +- 40 files changed, 1083 insertions(+), 1934 deletions(-) delete mode 100644 _config.yml delete mode 100644 bin/ImagetoData.py delete mode 100644 bin/Lost Robot/Solution.py delete mode 100644 bin/Lost Robot/quiz delete mode 100644 bin/Video-downloader/license.txt delete mode 100644 bin/Video-downloader/vid.py delete mode 100644 bin/dice_simulator.py delete mode 100644 bin/dictionary/app.py delete mode 100644 bin/dictionary/dict_dialog.py delete mode 100644 bin/dictionary/dictionary.py delete mode 100644 bin/fetch_html.py delete mode 100644 bin/ftp_download_file.py delete mode 100644 bin/getExternalIp.py delete mode 100644 bin/shortener.py delete mode 100644 bin/tweetload.py delete mode 100644 bin/twitter_retweet_bot.py diff --git a/README.md b/README.md index 47811a2..dd5823d 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,6 @@ -# [Python Scripts](https://logan1x.github.io/Python-Scripts/) # Python Scripts [![forthebadge](http://forthebadge.com/images/badges/made-with-python.svg)](http://forthebadge.com) -[![forthebadge](http://forthebadge.com/images/badges/made-with-python.svg)](http://forthebadge.com) -[![forthebadge](http://forthebadge.com/images/badges/built-by-developers.svg)](http://forthebadge.com) -[![forthebadge](http://forthebadge.com/images/badges/check-it-out.svg)](http://forthebadge.com) + > This Repo is a collection of Various python scripts. In this repo there are different kinds of python scripts for their respective uses. These all are open sourced and you can use them in any form for free. @@ -21,65 +18,16 @@ cd Python-Scripts/bin ``` ## Scripts -* ### Approximating *pi* - -This script is useful to show a way to approximate the value of pi using a Monte Carlo method. It is also optimized using the `@jit` (*just-in-time*) decorator from the [numba](https://numba.pydata.org/) library. - * ### Meme Density This script tells you the amount of memes in your facebook feed -To see different approximations you just need to modify the argument passed to the main function. - -```bash -python pi.py -``` - -* ### Blog Reader - -Blog Reader is the terminal reader that scrapes the article from [planet dgplug](http://planet.dgplug.org/) and displays it on the terminal. - -It seprates the content accrding to the screen size. - -```bash -python Blog_reader.py -``` - -* ### Bulk add users to Twitter list - -Simple script helps you mass add users to your twitter list to follow (Ex: Bitcoin/Altcoins official account, news, traders...) - -- Prepare list screen names -- Setup your app and get an access token ```bash -pip install twitter -python bulk_add_twitter_list.py -``` - - -* ### Caesar Cipher -Encrypts or Decrypts any message you want, simply enter the message and the rotation number -```bash -python caesar_cipher.py -``` - -* ### End To End Encryption -It is a simple program to implement and understand the basic of end_to_end encryption. -Here i am using caesar cipher to encrpt nbut in reality they Use algotihms lile SHA-1, RSA etc. -```bash -python end_to_end.py -``` - - -* ### Expense Manager -Simple GUI program which helps you calculate your expenses, monitor them just through mouse clicks. All you have to do is run the script and choose an option from the menu which will displayed when you run the script. Enter Your Expenses as eg: "Biscuits Rs 15" " rs " ignore the quotes. +pip install memedensity -```bash -python expense_manger.py +memedensity ``` - - * ### Facebook Auto Post This is python script that log in into facebook and post the status. @@ -91,60 +39,6 @@ pip install -r facebook-auto-post.requirements.txt python facebook-auto-post.py ``` - -* ### Find Large Files - -Searches a file location and subdirectories for files larger than a given size. -Useful for phones which might hide files in FileExplorer, but allow use as flash memory. -Directly prints results if run directly. -May also be imported, yielding results one by one. - -* ### FTP Download File -A simple application to download a file via FTP with the given remote and local path -Parameters: - * -hh hostname - * -u username - * -p password - * -rd remote directory - * -ld local directory -```bash -python ftp_download_file.py - -* ### Fetch HTML -This script fetch html response from the provided url and parse xml tag to get only text content and print out. - -```bash -python fetch_html.py https://github.com -`````` - -* ### Get External IP -Gets the external ip-address from the current machine and prints it to the console -```bash -python getExternalIp.py -``` - -* ### Handy offline dictionary -A tiny offline dictionary app based on nltk wordnet and pyqt5 -```bash -cd dictionary -python app.py -``` - - -* ### Image Encoder -It is a simple program to encode and decode images, which helps to reduce and handle images on server, as it is convertedto base64 address. -```bash -python image_encoder.py -``` - - -* ### Integrate to find area of a graph -The script takes a given graph along with the range within which the area is to be calculated. -It then calculates the area using two methods, the Simpson method and the Trapezoid method and displays the results on a graph. -```bash -python integrate-graph.py -``` - * ### Locate Me Run this script and it will locate you. @@ -163,18 +57,6 @@ This uses [Checkip](http://checkip.dyndns.com/) and [ipinfo.io](http://ipinfo.io python locate-me.py ``` - - -* ### Meme Density -This script tells you the amount of memes in your facebook feed - - -```bash -pip install memedensity - -memedensity -``` - * ### Mi Community Bot This python script uses selenium module in python to automate the thread posting. @@ -186,11 +68,7 @@ If you want to understand this code you can visit [here.](https://l0gan1x.quora. pip install -r mi-community-bot.requirements.txt python mi-community-bot.py ``` -* ### Missionaires And Cannibals Problem -It is a simple program to mimic Missionaries And Cannibals River Crossing Problem. -```bash -python missionaries_and_cannibals_problem.py -``` + * ### Password Strength Checker This code checks for your password strength. For the right password, password must contain mixture of an upper case letters, an digit (including 0-9), and a special characters with lower case letters. @@ -198,104 +76,76 @@ This code checks for your password strength. For the right password, password mu ```bash python password-strength-checker.py ``` -* ### Plotting a function -This script contains an example of plotting a function using [`matplotlib`](http://matplotlib.org/). Feel free to modify the value of `y` to obtain different functions that depend on `x`. * ### YouTube Bot This is a simple python script that increases your video count/ views. Log out from all google accounts and run this. -```bash -python plot_example.py -``` - -* ### Server And Client -It is simple client server communication script, will add more functionality in future. ```bash -cd server_client -python client.py -python server.py +# For Linux Users +python youtube-bot-linux.py + +# For Windows Users +python youtube-bot-windows.py ``` +#### NOTE: +In case your browser stoped working delete/comment the following line in the script. +#### _Linux_ + `os.system(" killall -9 " + brow)` +#### _Windows_ + `os.system("TASKKILL /F /IM " + brow + ".exe")` -* ### Tweetload -Download latest tweets (default: up to 4000) from a specific twitter user. The script will create a file with one tweet per line, stripped from mentions, hashtags and links. -
-For that to work, create a json file with your twitter credentials (see source) and define the twitter user in source code. -```bash -python3 tweetload.py -``` -* ### Blog Reader -* ### Twitter_retweet_bot -It is a simple script that retweets any hashtag provided in it. -```bash -python twitter_retweet_bot.py -``` -* ### Twitter Sentiment Analysis -A python script that goes through the twitter feeds and calculates the sentiment of the users on the topic of Demonetization in India. -Sentiments are calculated to be positive, negative or neutral. -Various other analyses are represented using graphs. - -```bash -pip install -r analyseTweets-requirements.txt -python analyseTweets.py -``` +* ### Blog Reader +Blog Reader is the terminal reader that scrapes the article from [planet dgplug](http://planet.dgplug.org/) and displays it on the terminal. -* ### URL Shortener -This is python script that shortens any URL provided to it. +It seprates the content accrding to the screen size. ```bash -# Takes multiple inputs and returns shortened URL for both -python shortener.py url1 url2 - -#Stores shortened URLs in a file -python shortener.py url1 url2 > file.txt +python Blog_reader.py ``` * ### Find Large Files +Searches a file location and subdirectories for files larger than a given size. +Useful for phones which might hide files in FileExplorer, but allow use as flash memory. +Directly prints results if run directly. +May also be imported, yielding results one by one. -* ### Video-downloader v1.1 -#### About +* ### Approximating *pi* +This script is useful to show a way to approximate the value of pi using a Monte Carlo method. It is also optimized using the `@jit` (*just-in-time*) decorator from the [numba](https://numba.pydata.org/) library. -This file allows the user to download videos off of the web. -* ### Approximating *pi* -as of version 1 the user is able to download highquality videos as a playlist or single file as well as audio files from the supported +To see different approximations you just need to modify the argument passed to the main function. -websites given here http://rg3.github.io/youtube-dl/supportedsites.html are supported. +```bash +python pi.py +``` -More features will be added in the future iterations of the project. -a simple video downloader using youtube-dl Library, a starter script for making use -of youtube-dl. -#### Requirements -* You will need to install youtube_dl - * This can be installed using pip on windows, - * if you do not know how to use pip please read the installation instructions -* requests library - * can be downloaded using pip on windows and respective package managers on different operating systems. -* ffmpeg in order to convert the downloaded files to the right format * ### Plotting a function -#### Installation +This script contains an example of plotting a function using [`matplotlib`](http://matplotlib.org/). Feel free to modify the value of `y` to obtain different functions that depend on `x`. + +```bash +python plot_example.py +``` -clone this repo and run `python vid.py` script! -assuming you already have the other requirements. -#### FFmpeg * ### Bulk add users to Twitter list -Follow this wiki-How tutorial -http://www.wikihow.com/Install-FFmpeg-on-Windows +Simple script helps you mass add users to your twitter list to follow (Ex: Bitcoin/Altcoins official account, news, traders...) -#### PIP +- Prepare list screen names +- Setup your app and get an access token -Extensive information on how to set up virtual env and pip. +```bash +pip install twitter +python bulk_add_twitter_list.py +``` -https://www.dabapps.com/blog/introduction-to-pip-and-virtualenv-python/ * ### Expense Manager Simple GUI program which helps you calculate your expenses, monitor them just through mouse clicks. All you have to do is run the script and choose an option from the menu which will displayed when you run the script. Enter Your Expenses as eg: "Biscuits Rs 15" " rs " ignore the quotes. @@ -325,14 +175,8 @@ Here i am using caesar cipher to encrpt nbut in reality they Use algotihms lile ```bash python end_to_end.py ``` -#### Commands -Just run the script and follow the interface! Videos downloaded in same folder as the script. - -* ### YouTube Bot -This is a simple python script that increases your video count/ views. -Log out from all google accounts and run this. * ### Server And Client It is simple client server communication script, will add more functionality in future. ```bash @@ -345,18 +189,8 @@ python server.py The script takes a given graph along with the range within which the area is to be calculated. It then calculates the area using two methods, the Simpson method and the Trapezoid method and displays the results on a graph. ```bash -# For Linux Users -python youtube-bot-linux.py - -# For Windows Users -python youtube-bot-windows.py +python integrate-graph.py ``` -#### NOTE: -In case your browser stoped working delete/comment the following line in the script. -#### _Linux_ - `os.system(" killall -9 " + brow)` -#### _Windows_ - `os.system("TASKKILL /F /IM " + brow + ".exe")` ## Release History @@ -364,7 +198,6 @@ In case your browser stoped working delete/comment the following line in the scr * 0.0.1 * Work in progress - ## Meta Khushal Sharma – [@Khushal](https://twitter.com/herkuch) – sharmakhushal78@gmail.com @@ -387,7 +220,7 @@ Distributed under the MIT LICENSE license. See [``LICENSE``](https://github.com/ ## Contributors The following people helped in creating the above content. -* Niharika Krishnan + * Khushal Sharma * Kayvan Mazaheri * Lakshay Kalbhor @@ -399,15 +232,6 @@ The following people helped in creating the above content. * Madhav Bahl * Ishank Arora * Vishal Sharma -* Apurva Nitanjay -* Surya K -* Peter L. -* Andreas K. -* Jetsada Machom -* Lukas S. -* Iyanu Ashiri - -### If you like the project give a star [Star button](https://github.com/Logan1x/Python-Scripts/stargazers) - +* Shivam Pachaori -[`Back to Top`](https://github.com/Logan1x/Python-Scripts#python-scripts) +### If you like the project give a star Star button diff --git a/_config.yml b/_config.yml deleted file mode 100644 index 3397c9a..0000000 --- a/_config.yml +++ /dev/null @@ -1 +0,0 @@ -theme: jekyll-theme-architect \ No newline at end of file diff --git a/bin/Blog_reader.py b/bin/Blog_reader.py index c1d9a14..a88f952 100644 --- a/bin/Blog_reader.py +++ b/bin/Blog_reader.py @@ -1,18 +1,18 @@ -from bs4 import BeautifulSoup -import requests -import shutil -page = requests.get("http://planet.dgplug.org/") -soup = BeautifulSoup(page.content, 'html.parser') -data = soup.find_all(class_="entrygroup") -columns = shutil.get_terminal_size().columns -size = len(data)-1 -for i in range(0, size): - piu = data[i] - heading = piu.find("a").get_text() - for n in range(84): - print ("-", end=" ") - print ('{}{}'.format(' ' * (int(columns / 2 - len(heading) / 2)), heading)) - for n in range(84): - print ("-", end=" ") - main_content = piu.find(class_="content").get_text() - print (main_content) +from bs4 import BeautifulSoup +import requests +import shutil +page = requests.get("http://planet.dgplug.org/") +soup = BeautifulSoup(page.content, 'html.parser') +data = soup.find_all(class_="entrygroup") +columns = shutil.get_terminal_size().columns +size = len(data)-1 +for i in range(0, size): + piu = data[i] + heading = piu.find("a").get_text() + for n in range(84): + print ("-", end=" ") + print ('{}{}'.format(' ' * (int(columns / 2 - len(heading) / 2)), heading)) + for n in range(84): + print ("-", end=" ") + main_content = piu.find(class_="content").get_text() + print (main_content) diff --git a/bin/ImageData/encodeData.json b/bin/ImageData/encodeData.json index e02aef2..7a73a41 100644 --- a/bin/ImageData/encodeData.json +++ b/bin/ImageData/encodeData.json @@ -1,2 +1,2 @@ -{ +{ } \ No newline at end of file diff --git a/bin/ImagetoData.py b/bin/ImagetoData.py deleted file mode 100644 index eadcb7e..0000000 --- a/bin/ImagetoData.py +++ /dev/null @@ -1,20 +0,0 @@ -import os, os.path -import numpy as np -from PIL import Image - -if __name__ == '__main__': - def image_classifier(path): - valid_images = [".jpg", ".gif", ".png", ".tga"] - imgs = [] - for f in os.listdir(path): - ext = os.path.splitext(f)[1] - if ext.lower() not in valid_images: - continue - img = Image.open(os.path.join(path, f)) - img = np.array(img.resize((64, 64), Image.ANTIALIAS)) - imgs.append(img) - - return np.array(imgs) - - # converts all images in a particular directory to a 64*64*3 (3 for the rgb value of image) dimension vector - # use - in machine learning and image processing diff --git a/bin/Lost Robot/Solution.py b/bin/Lost Robot/Solution.py deleted file mode 100644 index e314a03..0000000 --- a/bin/Lost Robot/Solution.py +++ /dev/null @@ -1,15 +0,0 @@ -#According to question we can only instruct robot up or down or left or right. So in his current coordiantes and home coordinates one of the/ -#coordinate either X or Y must be same. -for _ in range(int(input()): - x1,y1,x2,y2=map(int,input().split())#This will parse input to x1,y1,x2 and y2 - if x1!=x2 and y1!=y2: - print('sad') - elif x1==x2 and y1y2: - print('down') - elif y1==y2 and x1x2: - print('left') - diff --git a/bin/Lost Robot/quiz b/bin/Lost Robot/quiz deleted file mode 100644 index 02f35da..0000000 --- a/bin/Lost Robot/quiz +++ /dev/null @@ -1,34 +0,0 @@ - -Robot Bunny is lost. It wants to reach its home as soon as possible. Currently it is standing at coordinates (x1, y1) in 2-D plane. -Its home is at coordinates (x2, y2). Bunny is extremely worried. Please help it by giving a command by telling the direction in which it -should to go so as to reach its home. If you give it a direction, it will keep moving in that direction till it reaches its home. -There are four possible directions you can give as command - "left", "right", "up", "down". It might be possible that you can't instruct -the robot in such a way that it reaches its home. In that case, output "sad". - -Input -First line of the input contains an integer T denoting the number of test cases. T test cases follow. - -First line of each test case contains four space separated integers x1, y1, x2, y2. - -Output -For each test case, output a single line containing "left" or "right" or "up" or "down" or "sad" (without quotes). - -Constraints -1 ≤ T ≤ 5000 -0 ≤ x1, y1, x2, y2. ≤ 100 -It's guaranteed that the initial position of robot is not his home. -Example - -Input -3 -0 0 1 0 -0 0 0 1 -0 0 1 1 - -Output: -right -up -sad - -Explanation -Test case 1. If you give Bunny the command to move to the right, it will reach its home. diff --git a/bin/Pyfirebase.py b/bin/Pyfirebase.py index 333b304..ae520dc 100644 --- a/bin/Pyfirebase.py +++ b/bin/Pyfirebase.py @@ -1,18 +1,18 @@ -import requests.packages.urllib3 -requests.packages.urllib3.disable_warnings() -import serial -import json - -arduinoData = serial.Serial('com31',9600) - -from firebase import firebase - -firebase = firebase.FirebaseApplication('https://___YOUR_PROJECT_NAME____.firebaseio.com/') - -while 1: - myData = (arduinoData.readline().strip()) - myData = (myData.decode('utf-8')) - myData = float(myData) - result = firebase.put('MainNode/Leaf','temp',myData) - print 'Data : ',result - +import requests.packages.urllib3 +requests.packages.urllib3.disable_warnings() +import serial +import json + +arduinoData = serial.Serial('com31',9600) + +from firebase import firebase + +firebase = firebase.FirebaseApplication('https://___YOUR_PROJECT_NAME____.firebaseio.com/') + +while 1: + myData = (arduinoData.readline().strip()) + myData = (myData.decode('utf-8')) + myData = float(myData) + result = firebase.put('MainNode/Leaf','temp',myData) + print 'Data : ',result + diff --git a/bin/Video-downloader/license.txt b/bin/Video-downloader/license.txt deleted file mode 100644 index 8dada3e..0000000 --- a/bin/Video-downloader/license.txt +++ /dev/null @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "{}" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright {yyyy} {name of copyright owner} - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/bin/Video-downloader/vid.py b/bin/Video-downloader/vid.py deleted file mode 100644 index 64ef37a..0000000 --- a/bin/Video-downloader/vid.py +++ /dev/null @@ -1,107 +0,0 @@ -from __future__ import unicode_literals -import youtube_dl -import sys -import requests -# Master dictionary--will be expanding in future iterations of the project -# version 1 of vid.py -master = { - 'Audio': { - 'format': 'bestaudio/best', - 'noplaylist': True, - 'postprocessors': [{ - 'key': 'FFmpegExtractAudio', - 'preferredcodec': 'mp3', - 'preferredquality': '192', - }] - }, - 'Video': { - 'format': 'bestvideo+bestaudio/best', - 'noplaylist': True, - 'postprocessors': [{ - 'key': 'FFmpegVideoConvertor', - 'preferedformat': 'mp4', - # 'preferredquality': '137', - }] - }, - 'list': { - 'listsubtitles': True - }, - 'listformat': { - 'lisformats': True - } -} - - -def net(url): - """ - check if the user has connected to the internet. - """ - try: - requests.get(url) - except requests.exceptions.ConnectionError: - print("Please check your network connection.") - return False - except requests.exceptions.Timeout: - print("Site is taking too long to load, TimeOut.") - return False - except requests.exceptions.TooManyRedirects: - print("Too many Redirects.") - return False - except requests.exceptions.RequestException as e: - # catastrophic error. bail. - print(e) - sys.exit(1) - return True - - -def check(link): - """ - checking the validity of the link. - """ - try: - requests.get(link) - return True - except requests.exceptions.ConnectionError: - print("disconnected from network.") - return False - except requests.exceptions.HTTPError as err: - print(err) - return False - - -def download(link,data): - try: - with youtube_dl.YoutubeDL(data) as ydl: - ydl.download([link]) - except youtube_dl.utils.DownloadError as err: - print(err) - - -def main(): - ch = 'Y' - if net(r"https://www.youtube.com/"): - if ch == 'Y': - link = str(input("Enter the link: ")) - if check(link): - print("1.Download an Audio playlist") - print("2.Download a Video playlist") - print("3.Download a Single Audio") - print("4.Download a single video file") - ch=int(input("Enter your choice: ")) - if ch in [1,2,3,4]: - if ch == 1: - master['Audio']['noplaylist'] = False - download(link,master['Audio']) - elif ch == 2: - master['Video']['noplaylist'] = False - download(link,master['Video']) - elif ch == 4: - download(link,master['Video']) - else: - download(link,master['Audio']) - else: - print("Bad choice") - ch = str(input("do you want to continue?(Y/n)")) - -if __name__=="__main__": - main() diff --git a/bin/bulk_add_twitter_list.py b/bin/bulk_add_twitter_list.py index 1bbb8d5..eb9d99d 100644 --- a/bin/bulk_add_twitter_list.py +++ b/bin/bulk_add_twitter_list.py @@ -1,22 +1,22 @@ -from twitter import * - -# install with: pip install twitter -# Create new app and access token from https://apps.twitter.com/ - -token = '' -token_secret = '' - -consumer_key = '' -consumer_secret = '' - -chunk_size = 20 - - -tw = Twitter(auth=OAuth(token, token_secret, consumer_key, consumer_secret)) - -screen_name = 'iEx_ec,LunyrInc,DECENTplatform,musicoins,CoinMagi,augurproject,LiskHQ,dogecoin,monerocurrency,Ripple,Dashpay,omise_go,neo_blockchain,tenxwallet,tokesplatform,WavesPlatform,IncentLoyalty,KomodoPlatform,tokencard_io,monaco_card,eboostcoin,geo_coin,Crowncoin1,MonetaryUnit,ionomics,Golos_Gold,goloschain,ubiqsmart,QtumOfficial,DECENTplatform,bancornetwork,FunFairTech,NxtCommunity,golemproject,wingsplatform,ArkEcosystem,_pivx,vergecurrency,ArdorPlatform,AdEx_Network,AragonProject,civickey,firstbloodio,darcrus,gnosisPM,EOS_io,2givecoin,ad_chain,apx_ventures,officialaur,AttentionToken,BitBayofficial,bitcolncash,BitBeanCoin,bitalize,coinblack,the_blocknet,ArtByteMe,aeoncoin,synereo,spellsofgenesis,breakoutcoin,bit_send,breakoutgaming,bata_money,bitcoindark,bitshares,burstcoin_dev,bytecent_byc,cannabiscoins,cofound_it,clamclient,cloakcoin,clubcoin_co,circuitsofvalue,creditbit,CapriCoinTeam,curecoin_team,decredproject,digibytecoin,digixdao,digixglobal,dgxio,dmdcoin,dopecoingold,E_Drachma,augmentorsgame,dualitychain,edgelessproject,elecgulden,evergreencoin_,emercoin,einsteiniumcoin,energycoin,europecoineuorg,eth_classic,ethereumproject,exclusivecoin,expanseofficial,faircointeam,fair_coop,factom,foldingcoin,official_florin,feathercoin,gambitcrypto,gamecredits,byteballorg,gcrworldwide,goldcoin,gridcoinnetwork,groestlcointeam,matchpool,Humaniq,infxcoin,io_coin,Fermat_ORG,newkorecoin,lbryio,legendsroom,coinlomo,litecoin,maidsafe,pepecoins,melonport,metalpaysme,mysteriumnet,navcoin,officialnubits,neoscoin,gulden,numerai,BeyondVoidGame,nxsearth,okcashcrypto,omni_layer,particlproject,ParticlDev,pinkcoin_,parkbyte_pkb,potcoin,peercoinppc,pesetacoinofic,patientory,qrledger,qwarktoken,radiumcore,rubycoinorg,reddcoin,risevisionteam,safe_Exchange,siatechhq,dualitychain,ShiftNrg,sibchervonec,solarcoin_slr,singulardtv,synergycoin,ethstatus,ProjectSPHR,spreadcointeam,start_coin,StartJOIN,Startwallet,steemit,steemchain,storjproject,stratisplatform,bit_swift,swarmcitydapp,syndicatelabs_,syscoin,thehempcoin,chronobanknews,blocksafe,wetrustplatform,trustplus,transfer_dev,unbreakablcoin,unobtanium_uno,viacoin,voxelus,vericoin,veriumreserve,Vertcoin,vtorrentcrypto,urumproject,XaurumOfficial,counterpartyxcp,digitalnote_xdn,elastic_coin,NEMofficial,stellarorg,myriadcoin,stealthcoin,xvcnews,whitecoiner,zcoinofficial,zcoinproject,zclassiccoin,zcashco,zencashofficial' -screen_name = screen_name.split(',') -for i in range(len(screen_name))[::chunk_size]: - # split to chunk size - sn = ','.join(screen_name[i:i+chunk_size]) - tw.lists.members.create_all(owner_screen_name='your_screen_name_here', slug='your_list', screen_name=sn) +from twitter import * + +# install with: pip install twitter +# Create new app and access token from https://apps.twitter.com/ + +token = '' +token_secret = '' + +consumer_key = '' +consumer_secret = '' + +chunk_size = 20 + + +tw = Twitter(auth=OAuth(token, token_secret, consumer_key, consumer_secret)) + +screen_name = 'iEx_ec,LunyrInc,DECENTplatform,musicoins,CoinMagi,augurproject,LiskHQ,dogecoin,monerocurrency,Ripple,Dashpay,omise_go,neo_blockchain,tenxwallet,tokesplatform,WavesPlatform,IncentLoyalty,KomodoPlatform,tokencard_io,monaco_card,eboostcoin,geo_coin,Crowncoin1,MonetaryUnit,ionomics,Golos_Gold,goloschain,ubiqsmart,QtumOfficial,DECENTplatform,bancornetwork,FunFairTech,NxtCommunity,golemproject,wingsplatform,ArkEcosystem,_pivx,vergecurrency,ArdorPlatform,AdEx_Network,AragonProject,civickey,firstbloodio,darcrus,gnosisPM,EOS_io,2givecoin,ad_chain,apx_ventures,officialaur,AttentionToken,BitBayofficial,bitcolncash,BitBeanCoin,bitalize,coinblack,the_blocknet,ArtByteMe,aeoncoin,synereo,spellsofgenesis,breakoutcoin,bit_send,breakoutgaming,bata_money,bitcoindark,bitshares,burstcoin_dev,bytecent_byc,cannabiscoins,cofound_it,clamclient,cloakcoin,clubcoin_co,circuitsofvalue,creditbit,CapriCoinTeam,curecoin_team,decredproject,digibytecoin,digixdao,digixglobal,dgxio,dmdcoin,dopecoingold,E_Drachma,augmentorsgame,dualitychain,edgelessproject,elecgulden,evergreencoin_,emercoin,einsteiniumcoin,energycoin,europecoineuorg,eth_classic,ethereumproject,exclusivecoin,expanseofficial,faircointeam,fair_coop,factom,foldingcoin,official_florin,feathercoin,gambitcrypto,gamecredits,byteballorg,gcrworldwide,goldcoin,gridcoinnetwork,groestlcointeam,matchpool,Humaniq,infxcoin,io_coin,Fermat_ORG,newkorecoin,lbryio,legendsroom,coinlomo,litecoin,maidsafe,pepecoins,melonport,metalpaysme,mysteriumnet,navcoin,officialnubits,neoscoin,gulden,numerai,BeyondVoidGame,nxsearth,okcashcrypto,omni_layer,particlproject,ParticlDev,pinkcoin_,parkbyte_pkb,potcoin,peercoinppc,pesetacoinofic,patientory,qrledger,qwarktoken,radiumcore,rubycoinorg,reddcoin,risevisionteam,safe_Exchange,siatechhq,dualitychain,ShiftNrg,sibchervonec,solarcoin_slr,singulardtv,synergycoin,ethstatus,ProjectSPHR,spreadcointeam,start_coin,StartJOIN,Startwallet,steemit,steemchain,storjproject,stratisplatform,bit_swift,swarmcitydapp,syndicatelabs_,syscoin,thehempcoin,chronobanknews,blocksafe,wetrustplatform,trustplus,transfer_dev,unbreakablcoin,unobtanium_uno,viacoin,voxelus,vericoin,veriumreserve,Vertcoin,vtorrentcrypto,urumproject,XaurumOfficial,counterpartyxcp,digitalnote_xdn,elastic_coin,NEMofficial,stellarorg,myriadcoin,stealthcoin,xvcnews,whitecoiner,zcoinofficial,zcoinproject,zclassiccoin,zcashco,zencashofficial' +screen_name = screen_name.split(',') +for i in range(len(screen_name))[::chunk_size]: + # split to chunk size + sn = ','.join(screen_name[i:i+chunk_size]) + tw.lists.members.create_all(owner_screen_name='your_screen_name_here', slug='your_list', screen_name=sn) diff --git a/bin/caesar_cipher.py b/bin/caesar_cipher.py index 0bdbc95..df9fc40 100644 --- a/bin/caesar_cipher.py +++ b/bin/caesar_cipher.py @@ -1,42 +1,42 @@ -key = 'abcdefghijklmnopqrstuvwxyz' - -def encrypt(n, plaintext): - """Encrypt the string and return the ciphertext""" - result = '' - - for l in plaintext.lower(): - try: - i = (key.index(l) + n) % 26 - result += key[i] - except ValueError: - result += l - - return result.lower() - - -def decrypt(n, ciphertext): - """Decrypt the string and return the plaintext""" - result = '' - - for l in ciphertext: - try: - i = (key.index(l) - n) % 26 - result += key[i] - except ValueError: - result += l - - return result - -print("Encrypt or decrypt?") -ans = input() -ans = ans.lower() -print("Enter message") -k = input() -print("Enter rotation number") -nn = int(input()) -if ans == 'encrypt': - ret = encrypt(nn,k) - print ('Encrytped: %s' % ret) -else: - ret = decrypt(nn,k) - print ('Decrytped: %s' % ret) +key = 'abcdefghijklmnopqrstuvwxyz' + +def encrypt(n, plaintext): + """Encrypt the string and return the ciphertext""" + result = '' + + for l in plaintext.lower(): + try: + i = (key.index(l) + n) % 26 + result += key[i] + except ValueError: + result += l + + return result.lower() + + +def decrypt(n, ciphertext): + """Decrypt the string and return the plaintext""" + result = '' + + for l in ciphertext: + try: + i = (key.index(l) - n) % 26 + result += key[i] + except ValueError: + result += l + + return result + +print("Encrypt or decrypt?") +ans = input() +ans = ans.lower() +print("Enter message") +k = input() +print("Enter rotation number") +nn = int(input()) +if ans == 'encrypt': + ret = encrypt(nn,k) + print ('Encrytped: %s' % ret) +else: + ret = decrypt(nn,k) + print ('Decrytped: %s' % ret) diff --git a/bin/dice_simulator.py b/bin/dice_simulator.py deleted file mode 100644 index e215d67..0000000 --- a/bin/dice_simulator.py +++ /dev/null @@ -1,10 +0,0 @@ -import random # random is a python built-in module - - -def roll_dice(): - dice_side = random.randrange(1, 7) - print(dice_side) - - -if __name__ == '__main__': - roll_dice() \ No newline at end of file diff --git a/bin/dictionary/app.py b/bin/dictionary/app.py deleted file mode 100644 index 245101c..0000000 --- a/bin/dictionary/app.py +++ /dev/null @@ -1,17 +0,0 @@ -from dict_dialog import Dict_Dialog -from PyQt5.QtWidgets import QApplication, QDialog -import sys - - -class AppWindow(QDialog): - def __init__(self): - super().__init__() - self.ui = Dict_Dialog() - self.ui.setupUi(self) - self.show() - - -app = QApplication(sys.argv) -w = AppWindow() -w.show() -sys.exit(app.exec_()) diff --git a/bin/dictionary/dict_dialog.py b/bin/dictionary/dict_dialog.py deleted file mode 100644 index f788069..0000000 --- a/bin/dictionary/dict_dialog.py +++ /dev/null @@ -1,56 +0,0 @@ -from dictionary import definition -from PyQt5 import QtCore, QtWidgets - - -class Dict_Dialog(object): - def setupUi(self, Dialog): - Dialog.setObjectName("Dictionary") - Dialog.resize(344, 249) - self.widget = QtWidgets.QWidget(Dialog) - self.widget.setGeometry(QtCore.QRect(10, 10, 321, 236)) - self.widget.setObjectName("widget") - self.verticalLayout = QtWidgets.QVBoxLayout(self.widget) - self.verticalLayout.setContentsMargins(0, 0, 0, 0) - self.verticalLayout.setObjectName("verticalLayout") - self.horizontalLayout = QtWidgets.QHBoxLayout() - self.horizontalLayout.setContentsMargins(-1, -1, -1, 4) - self.horizontalLayout.setSpacing(6) - self.horizontalLayout.setObjectName("horizontalLayout") - self.searchText = QtWidgets.QLineEdit(self.widget) - self.searchText.setText("") - self.searchText.setObjectName("searchText") - self.horizontalLayout.addWidget(self.searchText) - self.searchButton = QtWidgets.QPushButton(self.widget) - self.searchButton.setObjectName("searchButton") - self.horizontalLayout.addWidget(self.searchButton) - self.verticalLayout.addLayout(self.horizontalLayout) - self.resultText = QtWidgets.QTextBrowser(self.widget) - self.resultText.setObjectName("resultText") - self.verticalLayout.addWidget(self.resultText) - - # output fonts - font = self.resultText.font() - font.setPointSize(20) - - self.retranslateUi(Dialog) - QtCore.QMetaObject.connectSlotsByName(Dialog) - Dialog.setTabOrder(self.searchText, self.searchButton) - - # events - self.searchButton.clicked.connect(self.show_definition) - - def show_definition(self): - word = self.searchText.text() - defn = definition(word) - - if defn != '': - self.resultText.setText(defn) - else: - self.resultText.setText('definition not found') - - def retranslateUi(self, Dialog): - _translate = QtCore.QCoreApplication.translate - Dialog.setWindowTitle(_translate("Dialog", "Dialog")) - self.searchText.setPlaceholderText( - _translate("Dialog", "word to search")) - self.searchButton.setText(_translate("Dialog", "search")) diff --git a/bin/dictionary/dictionary.py b/bin/dictionary/dictionary.py deleted file mode 100644 index 063801a..0000000 --- a/bin/dictionary/dictionary.py +++ /dev/null @@ -1,25 +0,0 @@ -from nltk.corpus import wordnet as wn - - -def extractInfo(synset): - """ - get string containing definition from a synset - """ - out = synset.pos() + ' : ' - out += synset.definition() - - return out - - -def definition(word): - ssets = wn.synsets(word) - defns = list() - - for i in ssets: - # ensure words in synsets are same - if i.name().split('.')[0] == word: - info = extractInfo(i) - defns.append(info) - - # return defns - return '\n'.join(defns) diff --git a/bin/end_to_end.py b/bin/end_to_end.py index ac360d8..264ca3d 100644 --- a/bin/end_to_end.py +++ b/bin/end_to_end.py @@ -1,39 +1,39 @@ -import time -a = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'] -def encrypt(msg): - off = 3 - enc = "" - for i in msg: - enc = enc + (a[(a.index(i)+off)%26]) - return enc -def decrypt(msg): - off = 3 - dec = "" - for i in msg: - dec = dec + (a[(a.index(i)-off)%26]) - return dec - -#Client Side(Sender) -msg = input("Enter Message To Send: ") -f = open('server.txt','w+') -print("Encrypting..........") -time.sleep(2) -enc = encrypt(msg) -print("Message Sent Is: ",enc) - -#Server Side -f.write(enc) -f.close() - -print() -#Client Side(Reciever) -print("Reciever Is Recieving.........") -time.sleep(2) -f = open('server.txt','r+') -msg = f.read() -print("Message Recieved Is: ",msg) -print("Decrypting........") -time.sleep(2) -dec = decrypt(msg) -print("Message Displayed Is: ",dec) - +import time +a = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'] +def encrypt(msg): + off = 3 + enc = "" + for i in msg: + enc = enc + (a[(a.index(i)+off)%26]) + return enc +def decrypt(msg): + off = 3 + dec = "" + for i in msg: + dec = dec + (a[(a.index(i)-off)%26]) + return dec + +#Client Side(Sender) +msg = input("Enter Message To Send: ") +f = open('server.txt','w+') +print("Encrypting..........") +time.sleep(2) +enc = encrypt(msg) +print("Message Sent Is: ",enc) + +#Server Side +f.write(enc) +f.close() + +print() +#Client Side(Reciever) +print("Reciever Is Recieving.........") +time.sleep(2) +f = open('server.txt','r+') +msg = f.read() +print("Message Recieved Is: ",msg) +print("Decrypting........") +time.sleep(2) +dec = decrypt(msg) +print("Message Displayed Is: ",dec) + diff --git a/bin/expense_manager.py b/bin/expense_manager.py index dad8299..469b2ff 100644 --- a/bin/expense_manager.py +++ b/bin/expense_manager.py @@ -1,340 +1,340 @@ -#General Function: - -def combine_funcs(*funcs): - def combined_func(*args, **kwargs): - for f in funcs: - f(*args, **kwargs) - return combined_func - - - -#Defining the create function: - -def create(): - def sub_create(): - def sub1(): - def sub2(): - f1.destroy() - b=TextArea.get("1.0",'end') - if(b!='0'): - f.write(b) - f.write("\n") - f2.destroy() - f1=tkinter.Frame(bg="#CCCCFF") - f1.pack(fill="both",expand="true") - l1=tkinter.Label(f1,text="Congratulations! Your Entry Is Made.",bg="#330033",fg="#FFFFFF",relief="groove",pady=30,font=16) - l1.pack(fill="x",expand="true") - b1=tkinter.Button(f1,text="Return To MainMenu",bg="#FFFFFF",fg="blue",relief="groove",command=combine_funcs(sub2,start),height=2,width=25) - b1.pack(side="right") - a=e.get() - a=a.upper() - f1.destroy() - f=open(a,"w") - f2=tkinter.Frame(bg="#CCCCFF") - f2.pack(fill="both",expand="true") - l1=tkinter.Label(f2,text="Make An Entry:\n\nExample: Item1 Rs amount\nItem2 Rs amount",bg="#FFFFFF",fg="#680000",relief="groove",anchor="n",pady=50,font=25) - l1.pack(fill="x",expand="true") - TextArea = tkinter.Text(f2) - ScrollBar = tkinter.Scrollbar(f2,bg="white") - ScrollBar.config(command=TextArea.yview) - TextArea.config(yscrollcommand=ScrollBar.set) - ScrollBar.pack(side="right", fill="y") - TextArea.pack(fill="x") - b1=tkinter.Button(f2,text="Submit",bg="#FFFFFF",fg="blue",relief="groove",command=sub1) - b1.pack() - frame.destroy() - f1=tkinter.Frame(bg="#CCCCFF") - f1.pack(fill="both",expand="true") - l1=tkinter.Label(f1,text="Welcome To Expense Manager",bg="#330033",fg="#FFFFFF",relief="groove",pady=30,font=16) - l1.pack(fill="x",expand="true",anchor="n") - l1=tkinter.Label(f1,text="Enter Date:",bg="#330033",fg="#FFFFFF",relief="groove",font=9,padx=50) - l1.place(relx=0.35,rely=0.5) - e=tkinter.Entry(f1) - e.place(relx=0.52,rely=0.5) - b1=tkinter.Button(f1,text="Make Entry",bg="#9999FF",fg="#660099",relief="groove",command=sub_create,height=2,width=10) - b1.place(relx=0.45,rely=0.56) - - -#Defining the get function: - -def get(): - def sub_get(): - def sub2(): - f2.destroy() - a=e.get() - a=a.upper() - f1.destroy() - f=open(a,'r') - f2=tkinter.Frame() - f2.pack(fill="both",expand="true") - l1=tkinter.Label(f2,text="Your Entries For The Date "+a+" Are: ",bg="#FFFFFF",fg="#680000",relief="groove",anchor="center",pady=50) - l1.pack(fill="x",expand="true") - TextArea = tkinter.Text(f2) - ScrollBar = tkinter.Scrollbar(f2) - ScrollBar.config(command=TextArea.yview) - ScrollBar.pack(side="right", fill="y") - TextArea.insert('insert',f.read()) - TextArea.config(yscrollcommand=ScrollBar.set,state="disabled") - TextArea.pack(fill="both",expand="true") - b1=tkinter.Button(f2,text="Return To MainMenu",bg="#FFFFFF",fg="blue",relief="groove",command=combine_funcs(sub2,start),height=2,width=25) - b1.pack(side="right") - frame.destroy() - f1=tkinter.Frame(bg="#CCCCFF") - f1.pack(fill="both",expand="true") - l1=tkinter.Label(f1,text="Welcome To Expense Manager",bg="#330033",fg="#FFFFFF",relief="groove",pady=30,font=16) - l1.pack(fill="x",expand="true",anchor="n") - l1=tkinter.Label(f1,text="Enter Date:",bg="#330033",fg="#FFFFFF",relief="groove",font=9,padx=50) - l1.place(relx=0.35,rely=0.5) - e=tkinter.Entry(f1) - e.place(relx=0.52,rely=0.5) - b1=tkinter.Button(f1,text="Get Entry",bg="#9999FF",fg="#660099",relief="groove",command=sub_get,height=2,width=10) - b1.place(relx=0.45,rely=0.56) - -#Defining the get entry by month function: - -def getm(): - def sub_getm(): - def sub2(): - f2.destroy() - a=e.get() - a=a.upper() - f1.destroy() - f2=tkinter.Frame() - f2.pack(fill="both",expand="true") - l1=tkinter.Label(f2,text="Your Entries For The Month Are: ",bg="#FFFFFF",fg="#680000",relief="groove",anchor="center",pady=50) - l1.pack(fill="x",expand="true") - TextArea = tkinter.Text(f2) - ScrollBar = tkinter.Scrollbar(f2) - ScrollBar.config(command=TextArea.yview) - ScrollBar.pack(side="right", fill="y") - for i in range(1,32): - try: - f=open(str(i)+' '+a,'r') - except IOError: - continue - TextArea.insert('insert',"\n"+str(i)+' '+a+": \n\n"+f.read()) - TextArea.config(yscrollcommand=ScrollBar.set,state="disabled") - TextArea.pack(fill="both",expand="true") - b1=tkinter.Button(f2,text="Return To MainMenu",bg="#FFFFFF",fg="blue",relief="groove",command=combine_funcs(sub2,start),height=2,width=25) - b1.pack(side="right") - frame.destroy() - f1=tkinter.Frame(bg="#CCCCFF") - f1.pack(fill="both",expand="true") - l1=tkinter.Label(f1,text="Welcome To Expense Manager",bg="#330033",fg="#FFFFFF",relief="groove",pady=30,font=16) - l1.pack(fill="x",expand="true",anchor="n") - l1=tkinter.Label(f1,text="Enter Month And Year:",bg="#330033",fg="#FFFFFF",relief="groove",font=9,padx=50) - l1.place(relx=0.3,rely=0.5) - e=tkinter.Entry(f1) - e.place(relx=0.52,rely=0.5) - b1=tkinter.Button(f1,text="Get Entry",bg="#9999FF",fg="#660099",relief="groove",command=sub_getm,height=2,width=10) - b1.place(relx=0.47,rely=0.56) - - - - -#Get Total Expense By Date: - - -def Sum(): - def sub_Sum(): - def sub2(): - f2.destroy() - t=e.get() - t=t.upper() - try: - f=open(t,'r') - a=f.readlines() - c=0 - for i in range(0,len(a)): - b='' - for j in range(len(a[i])-1,0,-1): - if(a[i][j]!=' ' and a[i][j]>='0' and a[i][j]<='9'): - b=b+a[i][j] - if(a[i][j]>='9'): - break - if(b!=''): - c=c+int(b[::-1]) - f1.destroy() - f2=tkinter.Frame() - f2.pack(fill="both",expand="true") - l1=tkinter.Label(f2,text="Total Expenses On "+t+" Are: \nRs "+str(c),bg="#FFFFFF",fg="#680000",relief="groove",anchor="center",pady=50,font=50) - l1.pack(fill="both",expand="true") - except IOError: - l1=tkinter.Label(f2,text="No Such Entry Is Made "+t+" Are: \nRs "+str(c),bg="#FFFFFF",fg="#680000",relief="groove",anchor="center",pady=50,font=50) - l1.pack(fill="both",expand="true") - b1=tkinter.Button(f2,text="Return To MainMenu",bg="#FFFFFF",fg="blue",relief="groove",command=combine_funcs(sub2,start),height=2,width=25) - b1.pack(side="right") - frame.destroy() - f1=tkinter.Frame(bg="#CCCCFF") - f1.pack(fill="both",expand="true") - l1=tkinter.Label(f1,text="Welcome To Expense Manager",bg="#330033",fg="#FFFFFF",relief="groove",pady=30,font=16) - l1.pack(fill="x",expand="true",anchor="n") - l1=tkinter.Label(f1,text="Enter Date:",bg="#330033",fg="#FFFFFF",relief="groove",font=9,padx=50) - l1.place(relx=0.35,rely=0.5) - e=tkinter.Entry(f1) - e.place(relx=0.52,rely=0.5) - b1=tkinter.Button(f1,text="Get Expenses",bg="#9999FF",fg="#660099",relief="groove",command=sub_Sum,height=2,width=10) - b1.place(relx=0.47,rely=0.56) - -#Defining Get total expense in a month: - -def Summ(): - def sub_Summ(): - def sub2(): - f2.destroy() - a=e.get() - a=a.upper() - c=0 - for i in range(1,32): - try: - f=open(str(i)+' '+a,'r') - t=f.readlines() - for i in range(0,len(t)): - b='' - for j in range(len(t[i])-1,0,-1): - if(t[i][j]!=' ' and t[i][j]>='0' and t[i][j]<='9'): - b=b+t[i][j] - if(b!=''): - c=c+int(b[::-1]) - except IOError: - continue - f1.destroy() - f2=tkinter.Frame() - f2.pack(fill="both",expand="true") - l1=tkinter.Label(f2,text="Total Expenses In "+a+" Are: \nRs "+str(c),bg="#FFFFFF",fg="#680000",relief="groove",anchor="center",pady=50,font=50) - l1.pack(fill="both",expand="true") - b1=tkinter.Button(f2,text="Return To MainMenu",bg="#FFFFFF",fg="blue",relief="groove",command=combine_funcs(sub2,start),height=2,width=25) - b1.pack(side="right") - frame.destroy() - f1=tkinter.Frame(bg="#CCCCFF") - f1.pack(fill="both",expand="true") - l1=tkinter.Label(f1,text="Welcome To Expense Manager",bg="#330033",fg="#FFFFFF",relief="groove",pady=30,font=16) - l1.pack(fill="x",expand="true",anchor="n") - l1=tkinter.Label(f1,text="Enter Month And Year:",bg="#330033",fg="#FFFFFF",relief="groove",font=9,padx=50) - l1.place(relx=0.3,rely=0.5) - e=tkinter.Entry(f1) - e.place(relx=0.52,rely=0.5) - b1=tkinter.Button(f1,text="Get Expenses",bg="#9999FF",fg="#660099",relief="groove",command=sub_Summ,height=2,width=10) - b1.place(relx=0.47,rely=0.56) - - - -# Defining Add to entry: - -def add(): - def sub_add(): - def sub1(): - def sub2(): - f1.destroy() - b=TextArea.get("1.0",'end') - if(b!='0'): - f.write(b) - f.write("\n") - f2.destroy() - f1=tkinter.Frame(bg="#CCCCFF") - f1.pack(fill="both",expand="true") - l1=tkinter.Label(f1,text="Congratulations! Your Entry Is Made.",bg="#330033",fg="#FFFFFF",relief="groove",pady=30,font=16) - l1.pack(fill="x",expand="true") - b1=tkinter.Button(f1,text="Return To MainMenu",bg="#FFFFFF",fg="blue",relief="groove",command=combine_funcs(sub2,start),height=2,width=25) - b1.pack(side="right") - a=e.get() - a=a.upper() - f1.destroy() - f=open(a,"a") - f2=tkinter.Frame(bg="#CCCCFF") - f2.pack(fill="both",expand="true") - l1=tkinter.Label(f2,text="Make An Entry:\n\nExample: Item1 Rs amount\nItem2 Rs amount",bg="#FFFFFF",fg="#680000",relief="groove",anchor="n",pady=50,font=25) - l1.pack(fill="x",expand="true") - TextArea = tkinter.Text(f2) - ScrollBar = tkinter.Scrollbar(f2,bg="white") - ScrollBar.config(command=TextArea.yview) - TextArea.config(yscrollcommand=ScrollBar.set) - ScrollBar.pack(side="right", fill="y") - TextArea.pack(fill="x") - b1=tkinter.Button(f2,text="Submit",bg="#FFFFFF",fg="blue",relief="groove",command=sub1) - b1.pack() - frame.destroy() - f1=tkinter.Frame(bg="#CCCCFF") - f1.pack(fill="both",expand="true") - l1=tkinter.Label(f1,text="Welcome To Expense Manager",bg="#330033",fg="#FFFFFF",relief="groove",pady=30,font=16) - l1.pack(fill="x",expand="true",anchor="n") - l1=tkinter.Label(f1,text="Enter Date:",bg="#330033",fg="#FFFFFF",relief="groove",font=9,padx=50) - l1.place(relx=0.35,rely=0.5) - e=tkinter.Entry(f1) - e.place(relx=0.52,rely=0.5) - b1=tkinter.Button(f1,text="Make Entry",bg="#9999FF",fg="#660099",relief="groove",command=sub_add,height=2,width=10) - b1.place(relx=0.45,rely=0.56) - -# Defining Delete Existing Entry: - -def delete(): - import os - delete=lambda x:os.remove(x) - def sub_delete(): - def sub2(): - f2.destroy() - a=e.get() - a=a.upper() - delete(a) - f1.destroy() - f2=tkinter.Frame(bg="#CCCCFF") - f2.pack(fill="both",expand="true") - l1=tkinter.Label(f2,text="Congratulations! Your Entry Is Deleted.",bg="#330033",fg="#FFFFFF",relief="groove",pady=30,font=16) - l1.pack(fill="x",expand="true") - b1=tkinter.Button(f2,text="Return To MainMenu",bg="#FFFFFF",fg="blue",relief="groove",command=combine_funcs(sub2,start),height=2,width=25) - b1.pack(side="right") - frame.destroy() - f1=tkinter.Frame(bg="#CCCCFF") - f1.pack(fill="both",expand="true") - l1=tkinter.Label(f1,text="Welcome To Expense Manager",bg="#330033",fg="#FFFFFF",relief="groove",pady=30,font=16) - l1.pack(fill="x",expand="true",anchor="n") - l1=tkinter.Label(f1,text="Enter Date:",bg="#330033",fg="#FFFFFF",relief="groove",font=9,padx=50) - l1.place(relx=0.35,rely=0.5) - e=tkinter.Entry(f1) - e.place(relx=0.52,rely=0.5) - b1=tkinter.Button(f1,text="Delete",bg="#9999FF",fg="#660099",relief="groove",command=sub_delete,height=2,width=10) - b1.place(relx=0.47,rely=0.56) - - - -import tkinter -root=tkinter.Tk() -root.geometry('1250x700') -def start(): - global frame - frame=tkinter.Frame(bg="#CCCCFF") - frame.pack(fill="both",expand="true",) - l1=tkinter.Label(frame,text="Welcome To Expense Manager",bg="#330033",fg="#FFFFFF",relief="groove",pady=30,font=16) - l1.pack(fill="x",expand="true",anchor="n") - l1=tkinter.Label(frame,text="Press To Create A new Entry",bg="#330066",fg="#66FFFF",relief="groove",pady=15,font=16,padx=16) - l1.place(relx=0.2,rely=0.2,anchor="n") - b1=tkinter.Button(frame,text="Create Entry Sheet",bg="#9999FF",fg="#660099",relief="solid",command=create,font=11,pady=16,cursor="dot") - b1.place(relx=0.2,rely=0.3,anchor="n") - l1=tkinter.Label(frame,text="Press To Get Entry By Date",bg="#330066",fg="#66FFFF",relief="groove",pady=15,font=16,padx=16) - l1.place(relx=0.4,rely=0.2,anchor="n") - b1=tkinter.Button(frame,text="Get Entry Sheet",bg="#9999FF",fg="#660099",relief="solid",command=get,font=11,pady=16,cursor="dot") - b1.place(relx=0.4,rely=0.3,anchor="n") - l1=tkinter.Label(frame,text="Press To Get Entry By Month",bg="#330066",fg="#66FFFF",relief="groove",pady=15,font=16,padx=7) - l1.place(relx=0.6,rely=0.2,anchor="n") - b1=tkinter.Button(frame,text="Get Monthly Entry Sheet",bg="#9999FF",fg="#660099",relief="solid",command=getm,font=11,pady=16,cursor="dot") - b1.place(relx=0.6,rely=0.3,anchor="n") - l1=tkinter.Label(frame,text="Press To Get Total Expense On Date",bg="#330066",fg="#66FFFF",relief="groove",pady=15,font=16) - l1.place(relx=0.8,rely=0.2,anchor="n") - b1=tkinter.Button(frame,text="Get Total Expense On Date",bg="#9999FF",fg="#660099",relief="solid",command=Sum,font=11,pady=16,cursor="dot") - b1.place(relx=0.8,rely=0.3,anchor="n") - l1=tkinter.Label(frame,text="Press To Get Total Expense In A Month",bg="#330066",fg="#66FFFF",relief="groove",pady=15,font=16) - l1.place(relx=0.3,rely=0.5,anchor="n") - b1=tkinter.Button(frame,text="Get Total Expense",bg="#9999FF",fg="#660099",relief="solid",command=Summ,font=11,pady=16,cursor="dot") - b1.place(relx=0.3,rely=0.6,anchor="n") - l1=tkinter.Label(frame,text="Press To Add To Existing Entry",bg="#330066",fg="#66FFFF",relief="groove",pady=15,font=16) - l1.place(relx=0.51,rely=0.5,anchor="n") - b1=tkinter.Button(frame,text="Add To Entry",bg="#9999FF",fg="#660099",relief="solid",command=add,font=11,pady=16,cursor="dot") - b1.place(relx=0.51,rely=0.6,anchor="n") - l1=tkinter.Label(frame,text="Press To Delete Existing Entry",bg="#330066",fg="#66FFFF",relief="groove",pady=15,font=16) - l1.place(relx=0.7,rely=0.5,anchor="n") - b1=tkinter.Button(frame,text="Delete Entry",bg="#9999FF",fg="#660099",relief="solid",command=delete,font=11,pady=16,cursor="dot") - b1.place(relx=0.7,rely=0.6,anchor="n") - l1=tkinter.Label(frame,text="\u00a9"+" copyright 2016\t\t\t\t\t\t\t\t\t\t\t\t"+"Developed By: Akshit Grover",bg="#330033",fg="#FFFFFF",relief="groove",pady=30,font=16) - l1.pack(fill="x",expand="true",anchor="s") - root.mainloop() -start() +#General Function: + +def combine_funcs(*funcs): + def combined_func(*args, **kwargs): + for f in funcs: + f(*args, **kwargs) + return combined_func + + + +#Defining the create function: + +def create(): + def sub_create(): + def sub1(): + def sub2(): + f1.destroy() + b=TextArea.get("1.0",'end') + if(b!='0'): + f.write(b) + f.write("\n") + f2.destroy() + f1=tkinter.Frame(bg="#CCCCFF") + f1.pack(fill="both",expand="true") + l1=tkinter.Label(f1,text="Congratulations! Your Entry Is Made.",bg="#330033",fg="#FFFFFF",relief="groove",pady=30,font=16) + l1.pack(fill="x",expand="true") + b1=tkinter.Button(f1,text="Return To MainMenu",bg="#FFFFFF",fg="blue",relief="groove",command=combine_funcs(sub2,start),height=2,width=25) + b1.pack(side="right") + a=e.get() + a=a.upper() + f1.destroy() + f=open(a,"w") + f2=tkinter.Frame(bg="#CCCCFF") + f2.pack(fill="both",expand="true") + l1=tkinter.Label(f2,text="Make An Entry:\n\nExample: Item1 Rs amount\nItem2 Rs amount",bg="#FFFFFF",fg="#680000",relief="groove",anchor="n",pady=50,font=25) + l1.pack(fill="x",expand="true") + TextArea = tkinter.Text(f2) + ScrollBar = tkinter.Scrollbar(f2,bg="white") + ScrollBar.config(command=TextArea.yview) + TextArea.config(yscrollcommand=ScrollBar.set) + ScrollBar.pack(side="right", fill="y") + TextArea.pack(fill="x") + b1=tkinter.Button(f2,text="Submit",bg="#FFFFFF",fg="blue",relief="groove",command=sub1) + b1.pack() + frame.destroy() + f1=tkinter.Frame(bg="#CCCCFF") + f1.pack(fill="both",expand="true") + l1=tkinter.Label(f1,text="Welcome To Expense Manager",bg="#330033",fg="#FFFFFF",relief="groove",pady=30,font=16) + l1.pack(fill="x",expand="true",anchor="n") + l1=tkinter.Label(f1,text="Enter Date:",bg="#330033",fg="#FFFFFF",relief="groove",font=9,padx=50) + l1.place(relx=0.35,rely=0.5) + e=tkinter.Entry(f1) + e.place(relx=0.52,rely=0.5) + b1=tkinter.Button(f1,text="Make Entry",bg="#9999FF",fg="#660099",relief="groove",command=sub_create,height=2,width=10) + b1.place(relx=0.45,rely=0.56) + + +#Defining the get function: + +def get(): + def sub_get(): + def sub2(): + f2.destroy() + a=e.get() + a=a.upper() + f1.destroy() + f=open(a,'r') + f2=tkinter.Frame() + f2.pack(fill="both",expand="true") + l1=tkinter.Label(f2,text="Your Entries For The Date "+a+" Are: ",bg="#FFFFFF",fg="#680000",relief="groove",anchor="center",pady=50) + l1.pack(fill="x",expand="true") + TextArea = tkinter.Text(f2) + ScrollBar = tkinter.Scrollbar(f2) + ScrollBar.config(command=TextArea.yview) + ScrollBar.pack(side="right", fill="y") + TextArea.insert('insert',f.read()) + TextArea.config(yscrollcommand=ScrollBar.set,state="disabled") + TextArea.pack(fill="both",expand="true") + b1=tkinter.Button(f2,text="Return To MainMenu",bg="#FFFFFF",fg="blue",relief="groove",command=combine_funcs(sub2,start),height=2,width=25) + b1.pack(side="right") + frame.destroy() + f1=tkinter.Frame(bg="#CCCCFF") + f1.pack(fill="both",expand="true") + l1=tkinter.Label(f1,text="Welcome To Expense Manager",bg="#330033",fg="#FFFFFF",relief="groove",pady=30,font=16) + l1.pack(fill="x",expand="true",anchor="n") + l1=tkinter.Label(f1,text="Enter Date:",bg="#330033",fg="#FFFFFF",relief="groove",font=9,padx=50) + l1.place(relx=0.35,rely=0.5) + e=tkinter.Entry(f1) + e.place(relx=0.52,rely=0.5) + b1=tkinter.Button(f1,text="Get Entry",bg="#9999FF",fg="#660099",relief="groove",command=sub_get,height=2,width=10) + b1.place(relx=0.45,rely=0.56) + +#Defining the get entry by month function: + +def getm(): + def sub_getm(): + def sub2(): + f2.destroy() + a=e.get() + a=a.upper() + f1.destroy() + f2=tkinter.Frame() + f2.pack(fill="both",expand="true") + l1=tkinter.Label(f2,text="Your Entries For The Month Are: ",bg="#FFFFFF",fg="#680000",relief="groove",anchor="center",pady=50) + l1.pack(fill="x",expand="true") + TextArea = tkinter.Text(f2) + ScrollBar = tkinter.Scrollbar(f2) + ScrollBar.config(command=TextArea.yview) + ScrollBar.pack(side="right", fill="y") + for i in range(1,32): + try: + f=open(str(i)+' '+a,'r') + except IOError: + continue + TextArea.insert('insert',"\n"+str(i)+' '+a+": \n\n"+f.read()) + TextArea.config(yscrollcommand=ScrollBar.set,state="disabled") + TextArea.pack(fill="both",expand="true") + b1=tkinter.Button(f2,text="Return To MainMenu",bg="#FFFFFF",fg="blue",relief="groove",command=combine_funcs(sub2,start),height=2,width=25) + b1.pack(side="right") + frame.destroy() + f1=tkinter.Frame(bg="#CCCCFF") + f1.pack(fill="both",expand="true") + l1=tkinter.Label(f1,text="Welcome To Expense Manager",bg="#330033",fg="#FFFFFF",relief="groove",pady=30,font=16) + l1.pack(fill="x",expand="true",anchor="n") + l1=tkinter.Label(f1,text="Enter Month And Year:",bg="#330033",fg="#FFFFFF",relief="groove",font=9,padx=50) + l1.place(relx=0.3,rely=0.5) + e=tkinter.Entry(f1) + e.place(relx=0.52,rely=0.5) + b1=tkinter.Button(f1,text="Get Entry",bg="#9999FF",fg="#660099",relief="groove",command=sub_getm,height=2,width=10) + b1.place(relx=0.47,rely=0.56) + + + + +#Get Total Expense By Date: + + +def Sum(): + def sub_Sum(): + def sub2(): + f2.destroy() + t=e.get() + t=t.upper() + try: + f=open(t,'r') + a=f.readlines() + c=0 + for i in range(0,len(a)): + b='' + for j in range(len(a[i])-1,0,-1): + if(a[i][j]!=' ' and a[i][j]>='0' and a[i][j]<='9'): + b=b+a[i][j] + if(a[i][j]>='9'): + break + if(b!=''): + c=c+int(b[::-1]) + f1.destroy() + f2=tkinter.Frame() + f2.pack(fill="both",expand="true") + l1=tkinter.Label(f2,text="Total Expenses On "+t+" Are: \nRs "+str(c),bg="#FFFFFF",fg="#680000",relief="groove",anchor="center",pady=50,font=50) + l1.pack(fill="both",expand="true") + except IOError: + l1=tkinter.Label(f2,text="No Such Entry Is Made "+t+" Are: \nRs "+str(c),bg="#FFFFFF",fg="#680000",relief="groove",anchor="center",pady=50,font=50) + l1.pack(fill="both",expand="true") + b1=tkinter.Button(f2,text="Return To MainMenu",bg="#FFFFFF",fg="blue",relief="groove",command=combine_funcs(sub2,start),height=2,width=25) + b1.pack(side="right") + frame.destroy() + f1=tkinter.Frame(bg="#CCCCFF") + f1.pack(fill="both",expand="true") + l1=tkinter.Label(f1,text="Welcome To Expense Manager",bg="#330033",fg="#FFFFFF",relief="groove",pady=30,font=16) + l1.pack(fill="x",expand="true",anchor="n") + l1=tkinter.Label(f1,text="Enter Date:",bg="#330033",fg="#FFFFFF",relief="groove",font=9,padx=50) + l1.place(relx=0.35,rely=0.5) + e=tkinter.Entry(f1) + e.place(relx=0.52,rely=0.5) + b1=tkinter.Button(f1,text="Get Expenses",bg="#9999FF",fg="#660099",relief="groove",command=sub_Sum,height=2,width=10) + b1.place(relx=0.47,rely=0.56) + +#Defining Get total expense in a month: + +def Summ(): + def sub_Summ(): + def sub2(): + f2.destroy() + a=e.get() + a=a.upper() + c=0 + for i in range(1,32): + try: + f=open(str(i)+' '+a,'r') + t=f.readlines() + for i in range(0,len(t)): + b='' + for j in range(len(t[i])-1,0,-1): + if(t[i][j]!=' ' and t[i][j]>='0' and t[i][j]<='9'): + b=b+t[i][j] + if(b!=''): + c=c+int(b[::-1]) + except IOError: + continue + f1.destroy() + f2=tkinter.Frame() + f2.pack(fill="both",expand="true") + l1=tkinter.Label(f2,text="Total Expenses In "+a+" Are: \nRs "+str(c),bg="#FFFFFF",fg="#680000",relief="groove",anchor="center",pady=50,font=50) + l1.pack(fill="both",expand="true") + b1=tkinter.Button(f2,text="Return To MainMenu",bg="#FFFFFF",fg="blue",relief="groove",command=combine_funcs(sub2,start),height=2,width=25) + b1.pack(side="right") + frame.destroy() + f1=tkinter.Frame(bg="#CCCCFF") + f1.pack(fill="both",expand="true") + l1=tkinter.Label(f1,text="Welcome To Expense Manager",bg="#330033",fg="#FFFFFF",relief="groove",pady=30,font=16) + l1.pack(fill="x",expand="true",anchor="n") + l1=tkinter.Label(f1,text="Enter Month And Year:",bg="#330033",fg="#FFFFFF",relief="groove",font=9,padx=50) + l1.place(relx=0.3,rely=0.5) + e=tkinter.Entry(f1) + e.place(relx=0.52,rely=0.5) + b1=tkinter.Button(f1,text="Get Expenses",bg="#9999FF",fg="#660099",relief="groove",command=sub_Summ,height=2,width=10) + b1.place(relx=0.47,rely=0.56) + + + +# Defining Add to entry: + +def add(): + def sub_add(): + def sub1(): + def sub2(): + f1.destroy() + b=TextArea.get("1.0",'end') + if(b!='0'): + f.write(b) + f.write("\n") + f2.destroy() + f1=tkinter.Frame(bg="#CCCCFF") + f1.pack(fill="both",expand="true") + l1=tkinter.Label(f1,text="Congratulations! Your Entry Is Made.",bg="#330033",fg="#FFFFFF",relief="groove",pady=30,font=16) + l1.pack(fill="x",expand="true") + b1=tkinter.Button(f1,text="Return To MainMenu",bg="#FFFFFF",fg="blue",relief="groove",command=combine_funcs(sub2,start),height=2,width=25) + b1.pack(side="right") + a=e.get() + a=a.upper() + f1.destroy() + f=open(a,"a") + f2=tkinter.Frame(bg="#CCCCFF") + f2.pack(fill="both",expand="true") + l1=tkinter.Label(f2,text="Make An Entry:\n\nExample: Item1 Rs amount\nItem2 Rs amount",bg="#FFFFFF",fg="#680000",relief="groove",anchor="n",pady=50,font=25) + l1.pack(fill="x",expand="true") + TextArea = tkinter.Text(f2) + ScrollBar = tkinter.Scrollbar(f2,bg="white") + ScrollBar.config(command=TextArea.yview) + TextArea.config(yscrollcommand=ScrollBar.set) + ScrollBar.pack(side="right", fill="y") + TextArea.pack(fill="x") + b1=tkinter.Button(f2,text="Submit",bg="#FFFFFF",fg="blue",relief="groove",command=sub1) + b1.pack() + frame.destroy() + f1=tkinter.Frame(bg="#CCCCFF") + f1.pack(fill="both",expand="true") + l1=tkinter.Label(f1,text="Welcome To Expense Manager",bg="#330033",fg="#FFFFFF",relief="groove",pady=30,font=16) + l1.pack(fill="x",expand="true",anchor="n") + l1=tkinter.Label(f1,text="Enter Date:",bg="#330033",fg="#FFFFFF",relief="groove",font=9,padx=50) + l1.place(relx=0.35,rely=0.5) + e=tkinter.Entry(f1) + e.place(relx=0.52,rely=0.5) + b1=tkinter.Button(f1,text="Make Entry",bg="#9999FF",fg="#660099",relief="groove",command=sub_add,height=2,width=10) + b1.place(relx=0.45,rely=0.56) + +# Defining Delete Existing Entry: + +def delete(): + import os + delete=lambda x:os.remove(x) + def sub_delete(): + def sub2(): + f2.destroy() + a=e.get() + a=a.upper() + delete(a) + f1.destroy() + f2=tkinter.Frame(bg="#CCCCFF") + f2.pack(fill="both",expand="true") + l1=tkinter.Label(f2,text="Congratulations! Your Entry Is Deleted.",bg="#330033",fg="#FFFFFF",relief="groove",pady=30,font=16) + l1.pack(fill="x",expand="true") + b1=tkinter.Button(f2,text="Return To MainMenu",bg="#FFFFFF",fg="blue",relief="groove",command=combine_funcs(sub2,start),height=2,width=25) + b1.pack(side="right") + frame.destroy() + f1=tkinter.Frame(bg="#CCCCFF") + f1.pack(fill="both",expand="true") + l1=tkinter.Label(f1,text="Welcome To Expense Manager",bg="#330033",fg="#FFFFFF",relief="groove",pady=30,font=16) + l1.pack(fill="x",expand="true",anchor="n") + l1=tkinter.Label(f1,text="Enter Date:",bg="#330033",fg="#FFFFFF",relief="groove",font=9,padx=50) + l1.place(relx=0.35,rely=0.5) + e=tkinter.Entry(f1) + e.place(relx=0.52,rely=0.5) + b1=tkinter.Button(f1,text="Delete",bg="#9999FF",fg="#660099",relief="groove",command=sub_delete,height=2,width=10) + b1.place(relx=0.47,rely=0.56) + + + +import tkinter +root=tkinter.Tk() +root.geometry('1250x700') +def start(): + global frame + frame=tkinter.Frame(bg="#CCCCFF") + frame.pack(fill="both",expand="true",) + l1=tkinter.Label(frame,text="Welcome To Expense Manager",bg="#330033",fg="#FFFFFF",relief="groove",pady=30,font=16) + l1.pack(fill="x",expand="true",anchor="n") + l1=tkinter.Label(frame,text="Press To Create A new Entry",bg="#330066",fg="#66FFFF",relief="groove",pady=15,font=16,padx=16) + l1.place(relx=0.2,rely=0.2,anchor="n") + b1=tkinter.Button(frame,text="Create Entry Sheet",bg="#9999FF",fg="#660099",relief="solid",command=create,font=11,pady=16,cursor="dot") + b1.place(relx=0.2,rely=0.3,anchor="n") + l1=tkinter.Label(frame,text="Press To Get Entry By Date",bg="#330066",fg="#66FFFF",relief="groove",pady=15,font=16,padx=16) + l1.place(relx=0.4,rely=0.2,anchor="n") + b1=tkinter.Button(frame,text="Get Entry Sheet",bg="#9999FF",fg="#660099",relief="solid",command=get,font=11,pady=16,cursor="dot") + b1.place(relx=0.4,rely=0.3,anchor="n") + l1=tkinter.Label(frame,text="Press To Get Entry By Month",bg="#330066",fg="#66FFFF",relief="groove",pady=15,font=16,padx=7) + l1.place(relx=0.6,rely=0.2,anchor="n") + b1=tkinter.Button(frame,text="Get Monthly Entry Sheet",bg="#9999FF",fg="#660099",relief="solid",command=getm,font=11,pady=16,cursor="dot") + b1.place(relx=0.6,rely=0.3,anchor="n") + l1=tkinter.Label(frame,text="Press To Get Total Expense On Date",bg="#330066",fg="#66FFFF",relief="groove",pady=15,font=16) + l1.place(relx=0.8,rely=0.2,anchor="n") + b1=tkinter.Button(frame,text="Get Total Expense On Date",bg="#9999FF",fg="#660099",relief="solid",command=Sum,font=11,pady=16,cursor="dot") + b1.place(relx=0.8,rely=0.3,anchor="n") + l1=tkinter.Label(frame,text="Press To Get Total Expense In A Month",bg="#330066",fg="#66FFFF",relief="groove",pady=15,font=16) + l1.place(relx=0.3,rely=0.5,anchor="n") + b1=tkinter.Button(frame,text="Get Total Expense",bg="#9999FF",fg="#660099",relief="solid",command=Summ,font=11,pady=16,cursor="dot") + b1.place(relx=0.3,rely=0.6,anchor="n") + l1=tkinter.Label(frame,text="Press To Add To Existing Entry",bg="#330066",fg="#66FFFF",relief="groove",pady=15,font=16) + l1.place(relx=0.51,rely=0.5,anchor="n") + b1=tkinter.Button(frame,text="Add To Entry",bg="#9999FF",fg="#660099",relief="solid",command=add,font=11,pady=16,cursor="dot") + b1.place(relx=0.51,rely=0.6,anchor="n") + l1=tkinter.Label(frame,text="Press To Delete Existing Entry",bg="#330066",fg="#66FFFF",relief="groove",pady=15,font=16) + l1.place(relx=0.7,rely=0.5,anchor="n") + b1=tkinter.Button(frame,text="Delete Entry",bg="#9999FF",fg="#660099",relief="solid",command=delete,font=11,pady=16,cursor="dot") + b1.place(relx=0.7,rely=0.6,anchor="n") + l1=tkinter.Label(frame,text="\u00a9"+" copyright 2016\t\t\t\t\t\t\t\t\t\t\t\t"+"Developed By: Akshit Grover",bg="#330033",fg="#FFFFFF",relief="groove",pady=30,font=16) + l1.pack(fill="x",expand="true",anchor="s") + root.mainloop() +start() diff --git a/bin/facebook-auto-post.py b/bin/facebook-auto-post.py index 8f02a23..39656f7 100644 --- a/bin/facebook-auto-post.py +++ b/bin/facebook-auto-post.py @@ -1,41 +1,41 @@ -from selenium import webdriver -from selenium.webdriver.common.keys import Keys -from time import sleep -from selenium.common.exceptions import TimeoutException -from selenium.webdriver.support.ui import WebDriverWait -from selenium.webdriver.support.ui import Select -from selenium.webdriver.common.by import By -from selenium.webdriver.support import expected_conditions -from selenium.common.exceptions import NoSuchElementException -import time -import getpass - -driver = webdriver.Firefox() -driver.get('https://www.facebook.com/') -print("facebook opened...") -time.sleep(2) -Email = raw_input("Enter your Email ID:") -email = driver.find_element_by_xpath("//input[@id='email' or @name='email']") -email.send_keys(Email) -print("Email Id entered...") -password1=getpass.getpass("Enter your Facebook password: ") -password = driver.find_element_by_xpath("//input[@id='pass']") -password.send_keys(password1) -print("Password entered...") -button = driver.find_element_by_xpath("//input[@id='u_0_r']") -button.click() -print("signed in") -time.sleep(7) -inputbox = driver.find_element_by_css_selector("span._5qtp") -inputbox.click() -time.sleep(3) -Text = raw_input("\tWhats on your mind? Enter here: \n") -text = driver.find_element_by_css_selector("#composer_text_input_box") -text.click() -text.send_keys(Text) -postbutton = driver.find_element_by_xpath("//*[text()='Post']") -postbutton.click() -time.sleep(10) -driver.close() - -#Thank You Stackoverflow and Jio for help +from selenium import webdriver +from selenium.webdriver.common.keys import Keys +from time import sleep +from selenium.common.exceptions import TimeoutException +from selenium.webdriver.support.ui import WebDriverWait +from selenium.webdriver.support.ui import Select +from selenium.webdriver.common.by import By +from selenium.webdriver.support import expected_conditions +from selenium.common.exceptions import NoSuchElementException +import time +import getpass + +driver = webdriver.Firefox() +driver.get('https://www.facebook.com/') +print("facebook opened...") +time.sleep(2) +Email = raw_input("Enter your Email ID:") +email = driver.find_element_by_xpath("//input[@id='email' or @name='email']") +email.send_keys(Email) +print("Email Id entered...") +password1=getpass.getpass("Enter your Facebook password: ") +password = driver.find_element_by_xpath("//input[@id='pass']") +password.send_keys(password1) +print("Password entered...") +button = driver.find_element_by_xpath("//input[@id='u_0_r']") +button.click() +print("signed in") +time.sleep(7) +inputbox = driver.find_element_by_css_selector("span._5qtp") +inputbox.click() +time.sleep(3) +Text = raw_input("\tWhats on your mind? Enter here: \n") +text = driver.find_element_by_css_selector("#composer_text_input_box") +text.click() +text.send_keys(Text) +postbutton = driver.find_element_by_xpath("//*[text()='Post']") +postbutton.click() +time.sleep(10) +driver.close() + +#Thank You Stackoverflow and Jio for help diff --git a/bin/facebook-auto-post.requirements.txt b/bin/facebook-auto-post.requirements.txt index 3e45060..fa9d52e 100644 --- a/bin/facebook-auto-post.requirements.txt +++ b/bin/facebook-auto-post.requirements.txt @@ -1 +1 @@ -selenium==3.4.3 +selenium==3.4.3 diff --git a/bin/fetch_html.py b/bin/fetch_html.py deleted file mode 100644 index 5131a2d..0000000 --- a/bin/fetch_html.py +++ /dev/null @@ -1,15 +0,0 @@ -import urllib.request -import sys -from lxml import html - -if len(sys.argv) < 2: - print('Usage example: python fetch_html.py https://github.com') - sys.exit(1) - -url = sys.argv[1] -response = urllib.request.urlopen(url) -html_text = response.read().decode('UTF-8') -text = html.fromstring(html_text).text_content() - -print(text) - diff --git a/bin/ftp_download_file.py b/bin/ftp_download_file.py deleted file mode 100644 index 8dbdee4..0000000 --- a/bin/ftp_download_file.py +++ /dev/null @@ -1,49 +0,0 @@ -import argparse -import os -from ftplib import FTP - -def parse_args(): - ''' parse and check command line arguments ''' - ap = argparse.ArgumentParser(description="FTP Utility") - ap.add_argument('-hh', dest='host', help="Host name") - ap.add_argument('-u', dest='username', help="user name") - ap.add_argument('-p', dest='password', help="user password") - ap.add_argument('-rd', dest='remote_dir', help="Path to remote directory") - ap.add_argument('-ld', dest='local_dir', help="Path to local directory") - ap.add_argument(dest='files', help="File names", nargs='+') - return ap.parse_args() - -def is_empty(file): - file_size = os.stat(file).st_size - if file_size == 0: - print('The file {} is empty'.format(file)) - return True - return False - - -args=parse_args() - -host = args.host -username = args.username -password = args.password -remote_dir = args.remote_dir -local_dir = args.local_dir -files = args.files - -ftp = FTP(host) -ftp.login(username, password) -ftp.cwd(remote_dir) - -for file in files: - try: - local_filename = os.path.join(local_dir, file) - print('Getting filename: ' + file) - ftp.retrbinary('RETR %s' % file, open(local_filename, 'wb').write) - print('Saving at %s' % local_filename) - except Exception as err: - print(err) - if (is_empty(local_filename)): - os.remove(local_filename) - continue - -ftp.quit() diff --git a/bin/getExternalIp.py b/bin/getExternalIp.py deleted file mode 100644 index 9aaba61..0000000 --- a/bin/getExternalIp.py +++ /dev/null @@ -1,11 +0,0 @@ -import requests -import re - -try: - res = requests.get("http://whatismyip.org") - myIp = re.compile('(\d{1,3}\.){3}\d{1,3}').search(res.text).group() - if myIp != "": - print(myIp) -except: - print('N/A') - pass diff --git a/bin/image_encoder.py b/bin/image_encoder.py index 552372c..a03ec5f 100644 --- a/bin/image_encoder.py +++ b/bin/image_encoder.py @@ -1,25 +1,25 @@ -import base64 -import json -import time - -def b64_encode(source_filepath): - with open(source_filepath, 'rb') as f: - data = f.read() - dest = open('ImageData/encodeData.json','r') - flag = json.loads(dest.read()) - key = (str(int(time.time()))).decode('utf-8') - d = {"data":base64.b64encode(data).decode('utf-8'),"ext":source_filepath[source_filepath.index('.'):]} - flag[key] = d - dest.close() - dest = open('ImageData/encodeData.json','w') - json.dump(flag,dest) - return key - -def b64_decode(key,dest_path): - source = open('ImageData/encodeData.json','r') - flag = json.loads(source.read()) - name = key+str(flag[key]["ext"]) - dest = open(dest_path+name,'wb') - dest.write(base64.b64decode((flag[key]["data"]).encode('utf-8'))) - dest.close() - return dest_path+name +import base64 +import json +import time + +def b64_encode(source_filepath): + with open(source_filepath, 'rb') as f: + data = f.read() + dest = open('ImageData/encodeData.json','r') + flag = json.loads(dest.read()) + key = (str(int(time.time()))).decode('utf-8') + d = {"data":base64.b64encode(data).decode('utf-8'),"ext":source_filepath[source_filepath.index('.'):]} + flag[key] = d + dest.close() + dest = open('ImageData/encodeData.json','w') + json.dump(flag,dest) + return key + +def b64_decode(key,dest_path): + source = open('ImageData/encodeData.json','r') + flag = json.loads(source.read()) + name = key+str(flag[key]["ext"]) + dest = open(dest_path+name,'wb') + dest.write(base64.b64decode((flag[key]["data"]).encode('utf-8'))) + dest.close() + return dest_path+name diff --git a/bin/integrate-graph.py b/bin/integrate-graph.py index 218ed66..17bd179 100644 --- a/bin/integrate-graph.py +++ b/bin/integrate-graph.py @@ -1,82 +1,82 @@ -# -*- coding: utf-8 -*- - -import numpy as np -import matplotlib.pyplot as plt -from matplotlib import animation - -def f(order, coefficients, x): - s = sum([coefficients[i]*(x**(order-i)) for i in range(order+1)]) - return s - -class Integrate(object): - def __init__(self): - self.N = None - self.I = None - - def graph(self, order, coefficients, low, high, interval, ans): - fig=plt.figure() - plt.axes(xlim=(low-5, high+5)) - lines = [plt.plot([], [], color='r')[0] for i in range(30)] - plt.title('Trapezoid Method\nRequired area is %0.2f units' %(ans)) - plt.xlabel('X-axis') - plt.ylabel('Y-axis') - plt.axhline(y=0, color='k') - plt.axvline(x=0, color='k') - x=np.linspace(low, high, 500) - y=f(order, coefficients, x) - s='' - for i in range(order+1): - if coefficients[i]>=0: - s=s+(' +'+str(coefficients[i])+'x^'+str(order-i)) - else: - s=s+(' '+str(coefficients[i])+'x^'+str(order-i)) - s=s+' = 0' - plt.plot(x, y, 'darkslateblue', label=s) - - def init(): - for line in lines: - line.set_data([], []) - return lines - - def animate(i): - if i<2: - for j in range(30): - lines[j].set_data([], []) - else: - x = np.linspace(low, high, i) - y = f(order, coefficients, x) - lines[29].set_data(x, y) - for j in range(i): - lines[j].set_data([x[j], x[j]], [y[j], 0]) - for j in range(i, 29): - lines[j].set_data([], []) - return lines - - animation.FuncAnimation(fig, animate, init_func=init, frames=30, interval=500, blit=True) - plt.legend(loc='upper right', numpoints=1) - plt.show() - - def Trapezoid(self, order, coefficients, low, high, interval): - self.N = (high - low)/interval - self.I = sum([2*f(order, coefficients, low + (i*interval)) for i in range(1, int(self.N))]) - self.I += (f(order, coefficients, low) + f(order, coefficients, high)) - ans = (self.I*(high - low))/(2*self.N) - self.graph(order, coefficients, low, high, interval, ans) - return ans - - def Simpson(self, order, coefficients, low, high, interval): - self.N = (high - low)/(2*interval) - self.I = sum([4*f(order, coefficients, low + (i*interval)) if i%2==1 else 2*f(order, coefficients, low + (i*interval)) for i in range(1, int(2*self.N))]) - self.I += (f(order, coefficients, low) + f(order, coefficients, high)) - return (self.I*(high - low))/(6*self.N) - - def solve(self, order, coefficients, low, high, method, interval = 1e-3): - if method == 'trapezoid': - return self.Trapezoid(order, coefficients, low, high, interval) - elif method == 'simpson': - return self.Simpson(order, coefficients, low, high, interval) - -igr = Integrate() -for method in ['trapezoid'] : - solution = igr.solve(3, [7, 3, -6, 10], -50, 65, method=method) - print (solution) +# -*- coding: utf-8 -*- + +import numpy as np +import matplotlib.pyplot as plt +from matplotlib import animation + +def f(order, coefficients, x): + s = sum([coefficients[i]*(x**(order-i)) for i in range(order+1)]) + return s + +class Integrate(object): + def __init__(self): + self.N = None + self.I = None + + def graph(self, order, coefficients, low, high, interval, ans): + fig=plt.figure() + plt.axes(xlim=(low-5, high+5)) + lines = [plt.plot([], [], color='r')[0] for i in range(30)] + plt.title('Trapezoid Method\nRequired area is %0.2f units' %(ans)) + plt.xlabel('X-axis') + plt.ylabel('Y-axis') + plt.axhline(y=0, color='k') + plt.axvline(x=0, color='k') + x=np.linspace(low, high, 500) + y=f(order, coefficients, x) + s='' + for i in range(order+1): + if coefficients[i]>=0: + s=s+(' +'+str(coefficients[i])+'x^'+str(order-i)) + else: + s=s+(' '+str(coefficients[i])+'x^'+str(order-i)) + s=s+' = 0' + plt.plot(x, y, 'darkslateblue', label=s) + + def init(): + for line in lines: + line.set_data([], []) + return lines + + def animate(i): + if i<2: + for j in range(30): + lines[j].set_data([], []) + else: + x = np.linspace(low, high, i) + y = f(order, coefficients, x) + lines[29].set_data(x, y) + for j in range(i): + lines[j].set_data([x[j], x[j]], [y[j], 0]) + for j in range(i, 29): + lines[j].set_data([], []) + return lines + + animation.FuncAnimation(fig, animate, init_func=init, frames=30, interval=500, blit=True) + plt.legend(loc='upper right', numpoints=1) + plt.show() + + def Trapezoid(self, order, coefficients, low, high, interval): + self.N = (high - low)/interval + self.I = sum([2*f(order, coefficients, low + (i*interval)) for i in range(1, int(self.N))]) + self.I += (f(order, coefficients, low) + f(order, coefficients, high)) + ans = (self.I*(high - low))/(2*self.N) + self.graph(order, coefficients, low, high, interval, ans) + return ans + + def Simpson(self, order, coefficients, low, high, interval): + self.N = (high - low)/(2*interval) + self.I = sum([4*f(order, coefficients, low + (i*interval)) if i%2==1 else 2*f(order, coefficients, low + (i*interval)) for i in range(1, int(2*self.N))]) + self.I += (f(order, coefficients, low) + f(order, coefficients, high)) + return (self.I*(high - low))/(6*self.N) + + def solve(self, order, coefficients, low, high, method, interval = 1e-3): + if method == 'trapezoid': + return self.Trapezoid(order, coefficients, low, high, interval) + elif method == 'simpson': + return self.Simpson(order, coefficients, low, high, interval) + +igr = Integrate() +for method in ['trapezoid'] : + solution = igr.solve(3, [7, 3, -6, 10], -50, 65, method=method) + print (solution) diff --git a/bin/locate-me.py b/bin/locate-me.py index bdf282a..d9c6a33 100644 --- a/bin/locate-me.py +++ b/bin/locate-me.py @@ -1,30 +1,30 @@ -import urllib2 -from urllib2 import urlopen -import json -import re -import requests -# Get Public IP - - -def getPublicIP(): - data = requests.get('http://checkip.dyndns.com/').content - return re.compile(r'Address: (\d+.\d+.\d+.\d+)').search(data).group(1) - -IP = str(getPublicIP()) - -# Get Location -url = 'http://ipinfo.io/' + IP + '/json' -response = urlopen(url) -data = json.load(response) -city = data['city'] -region = data['region'] -country = data['country'] -location = data['loc'] -org = data['org'] - -# Print Extracted Details -print "Your City : " + city -print "Your Region : " + region -print "Your Country : " + country -print "Your Location : " + location -print "Your ISP : " + org +import urllib2 +from urllib2 import urlopen +import json +import re +import requests +# Get Public IP + + +def getPublicIP(): + data = requests.get('http://checkip.dyndns.com/').content + return re.compile(r'Address: (\d+.\d+.\d+.\d+)').search(data).group(1) + +IP = str(getPublicIP()) + +# Get Location +url = 'http://ipinfo.io/' + IP + '/json' +response = urlopen(url) +data = json.load(response) +city = data['city'] +region = data['region'] +country = data['country'] +location = data['loc'] +org = data['org'] + +# Print Extracted Details +print "Your City : " + city +print "Your Region : " + region +print "Your Country : " + country +print "Your Location : " + location +print "Your ISP : " + org diff --git a/bin/memedensity.py b/bin/memedensity.py index 1ad7a15..2af6c20 100644 --- a/bin/memedensity.py +++ b/bin/memedensity.py @@ -1,134 +1,134 @@ - -ASCII = """ - __ __ _____ _ _ - | \/ | | __ \ (_) | - | \ / | ___ _ __ ___ ___| | | | ___ _ __ ___ _| |_ _ _ - | |\/| |/ _ \ '_ ` _ \ / _ \ | | |/ _ \ '_ \/ __| | __| | | | - | | | | __/ | | | | | __/ |__| | __/ | | \__ \ | |_| |_| | - |_| |_|\___|_| |_| |_|\___|_____/ \___|_| |_|___/_|\__|\__, | - __/ | - |___/ -""" - -DESC = """ -- Tells you approximately how many memes are currently in your facebook -newsfeed. Provides % memes in newsfeed. -- Provides memes in newsfeed urls -""" - -import os -import argparse -import requests -import six -from selenium import webdriver -from selenium.webdriver.common.keys import Keys -from time import sleep -from getpass import getpass -from argparse import RawTextHelpFormatter - -if six.PY2: - input = raw_input -else: - pass - -def _login_fb(): - - email = input('> Email or Phone: ') - password = getpass('> Password: ') - - return email,password - -def _xkcd(): - - r = requests.get('http://xkcd.com/info.0.json').json() - return r['img'] - -def _execute_script(email, password, count): - - - print("\nLoading..\nCheck out today's xkcd comic till then : %s \n\n" %(_xkcd())) - - driver = webdriver.PhantomJS() - driver.get('https://www.facebook.com') - - email_ID = driver.find_element_by_id('email') - pass_ID = driver.find_element_by_id('pass') - - - email_ID.send_keys(email) - pass_ID.send_keys(password) - pass_ID.send_keys(Keys.ENTER) - sleep(5) - - for i in range(0,count): - driver.execute_script("window.scrollBy(0, document.body.scrollHeight);") - sleep(1) - - sleep(5) - - driver_tags = driver.execute_script('return document.getElementsByClassName("scaledImageFitWidth img")') - - driver_img_list = { - 'src' : [x.get_attribute('src') for x in driver_tags], - 'alt' : [x.get_attribute('alt') for x in driver_tags], - } - - driver.quit() - - return driver_img_list - - -def _check_memes(driver_img_list, verbose): - - alt_list = driver_img_list['alt'] - if len(alt_list) == 0: - print("Error getting newsfeed. Possibly username or password was incorrect") - return - - output = "\n{} memes in your newsfeed.\n{} total images in your newsfeed.\n{}% memes in newsfeed.\n" - count = 0 - - for key,alt in enumerate(alt_list): - if "text" in alt or "meme" in alt : - count += 1 - if verbose: - print(driver_img_list['src'][key]) - - print(output.format(count,len(alt_list),round(count*100/len(alt_list),2))) - - -def main(): - - print('\n') - - parser = argparse.ArgumentParser( - description='\n{}\n{}\n'.format(ASCII,DESC), formatter_class=RawTextHelpFormatter) - parser.add_argument('-C', '--count', action='store', dest='count', - help='How many times to scroll newsfeed (default = 5)') - parser.add_argument('-L', '--login', action='store_true', - help='Input login credentials') - parser.add_argument('-v', '--verbose', action='store_true', - help='Shows meme urls') - args = parser.parse_args() - - count = int(args.count or '5') - login_bool = args.login - verbose_bool = args.verbose - - if login_bool: - email,password = _login_fb() - else: - try: - email=os.environ['fb_email'] - password=os.environ['fb_pass'] - except KeyError: - print("Couldn't find fb_email and fb_pass in environment variables") - email,password = _login_fb() - - driver_img_list = _execute_script(email, password, count) - _check_memes(driver_img_list, verbose_bool) - - -if __name__ == '__main__': - - main() + +ASCII = """ + __ __ _____ _ _ + | \/ | | __ \ (_) | + | \ / | ___ _ __ ___ ___| | | | ___ _ __ ___ _| |_ _ _ + | |\/| |/ _ \ '_ ` _ \ / _ \ | | |/ _ \ '_ \/ __| | __| | | | + | | | | __/ | | | | | __/ |__| | __/ | | \__ \ | |_| |_| | + |_| |_|\___|_| |_| |_|\___|_____/ \___|_| |_|___/_|\__|\__, | + __/ | + |___/ +""" + +DESC = """ +- Tells you approximately how many memes are currently in your facebook +newsfeed. Provides % memes in newsfeed. +- Provides memes in newsfeed urls +""" + +import os +import argparse +import requests +import six +from selenium import webdriver +from selenium.webdriver.common.keys import Keys +from time import sleep +from getpass import getpass +from argparse import RawTextHelpFormatter + +if six.PY2: + input = raw_input +else: + pass + +def _login_fb(): + + email = input('> Email or Phone: ') + password = getpass('> Password: ') + + return email,password + +def _xkcd(): + + r = requests.get('http://xkcd.com/info.0.json').json() + return r['img'] + +def _execute_script(email, password, count): + + + print("\nLoading..\nCheck out today's xkcd comic till then : %s \n\n" %(_xkcd())) + + driver = webdriver.PhantomJS() + driver.get('https://www.facebook.com') + + email_ID = driver.find_element_by_id('email') + pass_ID = driver.find_element_by_id('pass') + + + email_ID.send_keys(email) + pass_ID.send_keys(password) + pass_ID.send_keys(Keys.ENTER) + sleep(5) + + for i in range(0,count): + driver.execute_script("window.scrollBy(0, document.body.scrollHeight);") + sleep(1) + + sleep(5) + + driver_tags = driver.execute_script('return document.getElementsByClassName("scaledImageFitWidth img")') + + driver_img_list = { + 'src' : [x.get_attribute('src') for x in driver_tags], + 'alt' : [x.get_attribute('alt') for x in driver_tags], + } + + driver.quit() + + return driver_img_list + + +def _check_memes(driver_img_list, verbose): + + alt_list = driver_img_list['alt'] + if len(alt_list) == 0: + print("Error getting newsfeed. Possibly username or password was incorrect") + return + + output = "\n{} memes in your newsfeed.\n{} total images in your newsfeed.\n{}% memes in newsfeed.\n" + count = 0 + + for key,alt in enumerate(alt_list): + if "text" in alt or "meme" in alt : + count += 1 + if verbose: + print(driver_img_list['src'][key]) + + print(output.format(count,len(alt_list),round(count*100/len(alt_list),2))) + + +def main(): + + print('\n') + + parser = argparse.ArgumentParser( + description='\n{}\n{}\n'.format(ASCII,DESC), formatter_class=RawTextHelpFormatter) + parser.add_argument('-C', '--count', action='store', dest='count', + help='How many times to scroll newsfeed (default = 5)') + parser.add_argument('-L', '--login', action='store_true', + help='Input login credentials') + parser.add_argument('-v', '--verbose', action='store_true', + help='Shows meme urls') + args = parser.parse_args() + + count = int(args.count or '5') + login_bool = args.login + verbose_bool = args.verbose + + if login_bool: + email,password = _login_fb() + else: + try: + email=os.environ['fb_email'] + password=os.environ['fb_pass'] + except KeyError: + print("Couldn't find fb_email and fb_pass in environment variables") + email,password = _login_fb() + + driver_img_list = _execute_script(email, password, count) + _check_memes(driver_img_list, verbose_bool) + + +if __name__ == '__main__': + + main() diff --git a/bin/mi-community-bot.py b/bin/mi-community-bot.py index d509f17..46196c9 100644 --- a/bin/mi-community-bot.py +++ b/bin/mi-community-bot.py @@ -1,49 +1,49 @@ -from selenium import webdriver -from selenium.webdriver.common.keys import Keys -from time import sleep -from selenium.common.exceptions import TimeoutException -from selenium.webdriver.support.ui import WebDriverWait -from selenium.webdriver.support.ui import Select -from selenium.webdriver.common.by import By -from selenium.webdriver.support import expected_conditions -from selenium.common.exceptions import NoSuchElementException -import time -import getpass - -driver = webdriver.Firefox() -driver.get('http://c.mi.com/') -print("Opened MI community...") -signin = driver.find_element_by_css_selector(".sign-action > a:nth-child(1)") -signin.click() -time.sleep(10) -email = driver.find_element_by_xpath("//input[@id='username' or @name='email']") -email.send_keys('Email id') -print("Email Id entered...") -password = driver.find_element_by_xpath("//input[@id='pwd']") -password_input = getpass.getpass("Enter your password:") -password.send_keys(password_input) -print("Password entered...") -button = driver.find_element_by_xpath("//input[@id='login-button']") -button.click() -print('login successfully') -time.sleep(7) -threadbutton = driver.find_element_by_css_selector(".thread-box > h4:nth-child(1) > a:nth-child(2)") -threadbutton.click() -print("clicked on new thread button") -time.sleep(2) -selectforum = Select(driver.find_element_by_name('fid')) - -selectforum.select_by_value('41') -print("Forum selected") -time.sleep(8) -selecttag = Select(driver.find_element_by_name('typeid')) -selecttag.select_by_value('62') -print("Catagory selected") - -title = driver.find_element_by_css_selector("#subject") -title.send_keys('Bot Typing Here....') -print('Title Entered waiting for your contant' ) -time.sleep(10) -submit = driver.find_element_by_css_selector(".btn-orange") -submit.click() -print('submitted') +from selenium import webdriver +from selenium.webdriver.common.keys import Keys +from time import sleep +from selenium.common.exceptions import TimeoutException +from selenium.webdriver.support.ui import WebDriverWait +from selenium.webdriver.support.ui import Select +from selenium.webdriver.common.by import By +from selenium.webdriver.support import expected_conditions +from selenium.common.exceptions import NoSuchElementException +import time +import getpass + +driver = webdriver.Firefox() +driver.get('http://c.mi.com/') +print("Opened MI community...") +signin = driver.find_element_by_css_selector(".sign-action > a:nth-child(1)") +signin.click() +time.sleep(10) +email = driver.find_element_by_xpath("//input[@id='username' or @name='email']") +email.send_keys('Email id') +print("Email Id entered...") +password = driver.find_element_by_xpath("//input[@id='pwd']") +password_input = getpass.getpass("Enter your password:") +password.send_keys(password_input) +print("Password entered...") +button = driver.find_element_by_xpath("//input[@id='login-button']") +button.click() +print('login successfully') +time.sleep(7) +threadbutton = driver.find_element_by_css_selector(".thread-box > h4:nth-child(1) > a:nth-child(2)") +threadbutton.click() +print("clicked on new thread button") +time.sleep(2) +selectforum = Select(driver.find_element_by_name('fid')) + +selectforum.select_by_value('41') +print("Forum selected") +time.sleep(8) +selecttag = Select(driver.find_element_by_name('typeid')) +selecttag.select_by_value('62') +print("Catagory selected") + +title = driver.find_element_by_css_selector("#subject") +title.send_keys('Bot Typing Here....') +print('Title Entered waiting for your contant' ) +time.sleep(10) +submit = driver.find_element_by_css_selector(".btn-orange") +submit.click() +print('submitted') diff --git a/bin/mi-community-bot.requirements.txt b/bin/mi-community-bot.requirements.txt index 3e45060..fa9d52e 100644 --- a/bin/mi-community-bot.requirements.txt +++ b/bin/mi-community-bot.requirements.txt @@ -1 +1 @@ -selenium==3.4.3 +selenium==3.4.3 diff --git a/bin/missionaries_and_cannibals_problem.py b/bin/missionaries_and_cannibals_problem.py index 674622c..bd51b91 100644 --- a/bin/missionaries_and_cannibals_problem.py +++ b/bin/missionaries_and_cannibals_problem.py @@ -1,103 +1,103 @@ -shore = {1:['m1','m2','m3','c1','c2','c3'],2:[]} -boat = {1:True,2:False} -boat_cap = 0 -boat_hold = [] -choice = 'y' -count = 0 -glob = 1 -def pick(): - print("Pick a person to put on boat/or press enter") - return input() -def check(person,flag,avail_p): - if(person in shore[flag] or person == "" or person in boat_hold): - return True - else: - return False -def check_conditions(shore,flag,cflag,boatf): - num_m = 0 - num_c = 0 - true = 0 - for i in shore[flag]: - if(i[0] == 'm'): - num_m = num_m + 1 - else: - num_c = num_c + 1 - if(num_m < num_c and num_m > 0): - return False - else: - true = 1 - num_m = 0 - num_c = 0 - for i in shore[cflag]+boatf: - if(i[0] == 'm'): - num_m = num_m + 1 - else: - num_c = num_c + 1 - if(num_m < num_c and num_m > 0): - return False - elif(true == 1): - return true -while(choice == 'Y' or choice == 'y'): - count = 0 - win = 0 - while(count <= 25): - def again(shore,boat_hold): - print("People On Shore "+str(flag)+ " are: ") - print() - print(shore[flag] + boat_hold) - shore[flag] = shore[flag] + boat_hold - avail_p = shore[flag] + boat_hold - boat_hold =[] - for i in range(2): - print("For Person " + str(i+1)) - print() - person = pick() - if(i == 0 and person == ""): - while(person == ""): - print("Boat Cannot Be Empty") - person = pick() - if((not person == "") and person in avail_p): - boat_hold.append(person) - del avail_p[avail_p.index(person)] - del shore[flag][shore[flag].index(person)] - elif(person not in avail_p and not person == ""): - print("Invalid Choice") - person = pick() - while(not check(person,flag,avail_p)): - person = pick() - if(person == ""): - break - glob = 0 - return boat_hold - if(boat[1]): - flag = 1 - cflag = 2 - else: - flag = 2 - cflag = 1 - if(glob == 1): - boat_hold = again(shore,boat_hold) - while(not check_conditions(shore,flag,cflag,boat_hold)): - print() - print("** Invalid Move,Try Again **") - print() - boat_hold = again(shore,boat_hold) - print("Sending Boat") - print() - avail_p = shore[cflag] + boat_hold - boat[cflag] = True - boat[flag] = False - glob = 1 - if(len(shore[1]) == 0): - win = 1 - print("Congratulation, You Solved The Problem.") - break - count = count + 1 - if(win == 0): - print() - print("*** Sorry, Number of moves exceeeded ***") - print() - print("Do You Want To Replay? Y/N",end=" ") - choice = input() - - +shore = {1:['m1','m2','m3','c1','c2','c3'],2:[]} +boat = {1:True,2:False} +boat_cap = 0 +boat_hold = [] +choice = 'y' +count = 0 +glob = 1 +def pick(): + print("Pick a person to put on boat/or press enter") + return input() +def check(person,flag,avail_p): + if(person in shore[flag] or person == "" or person in boat_hold): + return True + else: + return False +def check_conditions(shore,flag,cflag,boatf): + num_m = 0 + num_c = 0 + true = 0 + for i in shore[flag]: + if(i[0] == 'm'): + num_m = num_m + 1 + else: + num_c = num_c + 1 + if(num_m < num_c and num_m > 0): + return False + else: + true = 1 + num_m = 0 + num_c = 0 + for i in shore[cflag]+boatf: + if(i[0] == 'm'): + num_m = num_m + 1 + else: + num_c = num_c + 1 + if(num_m < num_c and num_m > 0): + return False + elif(true == 1): + return true +while(choice == 'Y' or choice == 'y'): + count = 0 + win = 0 + while(count <= 25): + def again(shore,boat_hold): + print("People On Shore "+str(flag)+ " are: ") + print() + print(shore[flag] + boat_hold) + shore[flag] = shore[flag] + boat_hold + avail_p = shore[flag] + boat_hold + boat_hold =[] + for i in range(2): + print("For Person " + str(i+1)) + print() + person = pick() + if(i == 0 and person == ""): + while(person == ""): + print("Boat Cannot Be Empty") + person = pick() + if((not person == "") and person in avail_p): + boat_hold.append(person) + del avail_p[avail_p.index(person)] + del shore[flag][shore[flag].index(person)] + elif(person not in avail_p and not person == ""): + print("Invalid Choice") + person = pick() + while(not check(person,flag,avail_p)): + person = pick() + if(person == ""): + break + glob = 0 + return boat_hold + if(boat[1]): + flag = 1 + cflag = 2 + else: + flag = 2 + cflag = 1 + if(glob == 1): + boat_hold = again(shore,boat_hold) + while(not check_conditions(shore,flag,cflag,boat_hold)): + print() + print("** Invalid Move,Try Again **") + print() + boat_hold = again(shore,boat_hold) + print("Sending Boat") + print() + avail_p = shore[cflag] + boat_hold + boat[cflag] = True + boat[flag] = False + glob = 1 + if(len(shore[1]) == 0): + win = 1 + print("Congratulation, You Solved The Problem.") + break + count = count + 1 + if(win == 0): + print() + print("*** Sorry, Number of moves exceeeded ***") + print() + print("Do You Want To Replay? Y/N",end=" ") + choice = input() + + diff --git a/bin/password-strength-checker.py b/bin/password-strength-checker.py index e12c7ea..98a4d85 100644 --- a/bin/password-strength-checker.py +++ b/bin/password-strength-checker.py @@ -1,19 +1,19 @@ -def checkx(): - email = raw_input('Enter the email:') - if '@' in email and '.' in email: - pass1() - else : - print ('Check you email') - checkx() - -def pass1(): - password = raw_input('Enter the password ') - special = '!@#$%^&*()?' - if len(password) >= 8 and not password.islower() and not password.isupper() and not password.isalpha() and not password.isdigit() and any((c in special) for c in password): - print ('Strong Password') - return 1 - else: - print ('Weak Password') - pass1() - -checkx() +def checkx(): + email = raw_input('Enter the email:') + if '@' in email and '.' in email: + pass1() + else : + print ('Check you email') + checkx() + +def pass1(): + password = raw_input('Enter the password ') + special = '!@#$%^&*()?' + if len(password) >= 8 and not password.islower() and not password.isupper() and not password.isalpha() and not password.isdigit() and any((c in special) for c in password): + print ('Strong Password') + return 1 + else: + print ('Weak Password') + pass1() + +checkx() diff --git a/bin/pi.py b/bin/pi.py index 2b8672b..4500089 100644 --- a/bin/pi.py +++ b/bin/pi.py @@ -1,15 +1,15 @@ -import numpy as np -from numba import jit - -@jit -def aprox_pi(N): - points = 2 * np.random.rand(N, 2) - 1 - M = 0 - - for k in range(N): - if points[k,0]**2 + points[k,1]**2 < 1.: - M += 1 - - return 4.*M/N - -print(aprox_pi(1e8)) +import numpy as np +from numba import jit + +@jit +def aprox_pi(N): + points = 2 * np.random.rand(N, 2) - 1 + M = 0 + + for k in range(N): + if points[k,0]**2 + points[k,1]**2 < 1.: + M += 1 + + return 4.*M/N + +print(aprox_pi(1e8)) diff --git a/bin/plot_example.py b/bin/plot_example.py index ca59742..4aec0a2 100644 --- a/bin/plot_example.py +++ b/bin/plot_example.py @@ -1,8 +1,8 @@ -import numpy as np -import matplotlib.pyplot as plt - -x = np.linspace(-3, 3, 100) -y = x**2 - -plt.plot(x, y) -plt.show() +import numpy as np +import matplotlib.pyplot as plt + +x = np.linspace(-3, 3, 100) +y = x**2 + +plt.plot(x, y) +plt.show() diff --git a/bin/server_client/client.py b/bin/server_client/client.py index 83ef666..94f2654 100644 --- a/bin/server_client/client.py +++ b/bin/server_client/client.py @@ -1,16 +1,16 @@ -import sys -from socket import socket, AF_INET, SOCK_DGRAM, SOL_SOCKET, SO_REUSEADDR - -SERVER_IP = '127.0.0.1' -PORT_NUMBER = 5000 -SIZE = 1024 -print ("Test client sending packets to IP {0}, via port {1}\n".format(SERVER_IP,PORT_NUMBER)) - -mySocket = socket( SOCK_DGRAM ) -mySocket.connect((SERVER_IP,PORT_NUMBER)) - -while True: - data = mySocket.recv(SIZE) - print(data) -sys.exit() -mySocket.close() +import sys +from socket import socket, AF_INET, SOCK_DGRAM, SOL_SOCKET, SO_REUSEADDR + +SERVER_IP = '127.0.0.1' +PORT_NUMBER = 5000 +SIZE = 1024 +print ("Test client sending packets to IP {0}, via port {1}\n".format(SERVER_IP,PORT_NUMBER)) + +mySocket = socket( SOCK_DGRAM ) +mySocket.connect((SERVER_IP,PORT_NUMBER)) + +while True: + data = mySocket.recv(SIZE) + print(data) +sys.exit() +mySocket.close() diff --git a/bin/server_client/server.py b/bin/server_client/server.py index 0ff2ccc..c02d6c4 100644 --- a/bin/server_client/server.py +++ b/bin/server_client/server.py @@ -1,14 +1,14 @@ -from socket import socket, gethostbyname, AF_INET, SOCK_DGRAM, SOL_SOCKET, SO_REUSEADDR -import sys -PORT_NUMBER = 5000 -SIZE = 1024 - -hostName = gethostbyname( 'localhost' ) - -mySocket = socket( SOCK_DGRAM ) -mySocket.bind((hostName, PORT_NUMBER)) -mySocket.listen(1) -while True: - client, addr = mySocket.accept() - data = client.send("Connection Established: ") -sys.exit() +from socket import socket, gethostbyname, AF_INET, SOCK_DGRAM, SOL_SOCKET, SO_REUSEADDR +import sys +PORT_NUMBER = 5000 +SIZE = 1024 + +hostName = gethostbyname( 'localhost' ) + +mySocket = socket( SOCK_DGRAM ) +mySocket.bind((hostName, PORT_NUMBER)) +mySocket.listen(1) +while True: + client, addr = mySocket.accept() + data = client.send("Connection Established: ") +sys.exit() diff --git a/bin/shortener.py b/bin/shortener.py deleted file mode 100644 index ad55e51..0000000 --- a/bin/shortener.py +++ /dev/null @@ -1,24 +0,0 @@ -from __future__ import with_statement -import contextlib -try: - from urllib.parse import urlencode -except ImportError: - from urllib import urlencode -try: - from urllib.request import urlopen -except ImportError: - from urllib2 import urlopen -import sys - -def make_tiny(url): - request_url = ('http://tinyurl.com/api-create.php?' + - urlencode({'url':url})) - with contextlib.closing(urlopen(request_url)) as response: - return response.read().decode('utf-8') - -def main(): - for tinyurl in map(make_tiny, sys.argv[1:]): - print(tinyurl) - -if __name__ == '__main__': - main() diff --git a/bin/tweetload.py b/bin/tweetload.py deleted file mode 100644 index bea1cce..0000000 --- a/bin/tweetload.py +++ /dev/null @@ -1,59 +0,0 @@ -import twitter -import json -import re - -# replace 'default' with twitter user -user = 'default' -# path to json file with your twitter credentials (see https://python-twitter.readthedocs.io/en/latest/) -creds = 'creds.json' -file_name = 'tweets.txt' - - -def init_twitter(): - # load twitter API tokens - with open(creds) as data_file: - data = json.load(data_file) - - api = twitter.Api(consumer_key=data["consumer_key"], - consumer_secret=data["consumer_secret"], - access_token_key=data["access_token_key"], - access_token_secret=data["access_token_secret"]) - - return api - - -def main(): - if user == 'default': - print("Please define the twitter user's screenname to download content from in source code.") - return - - api = init_twitter() - - # get up to 4000 latest tweets - tweets = api.GetUserTimeline(screen_name=user, count=200) - curr_id = tweets[-1].id - for i in range(19): - tweets = tweets + api.GetUserTimeline(screen_name=user, count=200, max_id=curr_id) - curr_id = tweets[-1].id - - print("Tweets: " + str(len(tweets))) - - # write tweets to file - with open(file_name, 'w') as file_o: - for tweet in tweets: - tweet_cont = tweet.text - # strip links - tweet_cont = re.sub(r'http\S+', '', tweet_cont) - # strip mentions - tweet_cont = re.sub(r'@\S+', '', tweet_cont) - # strip hashtags - tweet_cont = re.sub(r'#\S+', '', tweet_cont) - tweet_cont = tweet_cont.replace('RT: ', '') - tweet_cont = tweet_cont.replace('RT', '') - file_o.write(tweet_cont + '\n') - - - - -if __name__ == "__main__": - main() diff --git a/bin/twitter_retweet_bot.py b/bin/twitter_retweet_bot.py deleted file mode 100644 index 9d80be4..0000000 --- a/bin/twitter_retweet_bot.py +++ /dev/null @@ -1,31 +0,0 @@ -import tweepy # This is a Twitter API helper library. -import time - - -# You should get the following keys and authentication codes for your Twitter account -# Visit apps.twitter.com -consumer_key = 'consumer_key' -consumer_secret = 'consumer_secret' -access_token = 'access_token' -access_token_secret = 'access_token_secret' - - -# Twitter requires 0Auth2 authentication. You can readup about this. -auth = tweepy.OAuthHandler(consumer_key, consumer_secret) -auth.set_access_token(access_token, access_token_secret) -api = tweepy.API(auth) - - -def retweet_bot(): - for tweet in tweepy.Cursor(api.search, q='Hashtag to listen for').items(10): - try: - print('Twitter user: ' + '@' + tweet.user.screen_name) - tweet.retweet() - print('\nDone') - time.sleep(5) # You can remove the time module, if you want the program to continuously retweet - except tweepy.error.TweepError: - pass - - -if __name__ == '__main__': - retweet_bot() diff --git a/bin/youtube-bot-linux.py b/bin/youtube-bot-linux.py index ba107d4..969f000 100644 --- a/bin/youtube-bot-linux.py +++ b/bin/youtube-bot-linux.py @@ -1,10 +1,10 @@ -import time,webbrowser,os - -url = str(input("Enter your video url in ->\"url here \"<- : ")) -n = input("Enter refresh rate(seconds) : ") -brow = input("Enter your default browser in ->\"browser here \"<- : ") -while (1): - os.system(" killall -9 " + brow) - time.sleep(int(n)) - webbrowser.open(url) - print('Successfully Viewd') +import time,webbrowser,os + +url = str(input("Enter your video url in ->\"url here \"<- : ")) +n = input("Enter refresh rate(seconds) : ") +brow = input("Enter your default browser in ->\"browser here \"<- : ") +while (1): + os.system(" killall -9 " + brow) + time.sleep(int(n)) + webbrowser.open(url) + print('Successfully Viewd') diff --git a/bin/youtube-bot-windows.py b/bin/youtube-bot-windows.py index a459292..473756f 100644 --- a/bin/youtube-bot-windows.py +++ b/bin/youtube-bot-windows.py @@ -1,10 +1,10 @@ -import time,webbrowser,os - -url = str(input("Enter your video url in ->\"url here \"<- : ")) -n = input("Enter refresh rate(seconds) : ") -brow = input("Enter your default browser in ->\"browser here \"<- : ") -while (1): - os.system("TASKKILL /F /IM " + brow + ".exe") - time.sleep(int(n)) - webbrowser.open(url) - print('Successfully Viewd') +import time,webbrowser,os + +url = str(input("Enter your video url in ->\"url here \"<- : ")) +n = input("Enter refresh rate(seconds) : ") +brow = input("Enter your default browser in ->\"browser here \"<- : ") +while (1): + os.system("TASKKILL /F /IM " + brow + ".exe") + time.sleep(int(n)) + webbrowser.open(url) + print('Successfully Viewd')