Skip to content

Instantly share code, notes, and snippets.

View victordomingos's full-sized avatar

Victor Domingos victordomingos

View GitHub Profile
@Lordshell
Lordshell / 1_pdf.py
Created February 18, 2019 22:35 — forked from philfreo/1_pdf.py
Three ways to make a PDF from HTML in Python (preferred is weasyprint or phantomjs)
def render_pdf_weasyprint(html):
from weasyprint import HTML
pdf = HTML(string=html.encode('utf-8'))
return pdf.write_pdf()
def render_pdf_xhtml2pdf(html):
"""mimerender helper to render a PDF from HTML using xhtml2pdf.
Usage: http://philfreo.com/blog/render-a-pdf-from-html-using-xhtml2pdf-and-mimerender-in-flask/
"""
@alchemyst
alchemyst / spreadsheet.py
Created December 18, 2017 13:41
Spreadsheet in 100 lines of Python
#!/usr/bin/env python
import tkinter as tk
import math
import re
from collections import ChainMap
Nrows = 5
Ncols = 5
@Moving-Electrons
Moving-Electrons / bear_to_pelican.py
Last active January 8, 2019 00:15
Python 3 script for exporting Bear App documents to Pelican Site Generator. The script takes a zip file (argument) containing the exported files in Markdown format from Bear App (i.e. MD file and images), reformats the MD adequately and moves the files to Pelican content folders. More information on www.movingelectrons.net
import sys
import re
import os
import zipfile
import shutil
# Constant Definition
# -------------------
# Path to be prepended to image links in markdown file, like so: ![](IMAGE_LINK<image_filename>).
@thebostik
thebostik / dynamic_quality.py
Created May 30, 2017 22:02
Python Dynamic Image Quality Example
import cStringIO
import PIL.Image
from ssim import compute_ssim
def get_ssim_at_quality(photo, quality):
"""Return the ssim for this JPEG image saved at the specified quality"""
ssim_photo = cStringIO.StringIO()
# optimize is omitted here as it doesn't affect
# quality but requires additional memory and cpu
@Moving-Electrons
Moving-Electrons / pelican_injection-gist.py
Last active March 20, 2018 10:41
Python 3.5 script for processing files exported from Ulysses in either .md format or .zip format (including images) to be used on Pelican static site generator. The script inserts HTML code, moves images to the appropriate folders in Pelican and expands markdown image links accordingly. Visit www.movingelectrons.net for more info.
import sys
import re
import os
import zipfile
import shutil
# Constant Definition
# -------------------
@victordomingos
victordomingos / autocomplete.py
Last active May 4, 2016 15:48 — forked from ian-weisser/autocomplete.py
Python3 tkinter text entry widget with built-in autocompletion class, with working example (revised version)
#!/usr/bin/python3
"""
tkentrycomplete.py
A tkinter widget that features autocompletion.
Created by Mitja Martini on 2008-11-29.
Converted to Python3 by Ian weisser on 2014-04-06.
Edited by Victor Domingos on 2016-04-25.
@ian-weisser
ian-weisser / autocomplete.py
Created April 7, 2014 00:33
Python3 tkinter text entry widget with built-in autocompletion class,, with working example
#!/usr/bin/python3
"""
tkentrycomplete.py
A tkinter widget that features autocompletion.
Created by Mitja Martini on 2008-11-29.
Converted to Python3 by Ian weisser on 2014-04-06.
"""
@rcruz63
rcruz63 / Cards.py
Created March 19, 2013 10:37
Pythonista Scripts
# Card Game
#
# In this game, you have to find matching pairs of cards.
# This scene consists entirely of layers and demonstrates some
# interesting animation techniques.
from scene import *
from random import shuffle
from functools import partial
import sound
@alchemyst
alchemyst / pull.py
Created January 28, 2012 18:30
Scrape timetable webpage
#!/usr/bin/env python
import BeautifulSoup
import mechanize
import csv
import sys
import logging
logging.basicConfig(level=logging.INFO)
headers = ["ModuleName", "Group", "Language", "Activity", "ING", "YearPhase",