Skip to content

Instantly share code, notes, and snippets.

View luanfonceca's full-sized avatar

Luan Fonseca luanfonceca

View GitHub Profile
import unittest
class SimplestCase(unittest.TestCase):
def test_simple(self):
self.assertEqual(1 + 1, 2)
if __name__ == '__main__':
unittest.main()
@luanfonceca
luanfonceca / concat_pdf.py
Created October 7, 2013 02:46
Python code to concatenate PDF files, just keep them ordered by name, like pdf_01, pdf_02, pdf_10...
from pyPdf import PdfFileWriter, PdfFileReader
import os
def append_pdf(input, output):
[output.addPage(input.getPage(page_num)) \
for page_num in range(input.numPages)]
output = PdfFileWriter()
for pdf in filter(lambda x: '.pdf' in x, os.listdir('.')):
append_pdf(PdfFileReader(file(pdf, "rb")), output)
@luanfonceca
luanfonceca / gist:6736358
Created September 27, 2013 22:54
Algoritmo de Euclides em Python.
def rmdc(a, b):
return b and rmdc(b, a%b) or a
def mdc(a, b):
while a:
a, b = b%a, a
return b
if __name__ == '__main__':
a = input("Informe o primeiro valor: ")
@luanfonceca
luanfonceca / print_yourself
Created April 15, 2013 23:05
Desafio Python Nordeste Programa que imprime a sí mesmo.
import inspect as i;print i.stack()[0][4][0]
@luanfonceca
luanfonceca / .gitignore
Created October 15, 2012 18:38 — forked from iuridiniz/.gitignore
Django Tests with dynamic fields in hstore
*.pyc
.project
.pydevproject