Sending GPS coordinates through url using Symfony 1.4

I’ve been developing an API using Symfony 1.4.18 version and I’ve noticed that you can’t send “dots” as part of the url.
Basically if you have something like this in your routing.yml:

checkin_hotel:
 url: /checkin/hotel/:minLon/:minLat/:maxLon/:maxLat
 param: { module: service, action: checkin, type: hotel }

and you try to call this url:

http://myurl/checkin/hotel/-9.15794/39.34242/-8.95677/42.34532

This wont work!

This happens because by default symfony interpret “.” and “/” as separators and so the route “checkin_hotel” wont be called.

To fix this you should specify directly that it should only use “/” as separator:

checkin_hotel:
 url: /checkin/hotel/:minLon/:minLat/:maxLon/:maxLat
 param: { module: service, action: checkin, type: hotel }
 options:
   segment_separators: [/]

Best regards,
Daniel Botelho

Ubuntu 12.04 problems with NVIDIA® GeForce® 8400M

So finally I’ve got my old laptop working with the current Ubuntu 12.04 release.

To do this I’ve followed this user advice and completely removed the proprietary NVIDIA driver:


sudo apt-get --purge remove nvidia*
sudo apt-get install xserver-xorg-video-nouveau libdrm-nouveau1a nouveau-firmware

Reference: [8400m] nvidia-graphics-drivers (295.33-0ubuntu1), is causing failed restarts. shutdowns & only a blackscreen on tty’s other than tty7

Linux Mint 13 on VirtualBox needs some tweaks to use USB mouse

Since I’m kind of disappointed with the lasted Ubuntu version (12.04), that just makes my 4 year-old laptop useless, I’m now considering alternatives.
The first one that popped up was Linux Mint.

I’ve tested the latest build Linux Mint 13 on VirtualBox and I’ve noticed that my USB mouse didn’t work there.
To fix this I had to execute this command:
sudo usermod -aG lp <MY_USERNAME>

and it fixed that issue.

I’m going to try it a bit, just to see if I’m ready to do the switch.

Unity Launcher Editor in Ubuntu 12.04

To run the Unity Launcher Editor in Ubuntu 12.04 you need to run the following commands in the Terminal:

sudo apt-get install bzr
bzr branch lp:unity-launcher-editor
cd unity-launcher-editor/
./ule

I’ve noticed that many bloggers are telling you that you should run it by using the “~/unity-launcher-editor/unitylaunchereditor/main.py”, but that file no longer exists.

Blackberry Javascript Extension using an external library

I have a BlackBerry WebWorks project that needed to use Omniture reporting. Since Omniture already have an library for BlackBerry, I’ve decided to create an JavaScript Ext that would expose that functionality to the web application.

The only thing that you need to do differently from creating another regular JS Ext is that you need to include a new “<dependencies>” tag in the library.xml file, with the relative location of the external library.
Here it’s the example:

<library>
  <extension>
   <entryClass>xxx</entryClass>
  </extension>
  <features>
   <feature id="xxx" version="1.0.0" >XXX</feature>
  </features>
  <dependencies>
   <jar path="omni.jar" />
  </dependencies>
 </library>

Android Simulator/Emulator: Delete directory

One thing maybe (or maybe not) you’ve noticed is that you can’t delete an entire directory using DDMS on eclipse.

To be able to delete a directory on simulator sd card you can use the ADB command and connect to device via shell.

The first thing to do, is to go to “<android-sdk-PATH>/platform-tools” and from there type:

./adb devices

Then connect via shell to the device that you want:

./adb -s emulator-5554 shell

Now you’ve connected to the device “emulator-5554″  and now you can remove the files or directories that you want!

Protect your clients: Save hashed passwords in your database!

I’m always surprised when I open my Feed reader and over and over again I stumble upon another report saying that some website store users passwords in plain text and that those passwords got exposed.

Now, why do you need to store those passwords in plain text?

Just hash them in the database and when some user tries to login into your site, hash the password that he gave you and try to match it with the one that is stored in database.

Now if someone cracks your database security the users will not be harmed because they don’t get access to theirs passwords (at least in plain text)!

If you want to add an extra protection, append a “salt” string to the users password and hash the new string all together. (This is how it’s done in symfony sfGuardPlugin http://trac.symfony-project.org/browser/plugins/sfGuardPlugin/lib/model/sfGuardUser.php?rev=3980#L31)

Use Fatsort to order MP3 files (Linux)

Fatsort (http://fatsort.sourceforge.net/) is a very useful tool to order your MP3s so you can listen in your MP3 hardware player.

Fatsort is command line tool that allow you to order your files in a USB stick. It’s usage is very simple:

1) First get the device location by typing “sudo mount”. There you should find something like “/dev/sdb1″.

2) Unmount this device: “sudo eject /dev/sdb1″

3) Apply the fatsort to that unmounted device: “sudo fatsort /dev/sdb1″

And it’s done :)

Blackberry Widget dialog and menu conflict issue for OS 6.x

If you have developed a Blackberry Widget app that uses features blackberry.ui.menu and blackberry.ui.dialog in the same application, you’ve noticed that your application won’t work on devices that have OS version 6.x (like the Torch 9800 -6.0.0.227).

To fix this I’ve developed an Javascript Widget Extension that actually does the same as blackberry.ui.dialog but that uses another namespace( to avoid conflict with blackberry.ui.menu).

To use this Widget you should do this:

  • Download the blackberry.ui.dialoger and put this file in projects directory “ext”;
  • Go to applications “config.xml” and replace “blackberry.ui.dialog” for “blackberry.ui.dialoger”
  • Then replace all occurrences of  “blackberry.ui.dialog” for “blackberry.ui.dialoger” in your widget source code
  • And it’s Done!

Now your application can run in both OS 5.x and OS 6.x, and supports dialogs and menu items!

Best regards,

Daniel Botelho

Parsing XML namespace elements with jQuery

Let’s assume that we have loaded through AJAX an XML file and we wanted to parse a XML element “artist” with the namespace “palcoprincipal” to get the Artist name:


<palcoprincipal:artist>Cool Artist </palcoprincipal:artist>

You may be tempted to parse it like this:

$(xml_string).find(‘palcoprincipal:artist’).text()

but it won’t work.
The correct way (and multi-browser-way) is like this:

$(xml_string).find(‘[nodeName=palcoprincipal:artist]’).text()