Saturday, December 3, 2011

Front end automation + tricks + tools in Django

Very interesting presentation:

http://www.slideshare.net/evanreiser/font-end-development-automation-with-django

More than 50 cheat sheets for web projects and other programming languages

In this page we can find a fantastic recopilation of cheat sheets for distinct programming languages and web specifications.

http://eomblog.blogspot.com/2011/11/57-estupendas-chuleta-cheat-sheets.html

The full blog is interesting, so we add the url of it.

http://eomblog.blogspot.com/

Thank you to the author for sharing all this information!

Friday, November 11, 2011

Django - Context Processors

In some occasions we may need information available to each template, like the user properties, the session settings, or an special variable.

What we could do is to add all this information to the response dictionary. However, it would contradict the DRY principle of Django.

A good approach is to use a customized Context Processor, which will add to the dictionary the returned variables of the function.

Specifically, the modifications we must do can be the following:

  • Define the Context Processor function, like for example:
def context_processor_function(request):
return {'additional_values': ['a','b','c']}

  • Load the function inside the TEMPLATE_CONTEXT_PROCESSORS variable of the setting.py:
TEMPLATE_CONTEXT_PROCESSORS = ("django.core.context_processors.auth",
...
"path_to_context_processor_function.context_processor_function
",)
  • Use the variables inside the templates like any other variables of the dictionary
For more complete information, this links are useful:

http://www.b-list.org/weblog/2006/jun/14/django-tips-template-context-processors/

https://docs.djangoproject.com/en/1.1/ref/settings/#std:setting-TEMPLATE_CONTEXT_PROCESSORS

http://stackoverflow.com/questions/335231/in-django-is-it-possible-to-access-the-current-user-session-from-within-a-custo

Saturday, October 1, 2011

Python - C++ like stream input

One of the things in which C++ is better than Python is in the stream input, using the fantastic cin option.

In this link there are similar ways to do the same with Python

http://stackoverflow.com/questions/417703/python-c-like-stream-input

Friday, September 23, 2011

Iterating through two lists in a Django template

http://stackoverflow.com/questions/2415865/iterating-through-two-lists-in-django-templates

Access array elements in a Django template

http://stackoverflow.com/questions/1700661/access-array-elements-in-a-django-template


Remember that the dot notation in a Django template is used for four different notations in Python. In a template, foo.bar can mean any of:

foo[bar] # dictionary lookup
foo.bar # attribute lookup
foo.bar() # method call
foo[bar] # list-index lookup

Thursday, July 14, 2011

Saturday, June 4, 2011

Latex - How to change text properties of captions

There is related information here:

http://en.wikibooks.org/wiki/LaTeX/Floats,_Figures_and_Captions#Caption_Styles

Thursday, March 31, 2011

Gnuplot: save plot in jpeg

This are some useful commands:

set terminal jpeg

set output "fig.jpeg"

replot

set terminal x11

Friday, March 25, 2011

Log scale in gnuplot plots

The corresponding command is:

set log xy

Monday, January 17, 2011

Very important commands in Gnuplot

Plot two or more plots in the same window:

set multiplot

Plots with lines:

plot "file.dat" w l

Plot with yerrorbars. The third column of the input data is the lenght of the errorbar:

plot "file.dat" with errorbars

Hide the legend:

unset key