r/tinycode • u/Mike_TriHard_Cx • Jan 14 '18
CDSA - A compact (although highly documented) library of generic data structures and algorithms in ANSI C
r/tinycode • u/Mike_TriHard_Cx • Jan 14 '18
r/tinycode • u/onqtam • Jan 04 '18
r/tinycode • u/winner_godson • Dec 25 '17
Hi Pythonic Redditors,
I came across this script to send jpg files via email and I thought it would be worthwhile to share it here.
I hope the lines of code are not too much to go against the rules.(If you can minimize it, I would appreciate your effort)
import smtplib
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
from email.mime.multipart import MIMEBase
from email import encoders
import os
"""
extensions of files that we will send
"""
extension = "jpg"
"""
This function returns a tuple with the files located in the
current
directory
"""
files = os.listdir() #this program should be saved in the
current directory where your files are.
"""
We check what files have our wished extension
"""
for file in files:
if extension in file:
user ="sending@gmail.com" #sending gmail
recv ="receiving@gmail.com" #receiving gmail
subject = "Subject" #subject of email message
message = MIMEMultipart()
message["From"] = user
message["To"] = recv
message["Subject"]= subject
body = "Files with ." + extension + "extension"
message.attach(MIMEText(body,"plain"))
attachment = open(file,"rb")
part = MIMEBase("application","octet-stream")
part.set_payload((attachment).read())
encoders.encode_base64(part)
part.add_header("Content-Disposition","attachment;
filename= " + file)
message.attach(part)
text = message.as_string()
server = smtplib.SMTP("smtp.gmail.com",587)
server.starttls()
server.login(user,"your gmail pasword")
server.sendmail(user,recv,text)
server.quit()
else:
passThis code was shared by Om Tav on a facebook page.
You may get error at first due to google trying to protect your gmail account from unknown app trying to login in.
Just check your email and follow the steps provided by gmail.
Then run the code again.
Happy Pythonic Holiday and try to automate your task with Python
r/tinycode • u/rain5 • Dec 24 '17
r/tinycode • u/rain5 • Dec 13 '17
This erlang paper One Pass Real Time Generational Mark and Sweep Garbage Collection.
the algorithms they show are so concise. never seen anything like it.
r/tinycode • u/marcoscleison • Dec 05 '17
r/tinycode • u/feute • Nov 25 '17
r/tinycode • u/rain5 • Nov 19 '17
r/tinycode • • Nov 04 '17
r/tinycode • u/rain5 • Nov 03 '17
r/tinycode • u/Dresdenboy • Sep 17 '17
r/tinycode • u/Dresdenboy • Sep 16 '17
r/tinycode • • Sep 12 '17
r/tinycode • u/nbari • Sep 11 '17
r/tinycode • u/Jimmy_Lor • Aug 11 '17
r/tinycode • u/Bisqwit • Aug 10 '17
r/tinycode • u/rain5 • Aug 06 '17
r/tinycode • u/CountFrolic • Jul 19 '17