<$BlogRSDUrl$>

digitalfredy log

software libre. electronica, audio, video, ingenieria, ... en fin este es mi log dedicado a la tecnologia "que bacano que es ser cacharrero"

martes, mayo 23, 2017

Python: Exception Handling and Object Serialization 

This is my homework #7 for my UW Python course,

To handle exceptions in python we use try - except, in my case I'm using it to handle:

Pickle is used for Object Serialization, in our case loading/dumping a dictionary in a file. 

In additional I learn pprint to get a more clean dictionary printing. 

I tried to document all in my code then I'm posting it here:


#!/usr/bin/python

# Pickle: https://docs.python.org/2/library/pickle.html
# Pickle examples: https://wiki.python.org/moin/UsingPickle
import pickle
# Data pretty printer https://docs.python.org/2/library/pprint.html
import pprint

filename = "inventory.bin"

print "Assignment07 by Fredy Pulido-Lopez"
# Based on Assignement04 I did using try except 

print  "Importig and printing data from ",filename
# Exception handler to take care if the file is not present
try:
  with open (filename,'rb') as file:
      dictionary = pickle.load(file)
      pprint.pprint(dictionary)
except IOError:
  print "ERROR: Failed loading (IOError) ",filename,", starting from scratch"
  # No file loaded then i'm creating my dictionary here
  dictionary = []

print "############## Inventory composer ##############"

print "WARNING: Ctl+c will write ",filename," file."
# Exception handler, close and save when Ctl+c send a KeyboardInterrupt signal
try:
    # Infinite loop to feed the inventory in memory:
    while True:
        item = raw_input("Item   : "),
        value = raw_input("Value  : "),
        dictionary.append({'item': item, 'value': value})
except KeyboardInterrupt:
    print "\nWriting inventory in ",filename

# After the exception the loop is done and we have a feeded dictionary in memory
# Now we will save our dictionary in a file called inventory.txt 
with open (filename,'w') as file:
    pickle.dump(dictionary,file,-1)

posted by digitalfredy  # 12:23 a. m.

lunes, febrero 11, 2013

Prueba video amara (universalsubtitles): 

En wordpress no funciona, pero en blogger si?

posted by digitalfredy  # 10:02 a. m.

viernes, enero 06, 2012

Defender Internet 

Hola todos

El mundo está cambiando fuertemente como cuando apareció la imprenta y
el motor de este cambio es Internet, desafortunadamente la red está
siendo atacada de forma directa, usando como caballo de trolla la
industria del copy rigth, es tan grave que en protesta Google, Amazon,
Mozilla, Twitter, Linkedin y otros han optado por algo que se ha
denomidando la opción nuclear:

http://alt1040.com/2012/01/opcion-nuclear-el-23-de-enero-google-podria-desconectar-la-red-contra-sopa

Y yo creo que todo el mundo se pregunta que puede hacer, bueno lo más
fácil es hacer una firma en linea, OJO: bajen y encuentren la sección
"Not in the us? Petition the state department"

http://americancensorship.org/

Donar dinero a mozilla que está haciendo una fuertre campaña:

https://donate.mozilla.org/page/s/commit-to-call-pipa

Finalmente sería bueno que el 22 y 23 de enero impriman una hoja, o
cientos de ellas y la cargen visible para hacer publicidad, una imagen
como esta es buena:
http://cdn.digitaltrends.com/wp-content/uploads/2011/11/stop-sopa-pipa.png

posted by digitalfredy  # 10:26 a. m.

martes, diciembre 27, 2011

Formulario de contacto wordpress 

Estoy haciendo el sitio de la real y para el tema del formulario de contacto gasté un buen tiempo, finalmente elegí Administrador de formularios hecho por Campbell Hoffman.

Pero hice un cambio en /wp-content/plugins/wordpress-form-manager/css/style.css para que el botón enviar quedara debajo del rechaptcha:

.fm-form input.submit{
float:left;
margin-left:430px;
}

Para dshabilitar los comentarios en las páginas instalé Disable Comments de Samir Shah.

Etiquetas: , ,


posted by digitalfredy  # 7:05 p. m.

sábado, diciembre 24, 2011

Imagenes slider custom community wordpress 

