<commit_before>#!/usr/bin/python
#
# gen_cert.py written by <NAME> <http://hacklog.in/about>
# PDF 
# For details about this project please visit http://hacklog.in/peg.
#
# This work is licensed under a Creative Commons Attribution 3.0 Unported License.
# License details at http://creativecommons.org/licenses/by/3.0.
#

from pyPdf import PdfFileWriter, PdfFileReader
import StringIO
import os
import sys
from reportlab.pdfgen import canvas
from reportlab.lib.pagesizes import letter
from reportlab.lib.colors import PCMYKColor
from reportlab.pdfbase.pdfmetrics import stringWidth

#page_width = defaultPageSize[0]
#page_height = defaultPageSize[1]
packet = StringIO.StringIO()
# Create a new PDF with reportlab
attendee = sys.argv[1]
#attendee_width = stringWidth(attendee, "Times-Roman", 30)
gold = PCMYKColor(26,23,45,11)
can = canvas.Canvas(packet, pagesize=letter)
can.setFillColor(gold)
can.setFont("Times-Roman", 50)
# Specify the x,y coordinate for attendee name
can.drawCentredString(420, 225, attendee, mode=None)
# Specify Font size & coordinates for certificate number
black = PCMYKColor(0,0,0,61)
can.setFillColor(black)
can.setFont("Courier", 8)
can.drawString(668, 75, "Cert ID: 13-2gYNwts=", mode=None)
can.save()

# Move to the beginning of the StringIO buffer
packet.seek(0)
new_pdf = PdfFileReader(packet)

# Read existing PDF
existing_pdf = PdfFileReader(file("New.pdf", "rb"))
output = PdfFileWriter()

# Add new PDF
page = existing_pdf.getPage(0)
page.mergePage(new_pdf.getPage(0))
output.addPage(page)

# Write merged content to PDF
outputStream = file(attendee + ".pdf", "wb")
output.write(outputStream)
outputStream.close()

if os.path.isfile(attendee + ".pdf"):
    print attendee + ".pdf created"
else:
    print "Error encountered while creating " + attendee + ".pdf"<commit_msg>Added hash code<commit_after>#!/usr/bin/python
#
# gen_cert.py written by <NAME> <http://hacklog.in/about>
# PDF 
# For details about this project please visit http://hacklog.in/peg.
#
# This work is licensed under a Creative Commons Attribution 3.0 Unported License.
# License details at http://creativecommons.org/licenses/by/3.0.
#

from pyPdf import PdfFileWriter, PdfFileReader
import StringIO
import os
import sys
import base64
import haslib
from reportlab.pdfgen import canvas
from reportlab.lib.pagesizes import letter
from reportlab.lib.colors import PCMYKColor
from reportlab.pdfbase.pdfmetrics import stringWidth

#page_width = defaultPageSize[0]
#page_height = defaultPageSize[1]
packet = StringIO.StringIO()
# Create a new PDF with reportlab
attendee = sys.argv[1]
# Creating a certificate hash code
hasher = hashlib.md5(attendee)
certID = base64.urlsafe_b64encode(hasher.digest()[0:5])
# attendee_width = stringWidth(attendee, "Times-Roman", 30)
gold = PCMYKColor(26,23,45,11)
can = canvas.Canvas(packet, pagesize=letter)
can.setFillColor(gold)
can.setFont("Times-Roman", 50)
# Specify the x,y coordinate for attendee name
can.drawCentredString(420, 225, attendee, mode=None)
# Specify Font size & coordinates for certificate number
black = PCMYKColor(0,0,0,61)
can.setFillColor(black)
can.setFont("Courier", 8)
can.drawString(668, 75, "Cert ID: 13-"+certID, mode=None)
can.save()

# Move to the beginning of the StringIO buffer
packet.seek(0)
new_pdf = PdfFileReader(packet)

# Read existing PDF
existing_pdf = PdfFileReader(file("New.pdf", "rb"))
output = PdfFileWriter()

# Add new PDF
page = existing_pdf.getPage(0)
page.mergePage(new_pdf.getPage(0))
output.addPage(page)

# Write merged content to PDF
outputStream = file(attendee + ".pdf", "wb")
output.write(outputStream)
outputStream.close()

if os.path.isfile(attendee + ".pdf"):
    print attendee + ".pdf created"
else:
    print "Error encountered while creating " + attendee + ".pdf"
{'fraction_non_alphanumeric': 0.11756900212314225, 'fraction_numerical': 0.024416135881104035, 'mean_word_length': 5.62390158172232, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4838075', 'n_tokens_mistral': 1324, 'n_tokens_neox': 1265, 'n_words': 346}