Skip to content

Commit c781a8b

Browse files
authored
Add files via upload
1 parent 2b8509a commit c781a8b

24 files changed

+285
-266
lines changed

CountMillionCharacters-2.0.py

-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
"""Get the number of each character in any given text.
32
Inputs:
43
A txt file -- You will be asked for an input file. Simply input the name
@@ -10,7 +9,6 @@
109

1110

1211
def main():
13-
1412
file_input = input('File Name: ')
1513
try:
1614
with open(file_input, 'r') as info:

Counting-sort.py

+7-9
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#counting sort
1+
# counting sort
22

33
l = []
44

@@ -7,17 +7,16 @@
77
highest = 0
88

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

1212
if temp > highest:
1313
highest = temp
14-
15-
l += [temp]
1614

15+
l += [temp]
1716

18-
def counting_sort(l,h):
1917

20-
bookkeeping = [0 for i in range(h+1)]
18+
def counting_sort(l, h):
19+
bookkeeping = [0 for i in range(h + 1)]
2120

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

3130
for j in range(bookkeeping[i]):
32-
3331
L += [i]
3432

3533
return L
3634

37-
print(counting_sort(l,highest))
38-
35+
36+
print(counting_sort(l, highest))

Credit_Card_Validator.py

+6-8
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22

33

44
class CreditCard:
5-
def __init__(self,card_no):
5+
def __init__(self, card_no):
66
self.card_no = card_no
77

88
@property
99
def company(self):
1010
comp = None
1111
if str(self.card_no).startswith('4'):
1212
comp = 'Visa Card'
13-
elif str(self.card_no).startswith(('50', '67', '58','63',)):
13+
elif str(self.card_no).startswith(('50', '67', '58', '63',)):
1414
comp = 'Maestro Card'
1515
elif str(self.card_no).startswith('5'):
1616
comp = 'Master Card'
@@ -25,7 +25,7 @@ def company(self):
2525
elif str(self.card_no).startswith('7'):
2626
comp = 'Gasoline Card'
2727

28-
return 'Company : '+comp
28+
return 'Company : ' + comp
2929

3030
def first_check(self):
3131
if 13 <= len(self.card_no) <= 19:
@@ -41,7 +41,7 @@ def validate(self):
4141
crd_no = self.card_no[::-1]
4242
for i in range(len(crd_no)):
4343
if i % 2 == 1:
44-
double_it = int(crd_no[i])*2
44+
double_it = int(crd_no[i]) * 2
4545

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

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

6666
@classmethod
67-
def set_card(cls,card_to_check):
67+
def set_card(cls, card_to_check):
6868
return cls(card_to_check)
6969

7070

@@ -76,8 +76,6 @@ def set_card(cls,card_to_check):
7676
print(card.checksum)
7777
print(card.validate())
7878

79-
8079
# 79927398713
8180
# 4388576018402626
8281
# 379354508162306
83-

Cricket_score.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import bs4 as bs
22
from urllib import request
3-
from win10toast import ToastNotifier
3+
from win10toast import ToastNotifier
44

55
toaster = ToastNotifier()
66

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

20-
2120
print(score[0], results[0])
2221
toaster.show_toast(title=score[0], msg=results[0])
23-

EncryptionTool.py

+60-52
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
#GGearing
2-
#Simple encryption script for text
3-
#This was one my first versions of this script
4-
#09/07/2017
1+
# GGearing
2+
# Simple encryption script for text
3+
# This was one my first versions of this script
4+
# 09/07/2017
55
from __future__ import print_function
66
import math
77
import sys
@@ -15,97 +15,105 @@
1515
else:
1616
input_fun = raw_input
1717

18-
text=input_fun("Enter text: ")
19-
values= []
20-
reverse= []
18+
text = input_fun("Enter text: ")
19+
values = []
20+
reverse = []
21+
22+
2123
def encryptChar(target):
22-
#encrytion algorithm
23-
target=(((target+42) * key) -449)
24+
# encrytion algorithm
25+
target = (((target + 42) * key) - 449)
2426
return target
2527

28+
2629
def decryptChar(target):
27-
target=(((target+449) / key) -42)
30+
target = (((target + 449) / key) - 42)
2831
return target
2932

33+
3034
def encrypt(input_text):
31-
col_values= []
32-
for i in range (len(input_text)):
33-
current=ord(input_text[i])
34-
current=encryptChar(current)
35+
col_values = []
36+
for i in range(len(input_text)):
37+
current = ord(input_text[i])
38+
current = encryptChar(current)
3539
col_values.append(current)
3640
return col_values
3741

42+
3843
def decrypt(enc_text):
3944
col_values = []
40-
for i in range (len(enc_text)):
41-
current=int(decryptChar(enc_text[i]))
42-
current=chr(current)
45+
for i in range(len(enc_text)):
46+
current = int(decryptChar(enc_text[i]))
47+
current = chr(current)
4348
col_values.append(current)
4449
return col_values
4550

51+
4652
def readAndDecrypt(filename):
47-
file=open(filename,"r")
48-
data=file.read()
49-
datalistint= []
50-
actualdata= []
51-
datalist=data.split(" ")
53+
file = open(filename, "r")
54+
data = file.read()
55+
datalistint = []
56+
actualdata = []
57+
datalist = data.split(" ")
5258
datalist.remove('')
5359
for i in range(len(datalist)):
5460
datalistint.append(float(datalist[i]))
5561
for i in range(len(datalist)):
56-
current1=int(decryptChar(datalistint[i]))
57-
current1=chr(current1)
62+
current1 = int(decryptChar(datalistint[i]))
63+
current1 = chr(current1)
5864
actualdata.append(current1)
5965
file.close()
6066
return actualdata
6167

68+
6269
def readAndEncrypt(filename):
63-
file=open(filename,"r")
64-
data=file.read()
65-
datalist=list(data)
66-
encrypted_list=list()
67-
encrypted_list_str=list()
70+
file = open(filename, "r")
71+
data = file.read()
72+
datalist = list(data)
73+
encrypted_list = list()
74+
encrypted_list_str = list()
6875
for i in range(len(datalist)):
69-
current=ord(datalist[i])
70-
current=encryptChar(current)
76+
current = ord(datalist[i])
77+
current = encryptChar(current)
7178
encrypted_list.append(current)
7279
file.close()
7380
return encrypted_list
7481

75-
def readAndEncryptAndSave(inp_file,out_file):
76-
enc_list=readAndEncrypt(inp_file)
77-
output=open(out_file,"w")
82+
83+
def readAndEncryptAndSave(inp_file, out_file):
84+
enc_list = readAndEncrypt(inp_file)
85+
output = open(out_file, "w")
7886
for i in range(len(enc_list)):
79-
output.write(str(enc_list[i])+" ")
87+
output.write(str(enc_list[i]) + " ")
8088
output.close()
8189

82-
def readAndDecryptAndSave(inp_file,out_file):
83-
dec_list=readAndDecrypt(inp_file)
84-
output=open(out_file,"w")
90+
91+
def readAndDecryptAndSave(inp_file, out_file):
92+
dec_list = readAndDecrypt(inp_file)
93+
output = open(out_file, "w")
8594
for i in range(len(dec_list)):
8695
output.write(str(dec_list[i]))
8796
output.close()
8897

89-
#encryption
90-
for i in range (len(text)):
91-
current=ord(text[i])
92-
current=encryptChar(current)
98+
99+
# encryption
100+
for i in range(len(text)):
101+
current = ord(text[i])
102+
current = encryptChar(current)
93103
values.append(current)
94104

95-
#decryption
96-
for i in range (len(text)):
97-
current=int(decryptChar(values[i]))
98-
current=chr(current)
105+
# decryption
106+
for i in range(len(text)):
107+
current = int(decryptChar(values[i]))
108+
current = chr(current)
99109
reverse.append(current)
100110
print(reverse)
101111

102-
#saves encrypted in txt file
103-
output=open("encrypted.txt","w")
112+
# saves encrypted in txt file
113+
output = open("encrypted.txt", "w")
104114
for i in range(len(values)):
105-
output.write(str(values[i])+" ")
115+
output.write(str(values[i]) + " ")
106116
output.close()
107117

108-
#read and decrypts
118+
# read and decrypts
109119
print(readAndDecrypt("encrypted.txt"))
110-
111-

backup_automater_services.py

+16-16
Original file line numberDiff line numberDiff line change
@@ -8,25 +8,25 @@
88

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

11-
import datetime # Load the library module
12-
import os # Load the library module
13-
import shutil # Load the library module
11+
import datetime # Load the library module
12+
import os # Load the library module
13+
import shutil # Load the library module
1414

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

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

2626
# the destination backup directory
27-
for file_name in open(conffilename): # Walk through the configuration file
28-
fname = file_name.strip() # Strip out the blank lines from the configuration file
29-
if fname: # For the lines that are not blank
30-
sourcefile = os.path.join(sourcedir, fname) # Get the name of the source files to backup
31-
destfile = os.path.join(destdir, fname) # Get the name of the destination file names
32-
shutil.copytree(sourcefile, destfile) # Copy the directories
27+
for file_name in open(conffilename): # Walk through the configuration file
28+
fname = file_name.strip() # Strip out the blank lines from the configuration file
29+
if fname: # For the lines that are not blank
30+
sourcefile = os.path.join(sourcedir, fname) # Get the name of the source files to backup
31+
destfile = os.path.join(destdir, fname) # Get the name of the destination file names
32+
shutil.copytree(sourcefile, destfile) # Copy the directories

batch_file_rename.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
once you pass the current and new extensions
77
"""
88

9-
109
# just checking
1110
__author__ = 'Craig Richards'
1211
__version__ = '1.0'
@@ -28,7 +27,7 @@ def batch_rename(work_dir, old_ext, new_ext):
2827
# Start of the logic to check the file extensions, if old_ext = file_ext
2928
if old_ext == file_ext:
3029
# Returns changed name of the file with new extention
31-
newfile = split_file[0] + new_ext
30+
newfile = split_file[0] + new_ext
3231

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

4039
def get_parser():
4140
parser = argparse.ArgumentParser(description='change extension of files in a working directory')
42-
parser.add_argument('work_dir', metavar='WORK_DIR', type=str, nargs=1, help='the directory where to change extension')
41+
parser.add_argument('work_dir', metavar='WORK_DIR', type=str, nargs=1,
42+
help='the directory where to change extension')
4343
parser.add_argument('old_ext', metavar='OLD_EXT', type=str, nargs=1, help='old extension')
4444
parser.add_argument('new_ext', metavar='NEW_EXT', type=str, nargs=1, help='new extension')
4545
return parser

0 commit comments

Comments
 (0)