Entries by Carlos Escribano

When you modify your settings.py file of your Django project on production servers you can get errors like this when updating the code: $ git fetch $ git merge origin/master ... error: Your local changes to 'settings.py' would be overwritten by merge. Aborting. Please, commit your changes or stash them before you can merge. ... [...]


// Symfony 2 public function updateAction($id) { $em = $this->getDoctrine()->getEntityManager(); $product = $em->getRepository('AcmeStoreBundle:Product')->find($id); if (!$product) { throw $this->createNotFoundException('No product found for id '.$id); } $product->setName('New product name!'); $em->flush(); return $this->redirect($this->generateUrl('homepage')); } # Django def updateAction(request, id): product = Product.objects.get(pk=id) # Product.DoesNotExist exception raised if not found product.name = u"New product name!" product.save() return HttpResponseRedirect(reverse('homepage'))


For those of you that use Textmate here are my favourite bundles and plugins. First of all you should read documentation on how to get more bundles. GetBundles This bundle lets you easily find and install other bundles. It’s not so pretty but it works. You can download it with this Terminal.app command: svn export [...]


For all of you that don’t know what Less CSS is, check this first, but I will try to summarize it in a phrase: It is a way of writing cleaner CSS code using variables and mixins but with the need of being compiled to an actual CSS file. Lets see an example of .less [...]


Suppose we have HTML code with the following structure: <body> <a id="panel-previous" href="#">previous</a> <ul id="panel"> <li>ad</li> <li>adipisicing</li> <li>aliqua</li> <li>aliquip</li> <li>amet</li> <li style="display:none;">anim</li> <li style="display:none;">aute</li> <li style="display:none;">cillum</li> <li style="display:none;">commodo</li> <li style="display:none;">consectetur</li> <li style="display:none;">consequat</li> <li style="display:none;">culpa</li> </ul> <a id="panel-next" href="#">next</a> </body> We want to show only five items at once, and we want to show next and [...]


If you manage :focus CSS styles for certain input controls you may have noticed that Safari attempts against your pretty innovative design adding a blurry blue outline effect. You can avoid this adding this: input:focus { outline-width:0; ... } And that’s all.


Today I needed to access a webserver with phpMyAdmin configured as default page if no virtual host matched the requested one. It was configured to deny access from outside so my solution was to use a SSH tunnel: carlos$ ssh -L 10080:192.168.1.3:80 user@host So I can access phpMyAdmin writting this in my browser address bar: [...]


Recently I discovered that Firefox lets you override alert and confirm window object methods. I tried this with prototype and surprisingly it just worked! (Note that it is not tested in IE or Opera and others yet, but it also works in Safari). <div id="test" style="background:red;color:white;display:none;"></div> <script type="text/javascript"> window.confirm = function (s) { alert(s); }; [...]


You can see regular expression examples at this site. Very useful. This is the content: Examples Numeric Ranges Floating Point Numbers Email Addresses Valid Dates Credit Card Numbers Matching Complete Lines Deleting Duplicate Lines Programming Two Near Words


The concept around this is to serve a 1px image through a PHP script. This allows you to insert a new record or update an existing one about read mails. In your mail you only have to insert an image tag like this at the end of the template: <img src="<?php echo url_for('stats/image?bulletin='.$id, 'absolute=true') ?>" [...]


Nuestros queridos amigos de Joomla / Joomla Spanish, ni sé ni quiero echar las culpas a nadie, se han olvidado un trozo de código en una query para borrar imágenes y saltaba el mensajito de: No tiene permiso para acceder a esta sección o algo similar. Lo que hay que hacer es, en la línea [...]


Generating a CSV file from an action to bring it to the users of one of our websites I encountered myself with the problem of Symfony’s MVC model and decorator pattern. Although I was using echo statements directly, Symfony was waiting for the action to finish to send headers and allow the download, so the [...]


Cuando el nombre de la tabla en la base de datos difiere del nombre en el modelo de objetos, necesitamos obtener el “phpName”. Una forma de hacer esto, útil cuando solamente tenemos un nombre de tabla y un ID, es: $tabla = Propel::getDatabaseMap()->getTable($miNombreDeTabla); $phpName = $tabla->getPhpName() ? $tabla->getPhpName() : sfInflector::camelize($tabla->getName()); return call_user_func(array($phpName.'Peer', 'retrieveByPK'), $miID); Por [...]


Pegándome con el widget de Plaxo para obtener contactos de correo desde cuentas de servicios web públicos he necesitado sacar por un lado el nombre del “individuo” y por otro su dirección de email para insertarlo en unos controles de un formulario. Como no tengo ni idea de expresiones regulares, etc, etc, etc… me ha [...]