Ubuntu: Google Chrome or Chromium Browser

After spending time on this, I am moving back to Google Chrome. I was hoping that apt-get updates would be a nice one to keep (since Google’s official repository is crappy right now).

I reckon Google has its own update tool, and additional features such as embedded PDF reader (ok, you can hack the chromium-browser (with plugins) it to make it work as well)… but the official Google version comes with all Google stuff ready, and some additions I find handy. So, I am handling this with:

# download the package (unstable, replace this if you want the stable version)
wget https://dl.google.com/linux/direct/google-chrome-unstable_current_amd64.deb
# Install the package
sudo dpkg -i google-chrome-unstable_current_amd64.deb
# fix missing desktop icon
sudo ln -s /opt/google/chrome/google-chrome.desktop /usr/share/applications/google-chrome.desktop

Done!

PHP Documentation

Simple installation and usage of phpdoc:

Install dependencies and phpdoc

# install dependencies
$ sudo apt-get -y install php-pear php5-xsl graphviz
 
# install phpdoc
$ sudo pear channel-discover pear.phpdoc.org
$ sudo pear install phpdoc/phpDocumentor-alpha
 
# run phpdoc
$ phpdoc --target ./docs --directory ./ --title 'PHP Documentation'

And that’s it!

screenshot-20130506_001

[Linux] Running Multiple Skype instances

Recently I have been using Skype for corporate communication, and one thing that happens quite often is the fact you do not want to mess your personal and work stuff.

Luckily, on Linux (and Windows, I presume), you can easily  run multiple instances (accounts) of Skype.

Here is how I do it:

1) Create a script to run the second (or N instances) of Skype:

create a file on an executable $PATH (such as /usr/local/bin/skype-username)

#!/bin/bash
echo username password | skype --pipelogin -- secondary

Usually it is a good approach to set this file to permissions 0700, if you want to leave the password hard-coded like the above. Handy, but you have the security trade-offs to think about. And replace the username/password with your own credentials (note the file has also executable permissions, and if you don’t need the credentials, just use 0755).

sudo chmod 700 /usr/local/bin/skype-username

2) Create the desktop Icon

Save a file named: /usr/share/applications/skype-username.desktop

[Desktop Entry]
Name=Skype Username
Comment=Skype Internet Telephony (for Username)
Exec=skype-username %U
Icon=skype.png
Terminal=false
Type=Application
Encoding=UTF-8
Categories=Network;Application;
MimeType=x-scheme-handler/skype;
X-KDE-Protocols=skype

I basically use the desktop icon for Synapse, but you could just create on your desktop as well (or on Unity, if using Ubuntu).

screenshot_20130418112211

For more advanced usage of Skype, I recommend looking at system commands you can type in:

https://support.skype.com/en/faq/FA10042/what-are-chat-commands-and-roles

MySQL WorkBench on Ubuntu 12.10

Is this never gonna end? :S

I wrote some time ago about dependency issues with MySQL Workbench here http://blog.brunobraga.net/mysql-workbench-on-ubuntu-12-04-beta/, and here I am again. This time, I was just upgrading the latest version in my Ubuntu 12.10, and got another dependency issue, with version 5.2.47.

# get and install missing/unmet dependency
wget http://launchpadlibrarian.net/83494312/libctemplate0_1.0-1_amd64.deb
sudo dpkg -i libctemplate0_1.0-1_amd64.deb
# get and install MySQL WorkBench
wget http://dev.mysql.com/get/Downloads/MySQLGUITools/mysql-workbench-gpl-5.2.47-1ubu1204-amd64.deb/from/http://cdn.mysql.com/ 
sudo dpkg -i mysql-workbench-gpl-5.2.47-1ubu1204-amd64.deb

That’s it!

Logcat in colors from command-line

After days and days looking at these logs, I finally came to reason, and decided to put some colors on it. I found some people already doing this:

