Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
bhavsec authored Oct 11, 2018
1 parent 2b8509a commit c781a8b
Show file tree
Hide file tree
Showing 24 changed files with 285 additions and 266 deletions.
2 changes: 0 additions & 2 deletions CountMillionCharacters-2.0.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

"""Get the number of each character in any given text.
Inputs:
A txt file -- You will be asked for an input file. Simply input the name
Expand All @@ -10,7 +9,6 @@


def main():

file_input = input('File Name: ')
try:
with open(file_input, 'r') as info:
Expand Down
16 changes: 7 additions & 9 deletions Counting-sort.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#counting sort
# counting sort

l = []

Expand All @@ -7,17 +7,16 @@
highest = 0

for i in range(n):
temp = int(input("Enter element"+str(i+1)+': '))
temp = int(input("Enter element" + str(i + 1) + ': '))

if temp > highest:
highest = temp

l += [temp]

l += [temp]

def counting_sort(l,h):

bookkeeping = [0 for i in range(h+1)]
def counting_sort(l, h):
bookkeeping = [0 for i in range(h + 1)]

for i in l:
bookkeeping[i] += 1
Expand All @@ -29,10 +28,9 @@ def counting_sort(l,h):
if bookkeeping[i] > 0:

for j in range(bookkeeping[i]):

L += [i]

return L

print(counting_sort(l,highest))

print(counting_sort(l, highest))
14 changes: 6 additions & 8 deletions Credit_Card_Validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@


class CreditCard:
def __init__(self,card_no):
def __init__(self, card_no):
self.card_no = card_no

@property
def company(self):
comp = None
if str(self.card_no).startswith('4'):
comp = 'Visa Card'
elif str(self.card_no).startswith(('50', '67', '58','63',)):
elif str(self.card_no).startswith(('50', '67', '58', '63',)):
comp = 'Maestro Card'
elif str(self.card_no).startswith('5'):
comp = 'Master Card'
Expand All @@ -25,7 +25,7 @@ def company(self):
elif str(self.card_no).startswith('7'):
comp = 'Gasoline Card'

return 'Company : '+comp
return 'Company : ' + comp

def first_check(self):
if 13 <= len(self.card_no) <= 19:
Expand All @@ -41,7 +41,7 @@ def validate(self):
crd_no = self.card_no[::-1]
for i in range(len(crd_no)):
if i % 2 == 1:
double_it = int(crd_no[i])*2
double_it = int(crd_no[i]) * 2

if len(str(double_it)) == 2:
sum_ += sum([eval(i) for i in str(double_it)])
Expand All @@ -61,10 +61,10 @@ def validate(self):

@property
def checksum(self):
return '#CHECKSUM# : '+self.card_no[-1]
return '#CHECKSUM# : ' + self.card_no[-1]

@classmethod
def set_card(cls,card_to_check):
def set_card(cls, card_to_check):
return cls(card_to_check)


Expand All @@ -76,8 +76,6 @@ def set_card(cls,card_to_check):
print(card.checksum)
print(card.validate())


# 79927398713
# 4388576018402626
# 379354508162306

4 changes: 1 addition & 3 deletions Cricket_score.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import bs4 as bs
from urllib import request
from win10toast import ToastNotifier
from win10toast import ToastNotifier

toaster = ToastNotifier()

Expand All @@ -17,7 +17,5 @@
for result in soup.find_all('div', attrs={"class": "cb-lv-scrs-col cb-text-complete"}):
results.append(result.text)


print(score[0], results[0])
toaster.show_toast(title=score[0], msg=results[0])

112 changes: 60 additions & 52 deletions EncryptionTool.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#GGearing
#Simple encryption script for text
#This was one my first versions of this script
#09/07/2017
# GGearing
# Simple encryption script for text
# This was one my first versions of this script
# 09/07/2017
from __future__ import print_function
import math
import sys
Expand All @@ -15,97 +15,105 @@
else:
input_fun = raw_input

text=input_fun("Enter text: ")
values= []
reverse= []
text = input_fun("Enter text: ")
values = []
reverse = []


def encryptChar(target):
#encrytion algorithm
target=(((target+42) * key) -449)
# encrytion algorithm
target = (((target + 42) * key) - 449)
return target


def decryptChar(target):
target=(((target+449) / key) -42)
target = (((target + 449) / key) - 42)
return target


def encrypt(input_text):
col_values= []
for i in range (len(input_text)):
current=ord(input_text[i])
current=encryptChar(current)
col_values = []
for i in range(len(input_text)):
current = ord(input_text[i])
current = encryptChar(current)
col_values.append(current)
return col_values


def decrypt(enc_text):
col_values = []
for i in range (len(enc_text)):
current=int(decryptChar(enc_text[i]))
current=chr(current)
for i in range(len(enc_text)):
current = int(decryptChar(enc_text[i]))
current = chr(current)
col_values.append(current)
return col_values


def readAndDecrypt(filename):
file=open(filename,"r")
data=file.read()
datalistint= []
actualdata= []
datalist=data.split(" ")
file = open(filename, "r")
data = file.read()
datalistint = []
actualdata = []
datalist = data.split(" ")
datalist.remove('')
for i in range(len(datalist)):
datalistint.append(float(datalist[i]))
for i in range(len(datalist)):
current1=int(decryptChar(datalistint[i]))
current1=chr(current1)
current1 = int(decryptChar(datalistint[i]))
current1 = chr(current1)
actualdata.append(current1)
file.close()
return actualdata


def readAndEncrypt(filename):
file=open(filename,"r")
data=file.read()
datalist=list(data)
encrypted_list=list()
encrypted_list_str=list()
file = open(filename, "r")
data = file.read()
datalist = list(data)
encrypted_list = list()
encrypted_list_str = list()
for i in range(len(datalist)):
current=ord(datalist[i])
current=encryptChar(current)
current = ord(datalist[i])
current = encryptChar(current)
encrypted_list.append(current)
file.close()
return encrypted_list

def readAndEncryptAndSave(inp_file,out_file):
enc_list=readAndEncrypt(inp_file)
output=open(out_file,"w")

def readAndEncryptAndSave(inp_file, out_file):
enc_list = readAndEncrypt(inp_file)
output = open(out_file, "w")
for i in range(len(enc_list)):
output.write(str(enc_list[i])+" ")
output.write(str(enc_list[i]) + " ")
output.close()

def readAndDecryptAndSave(inp_file,out_file):
dec_list=readAndDecrypt(inp_file)
output=open(out_file,"w")

def readAndDecryptAndSave(inp_file, out_file):
dec_list = readAndDecrypt(inp_file)
output = open(out_file, "w")
for i in range(len(dec_list)):
output.write(str(dec_list[i]))
output.close()

#encryption
for i in range (len(text)):
current=ord(text[i])
current=encryptChar(current)

# encryption
for i in range(len(text)):
current = ord(text[i])
current = encryptChar(current)
values.append(current)

#decryption
for i in range (len(text)):
current=int(decryptChar(values[i]))
current=chr(current)
# decryption
for i in range(len(text)):
current = int(decryptChar(values[i]))
current = chr(current)
reverse.append(current)
print(reverse)

#saves encrypted in txt file
output=open("encrypted.txt","w")
# saves encrypted in txt file
output = open("encrypted.txt", "w")
for i in range(len(values)):
output.write(str(values[i])+" ")
output.write(str(values[i]) + " ")
output.close()

#read and decrypts
# read and decrypts
print(readAndDecrypt("encrypted.txt"))


32 changes: 16 additions & 16 deletions backup_automater_services.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,25 @@

# Description : This will go through and backup all my automator services workflows

import datetime # Load the library module
import os # Load the library module
import shutil # Load the library module
import datetime # Load the library module
import os # Load the library module
import shutil # Load the library module

today = datetime.date.today() # Get Today's date
todaystr = today.isoformat() # Format it so we can use the format to create the directory
today = datetime.date.today() # Get Today's date
todaystr = today.isoformat() # Format it so we can use the format to create the directory

confdir = os.getenv("my_config") # Set the variable by getting the value from the OS setting
dropbox = os.getenv("dropbox") # Set the variable by getting the value from the OS setting
conffile = 'services.conf' # Set the variable as the name of the configuration file
conffilename = os.path.join(confdir, conffile) # Set the variable by combining the path and the file name
sourcedir = os.path.expanduser('~/Library/Services/') # Source directory of where the scripts are located
confdir = os.getenv("my_config") # Set the variable by getting the value from the OS setting
dropbox = os.getenv("dropbox") # Set the variable by getting the value from the OS setting
conffile = 'services.conf' # Set the variable as the name of the configuration file
conffilename = os.path.join(confdir, conffile) # Set the variable by combining the path and the file name
sourcedir = os.path.expanduser('~/Library/Services/') # Source directory of where the scripts are located
# Combine several settings to create
destdir = os.path.join(dropbox, "My_backups" + "/" + "Automater_services" + todaystr + "/")

# the destination backup directory
for file_name in open(conffilename): # Walk through the configuration file
fname = file_name.strip() # Strip out the blank lines from the configuration file
if fname: # For the lines that are not blank
sourcefile = os.path.join(sourcedir, fname) # Get the name of the source files to backup
destfile = os.path.join(destdir, fname) # Get the name of the destination file names
shutil.copytree(sourcefile, destfile) # Copy the directories
for file_name in open(conffilename): # Walk through the configuration file
fname = file_name.strip() # Strip out the blank lines from the configuration file
if fname: # For the lines that are not blank
sourcefile = os.path.join(sourcedir, fname) # Get the name of the source files to backup
destfile = os.path.join(destdir, fname) # Get the name of the destination file names
shutil.copytree(sourcefile, destfile) # Copy the directories
6 changes: 3 additions & 3 deletions batch_file_rename.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
once you pass the current and new extensions
"""


# just checking
__author__ = 'Craig Richards'
__version__ = '1.0'
Expand All @@ -28,7 +27,7 @@ def batch_rename(work_dir, old_ext, new_ext):
# Start of the logic to check the file extensions, if old_ext = file_ext
if old_ext == file_ext:
# Returns changed name of the file with new extention
newfile = split_file[0] + new_ext
newfile = split_file[0] + new_ext

# Write the files
os.rename(
Expand All @@ -39,7 +38,8 @@ def batch_rename(work_dir, old_ext, new_ext):

def get_parser():
parser = argparse.ArgumentParser(description='change extension of files in a working directory')
parser.add_argument('work_dir', metavar='WORK_DIR', type=str, nargs=1, help='the directory where to change extension')
parser.add_argument('work_dir', metavar='WORK_DIR', type=str, nargs=1,
help='the directory where to change extension')
parser.add_argument('old_ext', metavar='OLD_EXT', type=str, nargs=1, help='old extension')
parser.add_argument('new_ext', metavar='NEW_EXT', type=str, nargs=1, help='new extension')
return parser
Expand Down
Loading

0 comments on commit c781a8b

Please sign in to comment.