Excelente video para sentarse a reflexionar un poco.
Open your .. mind, soul and source.
Excelente video para sentarse a reflexionar un poco.
So I came across the problem of needing to filter my Django ModelChoiceField queryset by a variable in my view. Specifically I needed to pass the current selected state to the ModelChoiceField queryset. The best way I found to do this is to initialize the form with my state var in the initial:
state = ‘OH’ form = LocationForm(initial={‘state’:state})After that, instead of creating the field the traditional way, you can append the field to the self.fields dictionary within the init, enabling you to pass the initial state variable into the queryset of the field. Here is my form:
class LocationForm(forms.Form): def __init__(self, *args, **kwargs): super(LocationForm, self).__init__(*args, **kwargs) self.fields.insert(len(self.fields)-1, ‘location’, forms.ModelChoiceField(queryset=Location.objects.filter(state=self.initial[‘state’]))) first_name = forms.CharField(50, label=«First Name») last_name = forms.CharField(50, label=«Last Name») address = forms.CharField(60, label=«Street Address») city = forms.CharField(40, label=«City») state = USStateField() zip = USZipCodeField()Self.fields is a Django SortedDict, and it’s insert method takes the index to insert to, the key, and the value.
De niños nos preguntaban ¿Qué es lo que querés ser cuando seas grande? Casi siempre las respuestas eran: astronauta, bombero, policía, médico, bailarina. Y ahora, que llegamos a grandes, ¿en qué nos convertimos?
Cuando miramos hacia atrás en la vida, podemos ver una gran cantidad de logros obtenidos, pero cuando observamos hacia el futuro, tratando de definir lo que queremos alcanzar, la visualización se torna nebulosa.
– See more at: http://administracioninteractiva.com/la-clave-del-exito-2/#sthash.omsfGJbE.dpuf
By Kevin Waterson
Converting an object to an array using PHP comes with a small gotcha. One would be forgiven for thinking it is merely a task of casting the object and the job can be completed with a single line of code. This works well for simple objects, however, the task increases in complexity in line with the objects complexity.
Consider the following object that is cast to an array.
<?php
/*** create an object ***/
$obj = new stdClass;
$obj->foo = 'foo';
$obj->bar = 'bar';
$obj->baz = 'baz';
/*** cast the object ***/
$array = (array) $obj;
/*** show the results ***/
print_r( $array );
?>
Shortcut | Description |
CTRL + P | go to file of your current project |
CTRL + ALT + P | go to project |
CTRL + R | go to methods |
CTRL + G | go to line |
CTRL + KB | toggle side bar |
CTRL + SHIFT + P | command prompt |
CTRL + SHIFT + N | new window (useful for new project) |
You can look a lot of more shortcuts here
http://docs.sublimetext.info/en/latest/reference/keyboard_shortcuts_win.html
Bueno ahora veremos como instalar redis en OpenSuse 12.3.
$ cd redis-2.6.14 $ make $ make test $ make install
Compruebe si la compilación se realizó correctamente.
# sudo cp redis.conf /etc/redis/redis.conf
Si el directorio no está disponible en / etc /, cree una carpeta llamada redis y copiar el archivo de configuración.
$ redis-server /etc/redis/redis.conf
#! /bin/sh ### BEGIN INIT INFO # Provides: redis-server # Required-Start: $syslog # Required-Stop: $syslog # Should-Start: $local_fs # Should-Stop: $local_fs # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: redis-server - Persistent key-value db # Description: redis-server - Persistent key-value db ### END INIT INFO PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin DAEMON=/usr/bin/redis-server DAEMON_ARGS=/etc/redis/redis.conf NAME=redis-server DESC=redis-server PIDFILE=/var/run/redis.pid test -x $DAEMON || exit 0 test -x $DAEMONBOOTSTRAP || exit 0 set -e case "$1" in start) echo -n "Starting $DESC: " touch $PIDFILE chown redis:redis $PIDFILE if start-stop-daemon --start --quiet --umask 007 --pidfile $PIDFILE --chuid redis:redis --exec $DAEMON -- $DAEMON_ARGS then echo "$NAME." else echo "failed" fi ;; stop) echo -n "Stopping $DESC: " if start-stop-daemon --stop --retry 10 --quiet --oknodo --pidfile $PIDFILE --exec $DAEMON then echo "$NAME." else echo "failed" fi rm -f $PIDFILE ;; restart|force-reload) ${0} stop ${0} start ;; *) echo "Usage: /etc/init.d/$NAME {start|stop|restart|force-reload}" >&2 exit 1 ;; esac exit 0
sudo /etc/init.d/redis-server start sudo /etc/init.d/redis-server stop
$ sudo /etc/init.d/redis-server start $ redis-cli
>set hello world OK
Getting “world” Value from “hello” Key:
>get hello “world”
http://www.arunchinnachamy.com/howto-install-latest-redis-version-2-4-17/
http://www.art-coder.com/2011/12/01/how-to-run-redis-server-as-daemon/
Despues de una actualizacion de OpenSUSE 12.3 a 13.1 me enconter con algun problemillas, como este:
Couldn't load library libmysqlclient_r.so: libmysqlclient_r.so: cannot open shared object file: No such file or directory Solucion: primero vemos que version de libmysqlclient en /usr/lib64/ bueno en mi caso, dejo la imagen con la sulucion. dudas deja un comentario