But neither of them support new logcat formats (specially the time output, which I use a lot). So I built my own (quick work, really). Here it is:

https://bitbucket.org/brunobraga/logcat-colorize

Rework from 37Signals

Just read the book Rework (http://37signals.com/rework)… can’t say I agree with everything, but definitely it defies the status-quo, and puts things to perspective. Sometimes we just get used to do things, oblivious of their reason, and such reading pushes you to question them all over again. Maybe worth reading (the interesting lines) every now and then to keep mind fresh!

front-cover

Some of the quotes I liked from the book:

[...] Unless you’re a fortune-teller, long-term business planning is a fantasy.

[...] Plans let past drive the future.

[...] Workaholics aren’t heroes. They don’t save the day, they just use it up. The real hero is already home because she figured out a faster way to get things done.

[...] If you constantly fret about timing things perfectly, they’ll never happen.

[...] Details make the difference. But getting infatuated with details too early leads to disagreement, meetings, and delays.

[...] If you start pushing back deadlines and increasing your budget, you’ll never stop.

[...] Let’s say your challenge is to get a bird’s-eye view. One way to do it is to climb the Mount Everest. That’s the ambitious solution. But then again, you could take an elevator to the top of a tall building. That’s a judo solution.

[...] The right time to hire is when there’s more work than you can handle for a sustained period of time.

[...] Hire managers of one.

[...] Hire great writers. [...] Clear writing is a sign of clear thinking.

[...] When everything constantly needs approval, you create a culture of nonthinkers,

[...] You don’t need more hours; you need better hours.

[...] Write to be read, don’t write just to write.

The Augustine Test

While studying Corporate Governance, I heard about the Augustine Test, a simple question based framework to help evaluating the ethics of decision making. The questions here are somewhat “adjusted” to present times (considering Augustine lived in 350s), but I found them quite interesting:

  • Is it legal?
  • If someone else did it to me, would I think it was fair?
  • Would I be OK if it appeared on the front page of the local paper?
  • Would I like my mother to know I did it?

 

[Bash] timing scripts

If you are in the need to check how long a script takes, most people will just suggest time command, and that’s good enough in many cases.

But if you need to print out different elapsed times within a script, or even a simple overall elapsed time in a more human readable way (I often do this for email reports, etc), I reckon this is a very good approach:

# In your script, define when the timer starts
start_timer=$(date +%s.%N)
# do whatever
# print in seconds
echo "This script took [`echo "$(date +%s.%N) - $start_timer" | bc \
     | awk '{printf "%.2f\n", $0}'`] seconds to complete."
# print in milliseconds
echo "This script took [`echo "($(date +%s.%N) - $start_timer)*1000" | bc \
     | awk '{printf "%.2f\n", $0}'`] milliseconds to complete."

Note that the awk command is there just to cut off the decimal digits (by default, is 9 digits for nanosecond precision). Tweak that as needed.

This will produce an output like:

This script took [12.01] seconds to complete.

Neat!

Migrating to WordPress…

Sorry folks,

Since the terrible news from Posterous, I am moving the site to WordPress installation, but this is still on going. Hopefully the site will be fully operational within a couple of days.

Sorry for the inconvenience (as most links pointing here will not work properly).

Sincerely,

– Bruno Braga

Decompiling Android Apps

More a reminder to myself of good tools out there:

Quick look

From an APK file:

# outputs "app" directory
$ apktool decode app.apk

This will give access to resources, assets, manifest, and some details of the Java files (such as property values, and public method names). Sometimes, that's all you need to troubleshoot issues with an APK.

Thorough look into the code

# outputs a DEX file
$ jar xvf app.apk

# convert DEX into Jar (outputs file classes_dex2jar.jar) 
$ dex2jar.sh classes.dex

# navigate the code 
$ jd-gui classes_dex2jar.jar

Obfuscated or not, this will give the complete source code of the app, and theoretically you'd be also able to recompile it back with whatever changes you make on it.