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

Samsung Galaxy S3 killer feature: Smart Stay!

I’ve been playing around with an SGS3 for a couple weeks now, and I must admit that I’m pretty impressed with this device.

I’m one of those early android adopters that bought an HTC Hero and I’ve been using it for around 4.5 years. I know that it has really old hardware and it’s many Android versions older than this SGS3 device, but I was using it primarily as a phone (making calls/SMS) and as an application tester, so it worked well and had good battery life.

I’m not going to do here a device review (because I’m sure that you can find a lot of those), and I’m just going to point out what for me is this device killer feature:

 

 

 

Smart Stay!

When you have a screen as big as this, you don’t scroll pages as often as you would on a device with a smaller one. Without this feature, I believe that it would be really annoying having to touch the screen every 30s just so it wouldn’t go to sleep.

I believe that Samsung got it right, and I believe that this feature should be in all tablet devices too!

BlackBerry Webworks Facebook Post

Facebook integration with an Webworks app, can be a really tricky matter. If you ever tried this you’ve noticed that the Facebook JavaScript SDK, don’t work in the widget and also that the Facebook BlackBerry SDK, is intended for JDE project and also don’t work on a Webworks project.

The best thing that I’ve found in the web that partially solved this, was to use ChildBrowser-plugin-for-BlackBerry, that maybe it used to work, but since some new modifications in the Facebook API, it doesn’t work anymore…

Actually with the ChildBrowser-plugin-for-BlackBerry, I was able to login and retrieve the token using the Torch 9800 simulator, but it just didn’t work for the Bold( device or simulator), so I needed to dive more deeply into it.

I’ve notice this plugin used a BrowserField to connect to Facebook and that it make no sense that it worked on the Torch simulator and not on Bold.

On the Bold device, when I tried to login, it just refreshed the page and didn’t login adding some Security notice.

Since the login worked on any other desktop browser, I’ve opened a sniffer and looked at how was the communication between the browser and Facebook.

Then I’ve also debugged the webworks app and noticed that the only difference between them were that the BlackBerry app was sending an x-wap-profile and maybe this was the reason why Facebook was rejecting the communication.

To be able to set those headers, I needed to create my own ProtocolController, and by doing this I could trick Facebook to think that actually it was a Desktop browser trying to connect. I’ve also had to implement the ability to store and send cookies, and after doing that I was able to connect to Facebook and actually retrieve the token.

Since I used the ChildBrowser-plugin-for-BlackBerry, I think that it’s only fair that I also share my progress, and so you can download it from here BlackBerry-Webworks-Facebook-Post

 

Best regards,

Daniel Botelho

BlackBerry Webworks Javascript Extension to allow File Downloads

If you are a BlackBerry Webworks developer I’m sure you’re always noticing that something is missing.
This time, I took some time to develop something that is really trivial in other plataforms, but due to Webworks nature, it’s bit triky.

My goal was simple: Download an image to the device, and show it in the Webworks app.
So as usual I googled it, and found that are at least one solution for the BlackBerry PlayBook, but not for OS5+.

Since I think that this is useful, I’ve decided to create an Javascript Extension to do this, and you can now download it here

The installation process is as usual, just download that file to your “ext” folder, and make it accessible to the application by adding it to the “config.xml”:

<feature id="blackberry.io.filetransfer" required="false" version="1.0.0"/>

To be able to access those downloaded files through the widget you may need to also add this line to the “config.xml” file:

<access subdomains="false" uri="file:///"/>

With this Javascript Ext you’ll have only one method available:

blackberry.io.filetransfer.download(arguments);

And the “arguments” can be:

  • url (required): Is the download url. ex: “https://www.google.com/images/srpr/logo3w.png”
  • dest (required): Is the local file location. ex:”file:///store/home/user/logo/logo.png”
  • type (optional): Can be ‘POST’ or ‘GET’ (default: ‘GET’)
  • success (optional): Is a Javascript function that is called after the download is complete
  • error(optional): Is a Javascript function that is called if the download fails for some reason
  • headers (optional): For this version the headers only allows you to set the “Authorization” and/or “Content-Type”, but if you need more support please let me know.

And now I’m leaving two examples of how it really works:
Example 1: Download the google logo and notify when it’s done

<script language=”javascript” type=”text/javascript”>

// Here whe need to create the local folder, if it doesn’t exist already
if (!blackberry.io.dir.exists(“file:///store/home/user/logos/”)) {
blackberry.io.dir
.createNewDir(“file:///store/home/user/logos/”);
}

// Download the file
blackberry.io.filetransfer.download({
url: “https://www.google.com/images/srpr/logo3w.png“, // the image url
type : ‘GET’, // explicitly setting method type to ‘GET’
dest: “file:///store/home/user/logos/GoogleLogo.png”, // the local file
success : function(data){ // The function called after the file is downloaded
alert(‘success’);
},
error : function(data){ // The function called if something fails
alert(‘error:’+data);
}
})
</script>

Example 2: Download the google logo with HTTP Basic Authentication

<script language=”javascript” type=”text/javascript”>
function make_base_auth(user, password) {
var tok = user + ‘:’ + pass;
var hash = Base64.encode(tok);
return “Basic ” + hash;
}

// Here whe need to create the local folder, if it doesn’t exist already
if (!blackberry.io.dir.exists(“file:///store/home/user/logos/”)) {
blackberry.io.dir
.createNewDir(“file:///store/home/user/logos/”);
}

// Download the file
blackberry.io.filetransfer.download({
url: “https://www.google.com/images/srpr/logo3w.png“, // the image url
type : ‘GET’, // explicitly setting method type to ‘GET’
headers:{
Authorization: make_base_auth(“my_username”,”my_password”),
“Content-Type”: “application/x-www-form-urlencoded”
},
dest: “file:///store/home/user/logos/GoogleLogo.png”, // the local file
success : function(data){ // The function called after the file is downloaded
alert(‘success’);
},
error : function(data){ // The function called if something fails
alert(‘error:’+data);
}
})
</script>

You can find the source code here https://github.com/dbotelho/blackberry.io.filetransfer

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.

Small UI failures on Ubuntu 12.04

Today I’ve upgraded to the new Ubuntu version 12.04 Precise Pangolim and I found that some UI needs to be updated to 2012 year! ;)

Missing tooltips in the “Dash Home”

Basically when an UI is intended to mouse point usage it should show tooltips when you hover over some button. The “Home”, “Files”, “Music” and “Video” icons are well understood, but the “Apps” icon makes no sense… To solve this when you hover over those buttons it should appear a tooltip like “Show Applications”/”Show Vídeo Collection”…

Missing visual feedback when opening apps outside the Launcher bar

Ok this is another weird ( I say weird, because it’s weird that in 2012 things like this still happen) issue on the UI, that don’t show any type of feedback to the user while he is waiting for the app to launch. Loading indicators are a standard and they are a standard for a reason, don’t you think?

J2ME References

Hi,

So I’ve started developing for J2ME devices and I’ve noticed that there aren’t many information around, so I’ve decided to start bookmarking some useful links.

J2ME LCDUI

Image Manipulation

Books

http://book.javanb.com/wireless-java-developing-with-j2me/