Skip to content

Instantly share code, notes, and snippets.

@kurzweil777
kurzweil777 / Twitch Bot
Last active February 9, 2021 16:34
Small Projects
# bot.py
import os # for importing env vars for the bot to use
from twitchio.ext import commands
import random
import sys
chatters = []
bot = commands.Bot(
# set up the bot
irc_token=os.environ['TMI_TOKEN'],
@kurzweil777
kurzweil777 / Yandex task finder
Created December 22, 2020 07:00
Selenium Automation
from selenium import webdriver
from selenium.common.exceptions import NoSuchElementException
from selenium.webdriver.common.keys import Keys
import win10toast
from selenium.webdriver.support.ui import WebDriverWait
import time
path = "C:\Program Files (x86)\chromedriver.exe"
driver = webdriver.Chrome(path)
toaster = win10toast.ToastNotifier()
@kurzweil777
kurzweil777 / Kebabize
Last active October 5, 2020 16:41
Exercise from CodeWars
def kebabize(string):
"""Modify the kebabize function so that it converts a camel case string into a kebab case."""
for letter in string:
if letter.isupper():
string = string.replace(letter, "-" + letter.lower())
elif letter.isdigit():
string = string.replace(letter, "")
return string.lstrip("-")
@kurzweil777
kurzweil777 / Salesman's Travel
Created October 5, 2020 04:12
Exercise from CodeWars
import re
def travel(r, zipcode):
"""The function travel will take two parameters r (addresses' list of all clients' as a string) and zipcode and
returns a string in the following format:
zipcode:street and town,street and town,.../house number,house number,...
The street numbers must be in the same order as the streets where they belong.
If a given zipcode doesn't exist in the list of clients' addresses return "zipcode:/"""
number_of_house, street = [], []
@kurzweil777
kurzweil777 / Duplicate Count
Created October 4, 2020 15:04
Exercise from CodeWars
from collections import Counter
def duplicate_count(text):
"""Write a function that will return the count of distinct case-insensitive alphabetic characters and numeric
digits that occur more than once in the input string. The input string can be assumed to contain only alphabets (
both uppercase and lowercase) and numeric digits. """
return sum([1 for a in Counter(text.lower()).values() if a > 1])
@kurzweil777
kurzweil777 / Fibonacci Strings
Created August 28, 2020 07:09
Exercise from the CodeWars
def solve(n):
f0, f1 = "0", "01"
if n == 0:
return f0
elif n == 1:
return f1
elif n > 1:
for i in range(2, n + 1):
b = f0
f0 = f1
@kurzweil777
kurzweil777 / Telegram Bots
Created August 13, 2020 18:35
SlangerBot
from telebot import types
from telebot.apihelper import ApiException
import config
import telebot
import requests
from bs4 import BeautifulSoup
from googletrans import Translator
bot = telebot.TeleBot(config.TOKEN, parse_mode="html")
@kurzweil777
kurzweil777 / Kis_Activator
Last active July 25, 2024 20:23
Kis_Activator
import os
import sys
import pywinauto
import requests
from bs4 import BeautifulSoup
import pyautogui as gui
import winreg as reg
import ctypes
import subprocess
@kurzweil777
kurzweil777 / Creating the Gaps
Last active July 25, 2020 13:14
Exercise from automate boring stuff
#!python3
import os
import re
"""As an added challenge, write another program that can insert gaps into numbered files so that a new file can be
added. """
working_directory = input("Input your working directory with files: ")
numbers = [[correct_number + 1, number_of_file] for foldername, subfolder, filename in
@kurzweil777
kurzweil777 / Filling in the Gaps
Last active July 25, 2020 13:11
Exercise from automate boring stuff
#!python3
import os
import re
"""Write a program that finds all files with a given prefix, such as spam001.txt , spam002.txt ,
and so on, 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."""