EPUB publishing

ton of different formats:

.aeh (used by Archos eReaders)
.lrx (used by Sony eReaders)
.ibooks (used by Apple eReaders)
.pkg (used by Newton eReaders)
.mobi (used by Amazon Kindle eReaders)
.epub (used by just about everyone else, including Barnes & Noble NOOK eReaders)

There are actually even more formats than those. That’s just a small sample. So, which one should you make?

Well, the only formats you need to create are EPUB and MOBI. Forget the others. EPUB is quickly becoming the industry standard and 90% of the eReaders on the market can open EPUB files. There is also a very simple conversion tool to change your EPUB into a MOBI. So, you really only need to make an EPUB, convert it to MOBI, and your book will be accessible on 99% of the eReaders out there, including NOOK and Kindle.

 


Build a digital book with EPUB

The open XML-based eBook format

Need to distribute documentation, create an eBook, or just archive your favorite blog posts? EPUB is an open specification for digital books based on familiar technologies like XML, CSS, and XHTML, and EPUB files can be read on portable e-ink devices, mobile phones, and desktop computers. This tutorial explains the EPUB format in detail, demonstrates EPUB validation using Java technology, and moves step-by-step through automating EPUB creation using DocBook and Python.


EPUB (short for electronic publication) is a free and open e-book standard by the International Digital Publishing Forum (IDPF). Files have the extension .epub.

Continue reading “EPUB publishing”

TDD by Example con Python 3

Después de leer Test Driven Development- By Example (Addison-Wesley Signature Series) me quedo un sensación mixta de intranquilidad. Seguí los ejemplos del libro, la primera…

Después de leer Test Driven Development- By Example (Addison-Wesley Signature Series) me quedo un sensación mixta de intranquilidad. Seguí los ejemplos del libro, la primera parte usando C#; aunque el libro usa Java y la segunda parte con Python 3.1, haciendo algunas adecuaciones al código del libro. De hecho, primero lo

The Eric Python IDE

Eric is a full featured Python and Ruby editor and IDE, written in python. It is based on the cross platform Qt gui toolkit, integrating the highly flexible Scintilla editor control. It is designed to be usable as everdays’ quick and dirty editor as well as being usable as a professional project management tool integrating many advanced features Python offers the professional coder. eric4 includes a plugin system, which allows easy extension of the IDE functionality with plugins downloadable from the net.

Current stable versions are eric4 based on Qt4 and Python 2 and eric5 based on Python 3 and Qt4.


http://ubuntuforums.org/showthread.php?t=1601218
sudo apt-get install libqt4-dev
install python3.2-dev (sudo apt-get install python3.2-dev)
Use Synaptic or Download it from here: http://www.riverbankcomputing.co.uk
1) build/install qscintilla
2) build/install sip
3) build/install PyQt
Python 3.2.3
Qt 4.8.1
PyQt 4.9.1
QScintilla 2.6.1


Python from Scratch

TDD by Example con Python 3

Después de leer Test Driven Development- By Example (Addison-Wesley Signature Series) me quedo un sensación mixta de intranquilidad.

Seguí los ejemplos del libro, la primera parte usando C#; aunque el libro usa Java y la segunda parte con Python 3.1, haciendo algunas adecuaciones al código del libro. De hecho, primero lo intente con IronPython para seguir con el tema de .Net, pero con Python 3.1 y IDLE me fue más fácil hacer trabajar el código.

TDD es una técnica avanzada que en su expresión ortodoxa no es seguida ni por el mismo Beck. Es fácil caer en callejones sin salida y el desarrollador debe tener un plan top-down  implícito basado en su experiencia y dominio técnico. Por otro lado su aceptación y referencias de éxito son evidencia de su validez.

La primera parte del libro me pareció incompleta, llena de manitas de puerco, visión nocturna, multiplicaciones por el número que pensaste, y conjuros de magia negra.

la segunda parte es de más alto nivel de abstracción pero muestra claramente los fundamentos del marco de xUnit. El uso de Python aquí parece apropiado ya que permite desarrollar la estructura básica de xUnit de manera clara y directa.

En resumen, Test Driven Development- By Example es un buen libro para desarrolladores expertos.

Referencias

