- Go to the "Settings" menu.
- Scroll to the bottom and tap "About phone" menu.
- Scroll to the bottom and tap on "Build number" seven (7) times.
Various ramblings of sysadmin, programmer, dancer, coffee snob, food lover and Winnipegger.
Thursday, February 19, 2015
Enable "Developer options" on Android
Saturday, November 29, 2014
Homebrew cheat sheet and workflow

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
mv filename filename-$(date '+%FT%T')or
mv filename filename-$(date '+%s')
For those who want to know the details, here's the break down.
Thursday, February 14, 2013
Grab Android screenshot to computer via ADB

Quite often, however, I need to copy the captured image over to my computer. Usually, I do this with
adb pull command, but if I'm going to use CLI to retrieve the file, why don't I take the screen shot with it as well?One method is to use
screencap command via adb shell like so:adb shell screencap -p /sdcard/screen.png adb pull /sdcard/screen.png adb shell rm /sdcard/screen.png
Not bad, but seems like there's some room for improvement.
Information provided by
screencap -h indicates that screen shot can be sent to stdout, but running adb shell screencap -p > screen.png results in seemingly corrupt file.Luckily, I wasn't the first person looking into this issue. Apparently, adb shell is performing an EOL (end-of-line) character conversion, from LF (line feed, '\n', 0x0A) to CR+LF (carriage return followed by line feed, '\r\n', 0x0D0A).
If that sounds familiar, that's because I've dealt with this before. Unfortunately, this time we're working with binary data, so using
tr -d '\r' command to remove all 0x0D will likely corrupt it by also removing bytes that aren't part of the 0x0D0A sequence. We want to only remove carriage return characters when they are followed by a line feed.The solution is to use sed search and replace as follows:
adb shell screencap -p | sed 's/\r$//' > screen.png
Unfortunately, I found that sed fix while works on Ubuntu doesn't work on OS X. This solution using perl handles binary search and replace better:
adb shell screencap -p | perl -pe 's/\x0D\x0A/\x0A/g' > screen.png
Now we have a one-liner that grabs a screen shot from the Android device and stores directly on the computer executing the command. Beautiful.
Tuesday, September 4, 2012
Backup your Android without root or custom recovery

Warning: this method is only available to devices running Ice Cream Sandwich or higher and it has bugs, but it is an alternative for folks who want to make a backup before rooting their device.
You'll need to have the latest adb installed and in you path, USB debugging enabled and your phone connected to your Mac.
The command in question has the following format:
adb backup [-f <file>] [-apk|-noapk] [-shared|-noshared] [-all] [-system|-nosystem] [<packages...>]Here are some common uses:
1. Backup all non-system apps, their data and your shared data (i.e. SD card contents):
adb backup -f /path/to/backup-file -apk -shared -all -nosystem
2. Backup all apps, their data and shared data (note: won't work on DRM protected apps):
adb backup -f /path/to/backup-file -apk -shared -all -system
3. Backup only app data (not the APKs themselves) and your shared data:
adb backup -f /path/to/backup-file -all
4. Backup only non-system apps:
adb backup -f /path/to/backup-file -apk -noshared -nosystem
5. Backup only your shared data:
adb backup -f /path/to/backup-file -noapk -shared -nosystem
6. Restore everything from your backup:
adb restore /path/to/backup-file
During backup your phone will display a backup confirmation screen giving you an option to enter an encryption password. In my case it would only work with non-empty password, otherwise it would generate a zero-sized file.
Sunday, August 19, 2012
Install adb and fastboot on OS X
adb and fastboot utilities for OS X, but I prefer installing those (and few other android utilities) on OS X is via Android SDK. This way you know exactly what you're getting and it's easy to can keep them up-to-date with Android SDK Manager.First download the latest Android SDK package from http://developer.android.com/sdk/index.html (
android-sdk_r20.0.3-macosx.zip at the time of this writing).Change into your download directory and unzip archive into your preferred location. I like my home directory so I run:
unzip android-sdk_r20.0.3-macosx.zip -d ~
This creates a
android-sdk-macosx directory in our home directory. Now run android application inside the tools directory to open Android SDK Manager (ASM).~/android-sdk-macosx/tools/android
ASM will connect to various repositories and present you with all possible Tools, Platforms and Add-Ons that could be downloaded and installed. Since we're only interested in few specific tools, deselect all except "Android SDK Tools" and "Android SDK Platform-tools" packages and then install / upgrade them.
Note: to accelerate checking for updates during future runs, go to "Tools"->"Manage Add-on Sites..." and click on "Disable All" button in "Official Add-on Sites" tab. From now on ASM will check only the default repository containing tools and APIs.
Now we'll add android tools to our PATH to make executing them more convenient. Create or edit
.bash_profile file in your home directory to contain these lines, just don't forget to replace YOURUSERNAME with your actual user name:ANDROID_TOOLS=/Users/YOURUSERNAME/android-sdk-macosx
export PATH=${PATH}:${ANDROID_TOOLS}/platform-tools:${ANDROID_TOOLS}/tools
Done.
Wednesday, April 18, 2012
Multiple time zones in Google Calendar

