Skip to content

Instantly share code, notes, and snippets.

def primes1(n):
"""Generates a list of the first n primes. If the input is not an integer it will be converted to one
Dependencies: N/A
In: (number)
Out: list"""
# pwimes = list(x for x in range(n) if x > 1 and all(x%y for y in range(2, min(x, 11))))
n = int(n) - 1
bank = []
track = 2
while len(bank)<n+1:
def mulPer(n):
"""Computes the Multiplicative Persistence of an int or float in base-10 positional notation
Dependencies: pipe (from meta)
In: Integer
Out: Integer"""
# Exclusions
if n == 0:
return 0
elif len(str(n)) == 1:
return 0
"""
While I'm sure there's a better word for this than cryptec, I'm afraid I don't know it... yet...
"""
def monoalphabetic(string, shif, dir):
"""Returns an un/en-crypted string using a monoalphabetic cryptosystem
Dependencies: crypt(nested), alphabet
In: (message, shift coefficient, direction ("de" for decryption, "en" for encryption))
Out: string"""
alphabet = " aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ0123456789!?&@#$%^*+_-=~.:,;`'\"|/\\(){}[]<>"
"""
Some things are shorter left unsaid
"""
import subprocess, pyperclip
def getIP(copy=False):
"""
Returns the IP address of the device on which the function is called
Dependencies: subprocess.check_result, pyperclip.copy
Arguments: copy=False
"""
Let yourself know your simple http server is running on a specific port when you broke your computer screen
but you've still gotta get jiggy with your file system so you're using someone else's machine while they watch
tv on the telly you'd be watching otherwise
"""
import os, smtplib
from email.message import EmailMessage
def quickMail(msg,dst=os.environ.get('personalEmail'),subj=None,head=None,extra=None,att=None):
"""
Sends a short email to the given dst using gmail's smtp configuration with default sender/receiver info taken from user environment variables
"""
This little piggy helps you avoid accidentally overwriting downloads/auto-generated files
"""
def nameUpdater(path):
"""
Returns a unique version of a given string by appending an integer
Dependencies: os module
In: string
Out: string_2
"""