Test Driven Development- By Example (Addison-Wesley Signature Series)

http://dinsdale.python.org/dev/peps/pep-0008/

http://docs.python.org/3.1/tutorial/index.html

http://www.python.org/

http://www.swaroopch.com/notes/Python

http://www.wrox.com/WileyCDA/

http://www.wrox.com/WileyCDA/Section/Browse-Titles-for-Code-Downloads.id-105127.html

http://www.wrox.com/WileyCDA/WroxTitle/Python-Create-Modify-Reuse.productCd-0470259329,descCd-DOWNLOAD.html

http://pybites.blogspot.com/

null nil

Language null true false
Java null true false
Python None True False
Objective-C nil, or NULL, or [NSNull null],
depending on context
YES NO
C NULL anything except 0 0
Lisp NIL T NIL

Objective-C is psychotic. It’s a Smalltalk dialect built on top of C (and for the most part, it got the good bits of both and left out the bad bits). Obj-C lets you instantiate arrays like [NSArray arrayWithObjects:@"Hello", @"World", nil], using nil as an end-of-array marker because C’s varargs implementation doesn’t know how many args you passed. So it has this extra “null” object that’s not really null.

extended traceback printer

The standard Python traceback module provides very useful functions to produce useful information about where and why an error occurred. Traceback objects actually contain a great deal more information than the traceback module displays, however. That information can greatly assist in detecting the cause of your error.

There is a Python recipe that, while not an interactive debugger, makes it easier to debug Python scripts within SciTE.

Here’s an example of an extended traceback printer you might use, followed by a usage example.

import sys,traceback
defprint_exc_plus():
    “””
    Print the usual traceback information, followed by a listing of all the
    local variables in each frame.
    “””
    tb=sys.exc_info()[2]
    stack=[]
    
    whiletb:
        stack.append(tb.tb_frame)
        tb=tb.tb_next
    traceback.print_exc()
    print“Locals by frame, innermost last”
    forframeinstack:
        print
        print“Frame %s in %s at line %s”%(frame.f_code.co_name,
                                             frame.f_code.co_filename,
                                             frame.f_lineno)
        forkey,valueinframe.f_locals.items():
            print“t%20s = “%key,
            #We have to be careful not to cause a new error in our error
            #printer! Calling str() on an unknown object could cause an
            #error we don’t want.
            try:                   
                printvalue
            except:
                print“<ERROR WHILE PRINTING VALUE>”
        
try:
        iflen(sys.argv)>1:
                length=len(sys.argv)
                foriinrange(1,length):       
                        sys.argv[i1]=sys.argv[i]
                delsys.argv[length1]
                execfile(sys.argv[0])
except:
        print_exc_plus()

La aritmética de Trachtenberg

Así como Viktor Emil Frankl desarrollo la logoterapia para superar los rigores de los campos de concentración Nazi, Jakow Trachtenberg ocupo su mente en desarrollar un sistema de aritmética mental al verse en la misma situación.

El sistema Trachtenberg de rápido cálculo mental, similar a las matemáticas Védicas, consiste en un conjunto de patrones para realizar operaciones aritméticas. Los algoritmos más importantes son multiplicación,división, y adición. El método también incluye algoritmos especializados para realizar multiplicaciones por números entre 5 y 13.

Multiplicación por 11

Abusando de la notación

(11)a = 11Σai10i =

an10n+1 + [Σj=0n-1(aj+aj+1)10j ]+ a0

Multiplicación por 12

(12)a = 12Σai10i =

an10n+1 + [Σj=0n-1 (aj+2aj+1)10j ]+ 2a0

Multiplicación por 6

Definiendo

bj = aj/2, donde / denota división entera

cj = aj mod 2

tenemos

aj = 2bj + cj

(6)a = (10/2)Σai10i  + Σai10i =

Σbi10i+1 + Σ(ai + 5ci)10i

bn10n+1 + [Σj=1n(aj + 5cj + bj-1)10j ]+ (a0 + 5c0)

Expresando el algoritmo en python:

def x6(number):
previous = 0
result = 0
power_of_10 = 1
while (number):
digit = number%10
odd_term = 5 if digit%2 else 0
result =
(digit + odd_term + previous ) *
power_of_10 + result
previous = digit//2
power_of_10 *= 10
number = number // 10
result = previous * power_of_10 + result
return result

