Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
.DS_Store
7 changes: 7 additions & 0 deletions 10fastfingershack/README.md
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
#Requires Selenium and Chrome Webdriver
Install selenium and specify location in the Python Script.

This is the official website.
https://10fastfingers.com/typing-test/english

The website serves a test for your typing speed. It can be easily automated because the words are loaded into the website during load and readily available in the source code.
16 changes: 16 additions & 0 deletions 10fastfingershack/hack.py
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
from selenium import webdriver
driver = webdriver.Chrome("/home/suryatej/Documents/chromedriver")
driver.get("https://10fastfingers.com/typing-test/english")
driver.maximize_window()
timer_element = driver.find_element_by_xpath('//*[@id="timer"]')
timer = timer_element.get_attribute("innerHTML")
input_element = driver.find_element_by_xpath('//*[@id="inputfield"]')
for i in range(1,350):
try:
current_word_element = driver.find_element_by_xpath('//*[@id="row1"]/span[' + str(i) +']' )
current_word = current_word_element.get_attribute("innerHTML")
input_element.send_keys(current_word + " ")
#driver.implicitly_wait(10)
except:
break

13 changes: 13 additions & 0 deletions Ascii-art-generator/Ascii-art-generator.py
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
import requests
import numpy as np

max_no_of_fonts = 10
text_to_show = "Enter the text here that you would like to see"
fonts = requests.get("http://artii.herokuapp.com/fonts_list")
font_list = np.array(fonts.content.split("\n"))
chose = np.arange(0,400,1)
np.random.shuffle(chose)
selected = font_list[chose[:max_no_of_fonts]]
for font in selected:
ascif = requests.get("http://artii.herokuapp.com/make?text="+text_to_show+"&font="+font)
print(ascif.content)
48 changes: 48 additions & 0 deletions Daily-Wallpaper/README.md
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
# [Daily-Wallpaper](https://github.com/udit-001/daily-wallpaper)