Luckily, Google Calendar takes care of this problem quite nicely:
- Go to Settings -> General -> Your current time zone
- Set your primary time zone if you haven't done so yet
- Check "Display all time zones" for full list of time zones
- Click on the "Show an additional time zone" link to add another time zone

- Chose you additional time zone from the list
- Enter your custom labels

- Save changes, and your appointments will have a nice label for each time zone next to them:

Monday, April 16, 2012
Convert Unix, Windows, Mac line endings using OS X command
The good ol' EOL (end-of-line) character...
Different operating systems use different characters to mark the end of line:
- Unix / Linux / OS X uses LF (line feed, '\n', 0x0A)
- Macs prior to OS X use CR (carriage return, '\r', 0x0D)
- Windows / DOS uses CR+LF (carriage return followed by line feed, '\r\n', 0x0D0A)
Since some of the files were very big, instead of changing line endings in TextWrangler I decided to use command line (shocking, I know).
First I executed
cat -v file-nameto confirm existence of the dreaded ^M (carriage return) at the end of every line, and then ran
tr -d '\r' < file-name > file-name-unixto generate new files without CR characters.
tr (translate character) is a nice little utility that does just that, substitutes one character with another or deletes it (like in my example). It's available on pretty much any *nix distro so no need to install additional software.
Saturday, April 14, 2012
Mounting CIFS shares from Windows command line

If you need to mount or unmount ('map' or 'disconnect' in Windows lingo) a Windows (Samba) share from Windows command line or batch file, you can do it with 'net use' command.
To map a network drive:
- Click Start, and then click Run (or use Windows+R keyboard shortcut).
- In the Open box, type cmd to open command line window.
- Type the following, replacing X: with drive letter you want to assign to the shared resource:
net use X: \\computer_name\share_name
- Open command line window.
- Type the following, replacing X: with drive letter of the shared resource:
net use X: /delete
Saturday, April 7, 2012
How to enable Windows 7 Administrator

net user administrator /active:yes
Wednesday, November 16, 2011
SSH into ESXi 5 host using public key

