Tuesday, November 12, 2013

JavaScript intresting links

Miscellaneous:

D3.js:

Datatables:

Django interesting links

Initialization tutorials:
  • TangoWithDjango. Fantastic tutorial that explains how to build a web site with Django 1.5.4 as a backend and Twitter Bootstrap as a frontend.
  • Django tutorial in four steps six steps (wow! Now there is a part introducing tests and another about static files management). The manual of the official django webpage. As the whole framework, the tutorial is excellent.

Miscellaneous:

Wednesday, October 23, 2013

Using git

Some useful commands when using git

Make a commit:
git add *
git commit -m "message"
git push origin master

Recover the state (be careful, overrides local changes!):
git reset --hard HEAD
git clean -f -d
git pull origin master

Delete on the repository the local deleted files:
(from http://stackoverflow.com/questions/1402776/how-do-i-commit-all-deleted-files-in-git)


Using the ndv3.js library

nvd3.js is an amazing d3 charts library.

However, it has few documentation in its website. In this post I put a summary of the useful things I've done when working with nvd3.
  • Integrating nvd3 with Django
django-nvd3 is a Django package which integrates nvd3 charts in a Django-Pythonic way. It also lacks a bit of documentation.

In this site there is the source code  of the package, what allows us to see the possible parametrizations of the chart:

def load_chart(chart_type, series, container, x_is_date=False, x_axis_date_format="%d %b %Y", tag_script_js=True, color_category='category20'):

The variable color category is the way to specify the colors range of the chart. However, in my case I had to specify its values in the javascript code instead of doing it directly in Python.

...
(javascript)
var mycolors = ["#80B898","#007030","#E58A01"];
d3.scale.mycolors = function() {
    return d3.scale.ordinal().range(mycolors);
}

(end javascript)

{% load_chart grafico.charttype grafico.chartdata "grafico_container" True "%d %b %Y" color_category='mycolors' %}
...


  • Customizing more nvd3.js charts
If you want further customization on nvd3.js charts then you have to move completely to the js environment. Some useful links I used:

Event trigger when  a serie is selected

Brush extent when working with a line with focus chart

Updating different d3 charts on the same page

Sunday, June 2, 2013

How to add a Gmail account with double step verification to an Android phone

It is a bit tricky. When you are asked to write the password, it is not your account password. You must specify a password which is unique for the Android application. It is well explained here:

http://alleged.org.uk/pdc/2012/11/29.html

Wednesday, May 8, 2013

CSS - Utilities

  • How to make an horizontal list. Very well explained. Step by step: 
http://css.maxdesign.com.au/listutorial/horizontal_master.htm

  • Resolution order in CSS
http://www.boogiejack.com/CSS_4.html
http://www.webteacher.ws/2010/08/26/resolving-conflicts-in-css/
http://www.webteacher.ws/2008/05/19/tip-calculate-the-specificity-of-css-selectors/

  • id vs class
http://stackoverflow.com/questions/970730/css-id-vs-class
http://stackoverflow.com/questions/544010/css-div-id-vs-div-class

  • 3 column liquid layout
http://alistapart.com/article/holygrail
http://matthewjamestaylor.com/blog/perfect-3-column.htm

  • How to float divs
http://stackoverflow.com/questions/2156712/how-to-float-3-divs-side-by-side-using-css



Apart from these utilities, recently I found "the collection", the most popular set of utlities for the front end desig: Twitter Bootstrap. Twitter Bootstrap is a free collection of tools for creating websites and web applications (HTML, CSS, and JavaScript toolkit). It contains HTML and CSS-based design templates for typography, forms, buttons, charts, navigation and other interface components, as well as optional JavaScript extensions. It is the most popular project in GitHub and is used by NASA and MSNBC among others.

http://twitter.github.io/bootstrap/

Wednesday, January 2, 2013

Galaxy Ace - Boot sounds

To manage the start up and shut down sounds on a Samsung Galaxy Ace device, you must change the following files (with a root admin file manager application, like TotalCommander):
  • Start up: /system/etc/poweron.ogg
  • Shut down: /system/media/audio/ui/sh­utdown.ogg
Info here: http://www.youtube.com/watch?v=affvUhk9P1g

Monday, December 24, 2012

Install and configure Trac in alwaysdata.com web site

I followed this steps to install Trac in the alwaysdata.com web site:

The main manual is from this page:

http://forum.alwaysdata.com/viewtopic.php?pid=3218#p3218

PYTHONPATH=~/modules easy_install-2.5 --install-dir ~/modules Genshi==0.6
PYTHONPATH=~/modules easy_install-2.5 --install-dir ~/modules Trac==1.0
./trac-admin /home//www/trac/myproject initenv
./trac-admin /home//www/trac/myproject deploy /tmp/deploy 
mv /tmp/deploy/* /home//www/trac
 
Section 5: Small modification
#!/usr/bin/eval PYTHONPATH=/home//modules TRAC_ENV=/home//www/trac/myproject python

Section 6: Small modification
AddHandler fcgid-script .fcgi

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ cgi-bin/trac.fcgi/$1 [QSA,L] 

I also had to solve some issues reported here:
http://forum.alwaysdata.com/viewtopic.php?id=1601

To configure Trac authentication (Trac works with apache authentication) I followed:
http://trac.edgewall.org/wiki/TracModWSGI#ConfiguringAuthentication

$ htpasswd -c /somewhere/trac.htpasswd admin
New password: 
Re-type new password: 
Adding password for user admin


$ htpasswd /somewhere/trac.htpasswd john
New password: 
Re-type new password: 
Adding password for user john

The final .htaccess file is the following:
AddHandler fcgid-script .fcgi
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ cgi-bin/trac.fcgi/$1 [QSA,L]

    AuthType Basic
    AuthName "trac"
    AuthUserFile /home//www/trac/trac.htpasswd
    Require valid-user

Sunday, November 25, 2012

Accents in javascripts

In the following link, we can see the codes we have to use to put accents and special characters in javascripts:

http://www.pjb.com.au/comp/diacritics.html

It is extremely easy and useful.

Friday, October 12, 2012

Map-Reduce implementation in Python

Recently I discovered a Python implementation of the Map-Reduce framework.
It is mincemeat.py, and can be found here: https://github.com/michaelfairley/mincemeatpy
The advantage is that it is an only-file implementation and it is quite efficient.
There is an example attached with the downloaded file.
To run it, you need just to execute example.py, which will perform the server tasks.
For each client, just run mincemeat.py specifying the server port (127.0.0.1 by default).

Other implementations of the Map-Reduce pattern in python are:

octopy
hadoopy
dino
mrjob

Sunday, September 30, 2012

Django - User authentication with django-registration

http://stackoverflow.com/questions/6127264/newbie-django-error-templatedoesnotexist-at-accounts-login

https://bitbucket.org/devdoodles/registration_templates/src

Friday, September 28, 2012

NoSQL and MapReduce

NoSQL is a wide variety of database systems that differ of the classical RDBMS based on SQL.

MapReduce is a framework that provides high performance in solving problems in a parallel way of computers, servers, clusters...

Here there is an interesting presentation about NoSQL and MapReduce: http://www.slideshare.net/j_singh/nosql-and-mapreduce

And here a popular NoSQL Databases web page: http://nosql-database.org/

The CAP theorem says that, for a distributed system, it is impossible to simultaneously provide the following guarantees:
  • Consistency
  • Availability
  • Partition tolerance

Sunday, August 5, 2012

Agile methodologies and Rails

I have found a very interesting online course called Software as a Service in which you are introduced to agile methodologies and Rails programming.

It can be followed here: https://www.coursera.org/courses

Here there is information about the course book and other important information (the assignments are thought to be done working in a virtual machine, which is available there also): http://beta.saasbook.info/bookware-vm-instructions

Thursday, June 14, 2012

What is big data?

The best definition I've found in the net:

Big Data is a term used to describe large collections of data (also known as datasets) that may be unstructured, and grow so large and quickly that it is difficult to manage with regular database or statistics tools.