A python script to update desktop wallpaper on a Windows machine from a tumblr blog. For more info, [click here.](https://github.com/udit-001/daily-wallpaper)

## Inspiration
I was tired of seeing the same boring wallpaper on my desktop everyday. After learning a little bit of Python, I decided to design a script that would update my wallpaper on it's own by fetching an image from a [Tumblr Blog](http://fuckinghomepage.com/).

## Installation
Install the required dependencies/libraries by running :

```bash
$ pip install -r requirements.txt
```

## Usage
This script can be scheduled to run daily by using the Task Scheduler utility present on Windows. You will require a BAT script to run the script from the task.

```bat
@echo off
cd <path to wall.pyw>
pythonw wall.pyw
```

Now copy the above code and paste it into notepad, then modify the `<path to wall.pyw>` according to where you download the files from this repo, and save it as "dailywall.bat"

If you want your script to work silently in the background without having a command prompt window opening up, then you'll also need to create a .VBS script.

```vbs
Set WshShell = CreateObject("WScript.Shell")
WshShell.Run chr(34) & "<path to dailywall.bat>" & Chr(34), 0
Set WshShell = Nothing
```
Copy the above code and paste it into notepad, then modify the `<path to dailywall.bat>` and save it as "dailywall.vbs".
Now add the above script in the Windows Task that you'll schedule to run daily.

## Features
It also displays a notification on your computer when the wallpaper gets updated.

![Notifications Screenshot](https://raw.githubusercontent.com/udit-001/daily-wallpaper/master/img/notification.jpg)

## License

> You can check out the full license [here](https://github.com/udit-001/daily-wallpaper/blob/master/LICENSE)

This project is licensed under the terms of the MIT license.



58 changes: 58 additions & 0 deletions Daily-Wallpaper/wall.pyw
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
#!python2
"""This script can be set to run daily on your computer using utilities like Windows Task Scheduler
on Windows, and it would download a wallpaper
from a blog and set it up as your wallpaper on it's own"""
import urllib
import os
import ctypes
import imghdr
from datetime import datetime
from bs4 import BeautifulSoup
import requests
from win10toast import ToastNotifier

url = 'http://fuckinghomepage.com/rss'
sourceCode = requests.get(url)
plainText = sourceCode.text
soup = BeautifulSoup(plainText, 'lxml')

data = soup.item.description.text
href = data.split('PICTURE OF THE DAY:')[1].split('href=')[1].split('target=')[0]
href = href.replace('\"', ' ').strip()

today = datetime.now()
files = os.listdir(os.getcwd())

dateString = str(today.day)+'-'+str(today.month)+'-'+str(today.year)
prev = str(today.day-1)+'-'+str(today.month)+'-'+str(today.year)

check = 0
for item in files:
if dateString in item:
fileName = item
check = 1
else:
continue

for item in files:
if prev in item:
os.remove(item)
else:
continue

if check == 0:
urllib.urlretrieve(href, dateString)
ext = imghdr.what(dateString)
path = dateString+'.'+ext
os.rename(dateString, path)
abspath = os.path.abspath(path)
ctypes.windll.user32.SystemParametersInfoA(20, 0, abspath, 3)

elif check == 1:
abspath = os.path.abspath(fileName)
ctypes.windll.user32.SystemParametersInfoA(20, 0, abspath, 3)

print "Wallpaper set successfully."
toaster = ToastNotifier()
toaster.show_toast('Wallpaper Set!', 'Wallpaper was successfully downloaded.', \
duration=5, icon_path='wall.ico')
Binary file not shown.
47 changes: 47 additions & 0 deletions HistogramEqualization/HistogramEqualization.py
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
from PIL import Image
import sys

def histogramEqualization(argv):

picSource = Image.open(argv)
picDestination = picSource.copy()

# For the sake of simplicity, the picture gets casted to
# RGB if it isn't yet
if picDestination.mode != 'RGB':
picDestination = picDestination.convert('RGB')

picDestinationArray = picDestination.load()
width, height = picSource.size

# Determine the maximum and minimum pixel brightness
histMax, histMin = 1, 256
for pixelX in range(width):
for pixelY in range(height):
# Even though a greyscale picture is expected the image
# gets loaded as RGB, thus its needed to access any of the
# seperate colour values, since they should have the same value.
# If coloured pictures are given, this will result in a greyscale
# representation and equalization of the red values.
if picDestinationArray[pixelX, pixelY][0] < histMin:
histMin = picDestinationArray[pixelX, pixelY][0]
if picDestinationArray[pixelX, pixelY][0] > histMax:
histMax = picDestinationArray[pixelX, pixelY][0]

# Apply histogramm equalization formula to every pixel
for pixelX in range(width):
for pixelY in range(height):
newVal = int(256 * ((picDestinationArray[pixelX, pixelY][0] - histMin) / (histMax - histMin)) - 1)
# Since the picture is loaded as RGB, we need to set the value thrice
picDestinationArray[pixelX, pixelY] = (newVal, newVal, newVal)

return picDestination



if __name__ == "__main__":
if len(sys.argv) != 2:
print('Usage: {} <Image File>'.format(sys.argv[0]))
else:
picOut = histogramEqualization(sys.argv[1])
picOut.save('out.bmp')
23 changes: 23 additions & 0 deletions HistogramEqualization/README.md
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
# Histogram Equalization with Phyton

This script takes grayscale pictures and spreads out their colour range to the fullest. Sometimes grayscale pictures look dull or foggy because they don't use the full range of possible gray colours. This script uses the formula described in [Wikipedia](https://de.wikipedia.org/wiki/Punktoperator_(Bildverarbeitung)#Histogrammspreizung_und_-stauchung) and applies it pixel by pixel on the given picture.

This example picture is taken from Wikimedia and belongs to [Phillip Capper](https://commons.wikimedia.org/wiki/File:Hawkes_Bay_NZ.jpg).
![Example of unequalized Picture](https://upload.wikimedia.org/wikipedia/commons/0/08/Unequalized_Hawkes_Bay_NZ.jpg)

And this is the result of the script.
![The example picture after processing](Equalized_example_picture.bmp)

## Installation
The script tries to use a minimum amount of modules, but still needs one; Pillow. Install it with

```bash
$ pip install pillow
```

## Usage
This script takes a picture and puts out the processed picture as 'out.bmp' in the destination of the script.

```bat
Usage: HistogrammEqualization.py <Image File>
```
71 changes: 71 additions & 0 deletions Kth Nearest Neighbour (ML Algorithm)/KNN.py
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
from numpy import *
import operator


def classify(x,dataset,labels,k):
datasetsize=dataset.shape[0]
diffmat=tile(x,(datasetsize,1))-dataset
sqdiffmat=diffmat**2
sqdistances=sqdiffmat.sum(axis=1)
distances=sqdistances**0.5
sorteddistindices=distances.argsort()
classcount={}
for i in range(k):

voteIlabel=labels[sorteddistindices[i]]
classcount[voteIlabel]=classcount.get(voteIlabel,0) +1

sortedclasscount=sorted(classcount.items(),key=operator.itemgetter(1),reverse=True)
return sortedclasscount[0][0]

def autonorm(dataset):
minval=dataset.min(0)
maxval=dataset.max(0)
ranges=maxval-minval
normdataset=zeros(shape(dataset))
m=dataset.shape[0]
normdataset=dataset-tile(minval,(m,1))
normdataset=normdataset/tile(ranges,(m,1))
return normdataset,ranges,minval


def file2matrix(filename):
fr=open(filename)
numberoflines=len(fr.readlines())
returnmat=zeros((numberoflines,7))
classLabelvec=[]
fr=open(filename)
index=0
for line in fr.readlines():
line=line.strip()
listfromline=line.split(",")
returnmat[index,:]=listfromline[1:8]
classLabelvec.append((listfromline[0]))
index+=1
return returnmat,classLabelvec

def classperson():
print("Abalone is a common name for any of a group of small to very large sea snails, marine gastropod molluscs in the family Haliotidae.")
print("\n")
print("From certain input about Abalone this algorithm will predict whether Abalone is \nM-> Male,\nF->Female or\nI->Infant ")
print("\n")
print("Accuracy of this algorithm is 65 to 70%")
input1 =float(input("enter length of Abalone"))
input2 = float(input("enter diameter"))
input3 = float(input("enter height"))
input4 = float(input("enter whole weight"))
input5 = float(input("enter shucked weight"))
input6 = float(input("enter viscera weight"))
input7 = float(input("enter shell weight"))


datamat, lab = file2matrix("KNN_support/abalone.data")
normmat, ran, minval = autonorm(datamat)

inarr=array([input1,input2,input3,input4,input5,input6,input7])
classresult=classify((inarr-minval)/ran,normmat,lab,3)
print("\n")
print(classresult)


classperson()
Loading