If you want to enable OpenSSH Public Key Authentication on your ESXi 5 host, append contents of your public key to
/etc/ssh/keys-USERNAME/authorized_keys file instead of usual ~/.ssh/authorized_keys file.For example, to enable public key logins as
root user, do the following:cat ~/.ssh/id_rsa.pub | ssh root@esxi.machine.com 'cat >> /etc/ssh/keys-root/authorized_keys'
Obviously, SSH server needs to be enabled on the ESXi host before you can do that. As I mentioned in my ESXi 5 installation write up, starting with
Wednesday, November 9, 2011
Updating BIOS of Intel DX58SO2
Here are the instructions from DX58SO2 manual:
Saturday, October 16, 2010
Reduce number of virtual terminals (TTYs) in Lucid
Most Linux distributions come with several (usually six) virtual consoles enabled by default. Think of it as having six terminal windows you can flip through using (CTRL)+ALT+F[1-6] keys. Sometimes you don't need or want to have that many TTYs. Let's say you have very little RAM, or want to shave a fraction of a second from your boot time, or simply want to strip all that isn't necessary from your installation. Here's how you do it in Ubuntu 10.04 Lucid Lynx.
Let's say you want to leave only two virtual consoles, tty1 and tty2. simply go to /etc/init/ directory and delete, or better yet move to safe location, files tty3.conf, tty4.conf, tty5.conf and tty6.conf
$ cd /etc/init/ $ sudo rm tty[3-6].conf
Next time you boot, only first two TTYs will be present. Note, that this will also shift your X session to where tty3 would normally be, so you can access it by typing ALT+F3 instead of ALT+F7.
Tuesday, October 5, 2010
Read a random line of text from file in Linux
There are many ways to achieve this, but this is probably the simplest since you most likely already have all the necessary components installed.
On Ubuntu it's the "shuf" command from "coreutils" package. It's original purpose is to shuffle the lines passed to it, or as its description says: "write a random permutation of the input lines to standard output". However, with one of the arguments you can limit the number of lines it returns, so if all you need is a single line from a given text file, juts run:
$ shuf –n 1 list.txt
where argument –n tells shuf to print only one random line from file list.txt
Thursday, September 30, 2010
Auto login Ubuntu user from CLI
There are a lot of recipes out there on how to automatically login into a given Linux user's account on start up, but most of them rely on some sort of graphical environment or display manager to be present. It took me quite a bit of digging to find a way to auto login in Ubuntu with nothing but CLI. I'm sure others will find this tip useful.
To auto login user "bob" on first console terminal (tty1) edit file /etc/init/tty1.conf and replace last line:
exec /sbin/getty -8 38400 tty1
with this:
exec /bin/login -f bob < /dev/tty1 > /dev/tty1 2>&1
and Robert's your father's brother, next time you boot your machine bob will automatically log into his account on tty1.
Wednesday, September 22, 2010
Convert .png to .gd2 for Nagios status map
If you ever tried to make Nagios web interface look a little nicer by adding some custom host or service icons, you have probably came across collections of icon packs at Nagios Exchange. You have also noticed an unusual .gd2 extension on some of the images and realized that without this format icons don't display properly on Status Map. I was doing exactly that the other day and couldn't find the icons I needed, so I ended up creating some myself. Here's how to convert a PNG image into .gd2 (GD Graphics Library format).
On Ubuntu install libgd-tools package, it will contain a pngtogd2 app. To convert file.png to file.gd2 use:
$ pngtogd2 file.png file.gd2 0 1
Once you have your .png or .gif and .gd2 images, I tend to use 40x40x8bit images with transparent background, place them in your /usr/local/nagios/share/images/logos/ directory (if you installed Nagios from source) and add these properties to your host or service definition:
define host{
...
icon_image ubuntu.png
statusmap_image ubuntu.gd2
...
}
Tuesday, September 21, 2010
Check NFS & memcached with Nagios
NFS
You can quickly check whether NFS server is up by usingcheck_rpc plugin like so:./check_rpc –H host –C nfsHere's my command definition:
define command{
command_name check_nfs
command_line $USER1$/check_rpc -H $HOSTADDRESS$ -C nfs
}
memcached
There are some dedicated plugins in the web for this one, but for my purposes this blog post was just the perfect solution. Memcached has a simple text based protocol and by default listens for connection on port 11211. So for a simple check I'm asking memcached for its version via TCP connection and expecting a response with word "VERSION" in it within 5 seconds:./check_tcp -H host -p11211 -E -s 'version\n' -e 'VERSION' -w2 -c5 –t5Here's my command definition:
define command{
command_name check_memcache
command_line $USER1$/check_tcp --hostname=$HOSTADDRESS$ --port=11211 --escape -s 'version\r\n' --expect='VERSION' --warning=2 --critical=5 --timeout=5
}
Monday, August 9, 2010
Enabling apache_* Munin plug-ins in Ubuntu
There are three Munin plug-ins for Apache monitoring bundled with Ubuntu's munin-node package:
apache_accesses- monitors the number of accesses to Apache serversapache_processes- monitors the number of apache-processes running on the machine, and (in addition to a simple process count), separate then into "busy" or "idle" serversapache_volume- monitors the volume of data sent from Apache servers
First of all, make sure that the libwww-perl package is installed on your system, or you might notice an error like this when you're executing these plug-ins directly from /usr/share/munin/plugins:
Can't locate object method "new" via package "LWP::UserAgent" at ./apache_volume line 127
In addition, apache_accesses and apache_volume require ExtendedStatus support to be enabled as well as mod_status module.
Status module can be enabled by running:
$ sudo a2enmod status $ sudo /etc/init.d/apache2 restart
To enable ExtendedStatus support create a /etc/apache2/conf.d/extendedstatus file containing the following directives:
<IfModule mod_status.c> ExtendedStatus On </IfModule>
Now create symbolic links to plug-ins in /etc/munin/plugins directory:
$ cd /etc/munin/plugins $ sudo ln -s /usr/share/munin/plugins/apache_accesses $ sudo ln -s /usr/share/munin/plugins/apache_processes $ sudo ln -s /usr/share/munin/plugins/apache_volume
Reload Apache and restart munin-node:
$ sudo /etc/init.d/apache2 reload $ sudo /etc/init.d/munin-node restart
Wednesday, July 7, 2010
Universal USB Installer
In my last post I mentioned UNetbootin – a great tool for Windows and Linux that allows you to create bootable Live USB drives for Ubuntu, Fedora, and other Linux distributions (VMware ESXi) without burning a CD. Here's another such tool, but with few extra features added.
Universal USB Installer is a Live Linux USB Creator that allows you to choose from a selection of Linux Distributions to put on your USB Flash Drive. The Universal USB Installer is easy to use. Simply choose a Live Linux Distribution, the ISO file, your Flash Drive and, Click Install. Other features include; Persistence (if available), and the ability to format the flash drive (recommended) to ensure a clean install. Upon completion, you should have a ready to run bootable USB Flash Drive with your select Linux version installed.
I particularly like the "Persistence" feature to create Linux LiveUSB that allows me to save data changes back to the USB storage device instead of leaving the information in system RAM. This data can then be recovered and used again on subsequent boots, even when booting from different machines. Now I always have a bootable Linux USB in my pocket.
Saturday, June 26, 2010
Quickly create VMware ESXi 4 LiveUSB
I recently discovered that it's possible to create a VMware ESXi 4 install USB using nothing but UNetbootin and official VMware ESXi 4 ISO file. Why would I want to do that? So I can install ESXi on servers without CD/DVD drives, they have become quite common lately. USB install is much faster than installing from optical media, and you save environment by not wasting a blank CD on a software version that will become outdated in three months or so.
In the past I have used a great little Bash script by Varazir that allows you to not only make a bootable USB with ESXi on it, but can also customize and merge various drivers into the install image. However, if all you need is a vanilla install, UNetbootin makes it a lot easier and works on both Windows and Linux platforms.
Just choose the "Diskimage" option and browse to your VMware ISO and you'll have a installation USB drive in no time.

