Tuesday, May 26, 2015

Brazillian phone format with Java


String num = "11936247832";
Pattern pattern = new Pattern("(\\d{2,2})(\\d{4,5})(\\d{4,4})");
Matcher res = pattern.matcher(num);
if (res.find()) {
   System.out.println("("+res.group(1)+") "+res.group(2)+"-"+res.group(3));
}

Friday, December 19, 2014

Android SDK on Ubuntu 14.10 x64

Everytime I install Ubuntu on a new machine, and want to get Android SDK running, I always forgot to install the 32bit libraries required by Android SDK.

The command line to install all required libraries on Ubuntu 14.10 x64:

sudo apt-get install libc6:i386 libncurses5:i386 libstdc++6:i386 lib32z1

Friday, August 1, 2014

Recovering old 5.25 floppies with Ubuntu Server

I was trying to recover some data from my old 5.25 floppy disks last weeks. First, I bought an old Pentium III 1Ghz, 256MB RAM for R$16 (about $7), and added my old 5.25 floppy drive to it.

The computer not had an HD or CD-ROM, but it has and old 3.5 floppy drive (very lucky!)
I installed FreeDOS on my old notebook HD first, to check if computer was working right. And yes, it was. 

Now, I wanted to run Ubuntu Server 14.04 (because there is not enough RAM to run Ubuntu Desktop) to enable the USB and network interface, to make easy to copy the recovered files from and USB drive or network.

I did the install in a VirtualBox using another computer, and after installing Ubuntu Server, did a boot in VirtualBox with a Clonezilla image transfering it to PIII HD via IDE/USB interface.

After installing it back to PIII, the first problem was Grub UUID. I fixed it booting on Grub recovery in Ubuntu, and running the command:

$ sudo grub-install --recheck

By default, the floppy module is not loaded first time, to fix it:

$ sudo modprobe floppy

Next annoying thing, which I lost almost 2 weeks trying to fix it, is the 5.25 floppy drive motor spinning forever bug. When I try to access the drive, using mount or dd, the drive motor turns on and never turns off, ever.

Finally I found a workaround to fix this!

First, install fdutils:

$ sudo apt-get install fdutils

Now, add this line to your /etc/rc.local:

floppycontrol -C 2147483647

Reboot, and your 5.25 floppy drive is working!


Thursday, January 13, 2011

¿How to create inverted question mark?

To create the inverted question and exclamation marks, used in spanish language:

[alt gr] + [shift] + !
[alt gr] + [shift] + ?


Sunday, September 5, 2010

Lost Android emulator

Last week I decided to start with Google Android development. Mostly because I bought a SonyEricsson Xperia X10 mini :D
It's a very nice phone, it runs Android 1.6, but I'm still impressed with it.

So, I decided to make things for my phone and downloaded the latest Android SDK from Google.

My environment is a Windows 7 and everything installed fine.

But I had an issue after trying to start an AVD (Android Virtual Device) after pushing the "Start..." on "Android SDK and AVD Manager".
Every time I try to start the AVD, it returns me a error:


emulator: ERROR: unknown virtual device name: 'Test21'
emulator: could not find virtual device named 'Test21'


Trying to solve the problem, I checked the folder where the .avd files are in, and the "Test21.avd" was there!

Trying to search for help on Google, a lot of people has this issue too, but the advanced users can't help them, because the environment of them is Linux (ok, I know)

I have the latest Ubuntu on my computer too, but I wanted to resolve the issue, not only blame Windows 7 for this and turn back from the problem.

Ok, what I found:
- AVD Manager creates the .avd file on your Home folder (eg.: My home folder is "D:\Users\Philber\.android\avd")
- The Android emulator searchs for the .avd file on your home folder, BUT on the wrong drive! ("C:\Users\Philber\.android\avd")

So, it'll happens with everyone which has the home folders on a different drive from C:

What I did to fix it? I copied the .avd files do C:

Maybe there is another way to solve this problem, but I already lost 1 hour to start doing something because of this.

Well, I hope someone find this helpfull.

Update: You can add an environment variable
ANDROID_SDK_HOME=D:\Users\Philber\
This solve the issue, too.





Let's begin

I'm finally restarting a blog, to try to get tracking of my ideas and stop forgetting things.
And it's a good way to practice my english.