Skip to content

Instantly share code, notes, and snippets.

@Haolicopter
Haolicopter / keepMouseMoving.py
Created June 12, 2017 18:59
Keep mouse moving so screen won't go to sleep, useful when playing Duck Games
#!/usr/bin/env python3
import pyautogui
import time
import sys
import os
print('Press Ctrl + C to stop mouse from moving around.')
# Time delay between mouse movement
delay = 10
@Haolicopter
Haolicopter / AutoUnsubscribe.py
Created June 12, 2017 18:30
Scans through your email account and find all the unsubscribe links in all your emails.
#!/usr/bin/env python3
# Scans through your email account,
# find all the unsubscribe links in all your emails,
# and automatically opens them in a browser.
# This program will have to log in to your email provider's IMAP server
# and download all of your emails.
# You can use BeautifulSoup to check for any instance
# where the word unsubscribe occurs within an HTML link tag.
@Haolicopter
Haolicopter / spreadsheetToTextFiles.py
Created May 16, 2017 05:09
This program opens a spreadsheet and write the cells of column A into one text file, the cells of column B into another text file, and so on.
#!/usr/bin/env python3
# This program opens a spreadsheet and write the cells of column A into one text file, the cells of column B into another text file, and so on.
import openpyxl, os
wb = openpyxl.load_workbook('allInOne.xlsx')
sheet = wb.active
# Loop through each column
@Haolicopter
Haolicopter / textFilesToSpreadsheet.py
Created May 16, 2017 04:59
This program reads in the contents of several text files and inserts those contents into a spreadsheet, with one line of text per row. The lines of the first text file will be in the cells of column A. The lines of the second text file will be in the cells of column B, and so on.
#!/usr/bin/env python3
# This program reads in the contents of several text files and inserts those contents into a spreadsheet, with one line of text per row.
# The lines of the first text file will be in the cells of column A.
# The lines of the second text file will be in the cells of column B, and so on.
import openpyxl
from openpyxl.utils import get_column_letter
# Create a new spreadsheet
@Haolicopter
Haolicopter / spreadsheetCellInverter.py
Created May 16, 2017 04:35
This program inverts the row and column of the cells in the spreadsheet.
#!/usr/bin/env python3
# This program inverts the row and column of the cells in the spreadsheet.
import sys, openpyxl
from openpyxl.utils import get_column_letter
fileName = 'somefile.xlsx'
wb = openpyxl.load_workbook(fileName)
sheet = wb.active
@Haolicopter
Haolicopter / blankRowInserter.py
Created May 16, 2017 04:29
This program takes two integers and a filename string as command line arguments. Let's call the first integer N and the second integer M. Starting at row N, the program should insert M blank rows into the spreadsheet.
#!/usr/bin/env python3
# This program takes two integers and a filename string as command line arguments.
# Let's call the first integer N and the second integer M.
# Starting at row N, the program should insert M blank rows into the spreadsheet.
import sys, openpyxl
from openpyxl.utils import get_column_letter
if len(sys.argv) > 1:
@Haolicopter
Haolicopter / multiplicationTable.py
Created May 15, 2017 03:58
This program takes a number N from the command line and creates an N by N multiplication table in an Excel spreadsheet.
#!/usr/bin/env python3
# This program takes a number N from the command line
# and creates an N by N multiplication table in an Excel spreadsheet.
import sys, openpyxl
from openpyxl.styles import Font
from openpyxl.utils import get_column_letter, column_index_from_string
# Default n is 6
@Haolicopter
Haolicopter / inPlaceShuffle.py
Created May 11, 2017 15:34
A small program that does in place shuffle
#!/usr/bin/env python3
# The shuffle must be "uniform," meaning each item in the original list must have the same probability of ending up in each spot in the final list.
# Assume that you have a function get_random(floor, ceiling) for getting a random integer that is >= floor and <= ceiling.
import random
myList = [12, 7, 9, 10, 4]
for i in range(len(myList)-1, 0, -1):
@Haolicopter
Haolicopter / fillInGaps.py
Created May 7, 2017 03:29
Write a program that finds all files with a given prefix, such as spam001.txt, spam002.txt, and so no, in a single folder and locates any gaps in the numbering (such as if there is a spam001.txt and spam003.txt but no spam002.txt). Have the program rename all the later files to close this gap.
#!/usr/bin/env python3
# Write a program that finds all files with a given prefix, such as spam001.txt, spam002.txt, and so no, in a single folder
# and locates any gaps in the numbering (such as if there is a spam001.txt and spam003.txt but no spam002.txt).
# Have the program rename all the later files to close this gap.
import os, shutil
def fillInGaps(folder, prefix):
folder = os.path.abspath(folder)
@Haolicopter
Haolicopter / fillInGapsWithNewFiles.py
Created May 7, 2017 02:35
Write a program that finds all files with a given prefix, such as spam001.txt, spam002.txt, and so no, in a single folder and locates any gaps in the numbering (such as if there is a spam001.txt and spam003.txt but no spam002.txt). Have the program that can insert gaps into numbered files so that a new file can be added.
#!/usr/bin/env python3
# Write a program that finds all files with a given prefix, such as spam001.txt, spam002.txt, and so no, in a single folder
# and locates any gaps in the numbering (such as if there is a spam001.txt and spam003.txt but no spam002.txt).
# Have the program that can insert gaps into numbered files so that a new file can be added.
import os
def fillInGapsWithNewFiles(folder, prefix):
folder = os.path.abspath(folder)