Multiplicación por 7

De manera similar al caso anterior:

aj = 2bj + cj

(7)a = (10/2)Σai10i  + Σ2ai10i =

Σbi10i+1 + Σ(2ai + 5ci)10i

bn10n+1 + [Σj=1n(2aj + 5cj + bj-1)10j ]+ (a0 + 5c0)

Expresando el algoritmo en python:

def x7(number):
previous = 0
result = 0
power_of_10 = 1
while (number):
digit = number%10
odd_term = 5 if digit%2 else 0
result =
(2*digit + odd_term + previous ) *
power_of_10 + result
previous = digit//2
power_of_10 *= 10
number = number // 10
result = previous * power_of_10 + result
return result

Multiplicación por 5

De manera similar al caso anterior:

aj = 2bj + cj

(5)a = (10/2)Σai10i   =

Σbi10i+1 + Σ(5ci)10i

bn 10n+1 + [Σj=1n(5cj + bj-1)10j ]+ (5c0)

Expresando el algoritmo en python:

def x5(number):
previous = 0
result = 0
power_of_10 = 1
while (number):
digit = number%10
odd_term = 5 if digit%2 else 0
result =
(odd_term + previous ) *
power_of_10 + result
previous = digit//2
power_of_10 *= 10
number = number // 10
result = previous * power_of_10 + result
return result

Multiplicación por 9

Definiendo

b = 10n+1 – Σj=0naj , o sea el complemento a 10 de a

tenemos

(9)a = 10a –a =

10a –a + b – b =

10a + b – 10n+1 =

(an – 1)10n+1 + [Σj=1n(bj + aj-1)10j ]+ (b0 )

Expresando el algoritmo en python:

def x9(number):
previous = number%10
result = 10 - previous
power_of_10 = 10
number = number // 10
while (number):
digit = number%10
result =
(9 - digit + previous ) *
power_of_10 + result
previous = digit
power_of_10 *= 10
number = number // 10
result =
(previous-1) * power_of_10 +
result
return result

Multiplicación por 8

Definiendo

b = 10n+1 – Σj=0naj , o sea el complemento a 10 de a

tenemos

(8)a = 10a –2a =

10a –2a +2 b – 2b =

10a + 2b – (2)10n+1 =

(an – 2)10n+1 + [Σj=1n(2bj + aj-1)10j ]+ (2b0 )

Expresando el algoritmo en python:

def x8(number):
previous = number%10
result = 2*(10 - previous)
power_of_10 = 10
number = number // 10
while (number):
digit = number%10
result =
(2*(9 - digit) + previous ) *
power_of_10 + result
previous = digit
power_of_10 *= 10
number = number // 10
result =
(previous-2) *
power_of_10 + result
return result

Multiplicación por 3 y por 4

Los algoritmos para multiplicar por 3 y por 4 combinan las ideas usadas en la multiplicación por 5 y por 9.

Definiendo

b = 10n+1 – Σj=0naj , o sea el complemento a 10 de a

ai = 2ci + di, donde

ci = ai/2

di = ai mod 2

tenemos

(4)a = 5a –a =

10c + 5d + b – 10n+1

(3)a = 5a –2a =

10c + + 5d + 2b – (2)10n+1

Expresando los algoritmos en python:

def x3(number):
digit = number%10
result = 2*(10 - digit)
if digit % 2:
result += 5
previous = digit // 2
power_of_10 = 10
number = number // 10
while (number):
digit = number%10
odd_term = 5 if digit%2 else 0
result +=(2*(9 - digit) + odd_term + previous ) * power_of_10
previous = digit//2
power_of_10 *= 10
number = number // 10
result = (previous-2) * power_of_10 + result
return result

def x4(number):
digit = number%10
result = (10 - digit)
if digit % 2:
result += 5
previous = digit // 2
power_of_10 = 10
number = number // 10
while (number):
digit = number%10
odd_term = 5 if digit%2 else 0
result +=((9 - digit) + odd_term + previous ) * power_of_10
previous = digit//2
power_of_10 *= 10
number = number // 10
result = (previous-1) * power_of_10 + result
return result

Referencias