Estoy usando este excelente tema para la página de La Real Acacemia del Sonido y uno de los problemas que yo tenia era con las imágenes de fondo por que las subia de un tamaño y las mostraba de otro (recortadas) y la solución está en la documentación:


Slideshow -> 3. Getting the images adjusted:


Default size of the big image in the slideshow: 756x250px, but the image should be bigger than 756x567px.


Why? When you create your feature image, you have to keep in mind that it will be displayed at 756 x 250. That is the big image you have in your slideshow. However, doing this, will cut your image on the small preview-menu in the slideshow.


Best is to create images at 756 x 567. This will keep the 4:3 ratio in the menu, and your image will be displayed as usual. You just have to center what you want to be in the big image on the slideshow.

Etiquetas: , ,


posted by digitalfredy  # 12:19 p. m.

viernes, agosto 26, 2011

Fiesta despedida 

Fiesta de despedida hoy viernes 9pm en la 7a con 47 BOG/Col, bar capella y Sábado a las 7pm aeropuerto. Abrazos

posted by digitalfredy  # 12:37 a. m.

domingo, junio 26, 2011

Idea for easy tag files whitout creating new filesystem 

Tenía esto por hay y bueno mejor publicarlo ...

Only autorization for use this idea in open source software:

I am a organized person, and much much time i try have my files organiced but have problems becouse for example one criteria for organization can to be the tipe of files (music, images, pictures ...), the type of file (.html, .odt, .ogg ...), other will be the year, the site (University, work) the type of acces (share, private ...).

In UNIX and UNIX type operative systema every file have one inodo and by inode you have minimal one hard link, in the hard link you have the name of the file.

My idea for tag files is very siple:

i develop my idea whit a example script:
1- creating "special" directory called tags and "special" subdirectory with the tag name
2- make a hard link of the file in the tag directory

digitalfredy@debian $ cat /usr/local/bin/tagfile
#!/bin/sh
# $1 is the file and $2 is the tag
mkdir -p $HOME/tags/$2
ln $1 $HOME/tags/$2/


You like see the files in a tag? use ls /tags/$TAG

Los sistemas operativos POSIX siempre han tenido soporte para tags, si, un tag es una carpeta en la cual hay enlaces duros que son un nombre para un inodo y el inodo es el que nos dice donde está el archivo

El problema es la forma en que accedemos y visualizamos el sistema de archivos, el problema es la falta de herramientas que nos permitan acceder el sistema de archivos usando una filosofía diferente al arbol de archivos

Ejemplo comando tag
tag operandos
operandos: archivo1 archivoN tag1 tagN

Pending: you can go to tags and find the files but not know how to show the tags of a file (show the hardlinks of a file)

posted by digitalfredy  # 5:15 p. m.

Archives

01/01/2004 - 02/01/2004   03/01/2004 - 04/01/2004   09/01/2004 - 10/01/2004   10/01/2004 - 11/01/2004   12/01/2004 - 01/01/2005   01/01/2006 - 02/01/2006   02/01/2006 - 03/01/2006   03/01/2006 - 04/01/2006   04/01/2006 - 05/01/2006   05/01/2006 - 06/01/2006   06/01/2006 - 07/01/2006   08/01/2006 - 09/01/2006   09/01/2008 - 10/01/2008   11/01/2008 - 12/01/2008   12/01/2008 - 01/01/2009   01/01/2009 - 02/01/2009   04/01/2009 - 05/01/2009   05/01/2009 - 06/01/2009   06/01/2009 - 07/01/2009   07/01/2009 - 08/01/2009   09/01/2009 - 10/01/2009   10/01/2009 - 11/01/2009   11/01/2009 - 12/01/2009   12/01/2009 - 01/01/2010   01/01/2010 - 02/01/2010   02/01/2010 - 03/01/2010   03/01/2010 - 04/01/2010   05/01/2010 - 06/01/2010   06/01/2010 - 07/01/2010   07/01/2010 - 08/01/2010   08/01/2010 - 09/01/2010   09/01/2010 - 10/01/2010   11/01/2010 - 12/01/2010   06/01/2011 - 07/01/2011   08/01/2011 - 09/01/2011   12/01/2011 - 01/01/2012   01/01/2012 - 02/01/2012   02/01/2013 - 03/01/2013   05/01/2017 - 06/01/2017  

This page is powered by Blogger. Isn't yours?