Thursday, February 19, 2015

Enable "Developer options" on Android

Since release of Android 4.2 the "Developer options" menu is not visible in the Settings by default. Regular users won't miss it, but for those of us who like to tinker with ADB and need the "USB debugging" option enabled, here's how to get it back:
  1. Go to the "Settings" menu.
  2. Scroll to the bottom and tap "About phone" menu.
  3. Scroll to the bottom and tap on "Build number" seven (7) times.
After this your "Developer options" should be back in the "Settings" menu and you be able to start voiding your warrantee like a hacker. "You are now a developer!"

Saturday, November 29, 2014

Homebrew cheat sheet and workflow

If you are a Mac owner and a serious *NIX user, you're probably aware of Homebrew.

I have a few of my favorite tools installed with brew and I like to keep my "Cellar" clean and up-to-date. Here's my commonly used commands and my typical workflow.

Never forget about man's best friend - "man". Use man to get the list of commands and options that can be used with brew:

man brew

To list software you currently have installed with version numbers, use:

brew list --versions

To see just the software, which is not a dependency of another:

brew leaves

To keep the Homebrew itself up-to-date, and fetch the newest version from GitHub:

brew update

After updating the brew, check which formulae have an updated version available, display detailed version information to see if you have more than one older version laying around:

brew outdated --verbose

See any app that you no longer need and want to get rid of them? Check the dependencies for all installed formulae:

brew deps --installed

For even more detailed picture, show the dependencies for all installed formulae as a tree:

brew deps --installed --tree

As a final precaution before removing a formula, see what other installed formulae use it as a dependency:

brew uses --installed formula

Uninstall formulae and all their older versions:

brew remove --force formulae

Upgrade remaining formulae:

brew upgrade

Show what will be removed by cleanup command, but do not actually remove anything:

brew cleanup -ns

Clean the "Cellar" removing any older versions of installed formulae and clearing old downloads from the Homebrew download-cache. Additionally, scrub the cache, removing downloads for even the latest versions of formula, which are downloaded, but not installed:

brew cleanup -s

Thursday, March 13, 2014

Add time stamp to a file name from CLI

I often find myself in need to append a time stamp to a file name, but always forget the right command line parameters. Here's a quick reminder to myself on how to do just that.

mv filename filename-$(date '+%FT%T')

For those who want to know the details, here's the break down.

Saturday, July 27, 2013

Root Android 4.3 Galaxy Nexus from OS X

My trusty Galaxy Nexus has just received its fresh Android 4.3 OTA, which, on the plus side, brought "improvements to performance and stability", but has also wiped out root along the way. When life gives you lemons... you write a blog post about delicious lemonade you've made, so I decided to update my old guide on how to root JB Galaxy Nexus. Check the link if you need more detailed explanation of each step.

First thing first, if you haven't done so yet, reveal Developer options in settings, enable USB debugging, unlock your bootloader and install or update adb, fastboot and other tools. I've written posts about that in the past, so follow the links if you need a walkthrough.

Download the latest ClockworkMod Recovery image for Galaxy Nexus (GSM) from ClockworkMod site, at the moment it's recovery-clockwork-touch- and save it as cwm.img in your home directory.

Download the latest SuperSU CWM installable ZIP using the link in the XDA-Developers forum thread ( at the time of this writing) and save it in the same directory as CWM Recovery image.

Make sure adb is detecting your devices correctly and is displaying phone's serial number when you run:

adb devices

You should see similar output in the terminal:

List of devices attached 

Push the SuperSU installer to your sdcard with command:

adb push /sdcard/

Reboot into bootloader with command:

adb reboot-bootloader

Make sure fastboot is also detecting your device and is displaying phone's serial number when you run:

fastboot devices

Boot into CWM recovery using cwm.img file in your home directory:

fastboot boot cwm.img

You will see the following output in the terminal:

downloading 'boot.img'...
OKAY [  0.707s]
OKAY [  0.388s]
finished. total time: 1.096s

Device will boot in to CWM recovery and present you with various options. Choose install zip option, then chose zip from sdcard, then 0/ - this is the default path to internal sdcard, then find and select the file we pushed earlier. Chose Yes - Install when presented with confirmation dialog and SuperSU will be installed from sdcard.

Once installation is complete select +++++Go Back+++++, then reboot system now. I personally choose not to disable recovery flash when presented with the next prompt.

Once the phone has restarted test for presence of root prompt (#) using:

adb shell su

You might want to update the SuperSU app via GooglePlay if you're not using the latest version, and it's done.

Wednesday, April 24, 2013

Using Git with Dropbox

Recently I challenged myself to get much more familiar with Git. I've used it briefly in the past, but some of my recent work got me seriously craving for a better version control system (VCS) than Subversion. Something faster, something that didn't require connection to central server, yet still allowed me to access my work on both my home and work computers. Git alone met majority of these requirements, I just needed a remote repository to share and sync my work between computers.

GitHub was my first choice, but my some of my work is not supposed to be available to the public, and I didn't think premium account was worth it. Setting up my own server seemed like too much work. My search for something simple, free, yet fast and reliable pointed me to Dropbox.

Dropbox has always been my favorite way to sync files and passwords between my devices. Here's how to turn it into a perfect remote Git repository.

First, we need a local Git repository with our work in it. If you don't already have one create one:

git init /path/to/new-project

It's good to have a README file, so let's make one:

cd /path/to/new-project
touch README

Now, let's stage and commit our changes:

git add .
git commit -m "Initial Commit"

Next, we create an empty "remote" repository in our Dropbox folder:

git init --bare ~/Dropbox/git/new-project.git

Technically, it's still stored locally on the same machine, but because it's inside our Dropbox folder, it will be automagically synced to the cloud and other linked devices.

We still need to "add" our remote repository to the local one:

git remote add dropbox ~/Dropbox/git/new-project.git

I'm naming my remote repository "dropbox" instead of traditional "origin". This could be handy if you have multiple remote repositories.

Then, push local master branch to remote:

git push -u dropbox master

I am also telling git to track remote master branch as upstream with -u flag.

Now I can work in my local repository, make changes and commits, and periodically updating remote repository with:

git push

If I need to work on my home computer, I can simply clone my project from remote repository inside my Dropbox with:

git clone -o dropbox ~/Dropbox/git/new-project.git

If local repository already exists on my home computer, but doesn't have the latest changes, we can fetch and merge them from remote with:

git pull

Now we have a distributed VCS with a central server, which is fast, reliable, super easy to setup, doesn't require maintenance, private and is free of charge. It might not be suitable for collaboration between multiple developers, but it's ideal for the needs of one.