Monday, July 25, 2016

Python 3.5: pip install error: Unable to find vcvarsall.bat

* Windows 7
* Python 3.5.2

I was trying to install cx_Freeze
pip install cx_freeze

It failed with the following error:
    creating build\lib.win32-3.5\cx_Freeze\samples\zope
    copying cx_Freeze\samples\zope\ -> build\lib.win32-3.5\cx_Freeze\samples\zope
    copying cx_Freeze\samples\zope\ -> build\lib.win32-3.5\cx_Freeze\samples\zope
    running build_ext
    building 'cx_Freeze.util' extension
    error: Unable to find vcvarsall.bat

Apparently, this "unable to find vcvarsall.bat" is a well known issue...Luckily, Steve Dower from Microsoft has posted a solution for us.

For Python 3.5 and later, install Visual C++ Build Tools 2015
For Python 3.3 and 3.4, install Windows SDK for Windows 7 and .NET 4.0
For Python 2.6 to 3.2, install Microsoft Visual C++ Compiler for Python 2.7 

How to deal with the pain of “unable to find vcvarsall.bat” – Python Engineering at Microsoft
Python 3.4, Windows 10 and Unable to find vcvarsall.bat - Stack Overflow
visual studio - Unable to find vcvarsall.bat using Python 3.3 in Windows 8 - Stack Overflow
windows - What version of Visual Studio is Python on my computer compiled with? - Stack Overflow
python - error: Unable to find vcvarsall.bat - Stack Overflow

Sunday, June 26, 2016

Android: User profile data location (root required)

To find users on a device:
adb shell pm list users

you should see something like this:

Bob's user ID is 11. His data files can be found at:

P.S. If you are using ES File Explorer, first install SuperSU, then enable Root Explorer within ES File Explorer. You should be prompted to grant root access to ES File Explorer.

To run an app as Bob for example:
adb shell am start --user 11 \ -n "com.example.myapp/com.example.myapp.testactivity" \ -a android.intent.action.MAIN -c android.intent.category.LAUNCHER

Set up Managed Profiles | Android Developers

Saturday, June 25, 2016

Android: Screen recording via ADB

To start a screen recording (requires Android 4.4 (KitKat) or above):
adb shell screenrecord /sdcard/example.mp4

Stop the screen recording by pressing Ctrl-C, otherwise the recording stops automatically at three minutes or the time limit set by --time-limit. The default and maximum value is 180 (3 minutes).

To take a screenshot:
adb shell screencap /sdcard/screen.png

ADB Shell Commands | Android Studio

Saturday, June 18, 2016

Android: What are the application-icon-* in aapt dump badging?

When running aapt dump badging, there is a list of application-icon.*

What are those numbers 120, 160, 213...etc.?

Each number represent a screen density, e.g.
120 = DENSITY_LOW = ldpi
160 = DENSITY_MEDIUM = mdpi
213 = DENSITY_TV = tvdpi


DisplayMetrics | Android Developers

Sunday, June 12, 2016

Python: pyenv vs pyvenv vs venv vs virtualenv

What's the difference between pyenv, pyvenv, venv, and virtualenv?

pyenv - a 3rd party tool for switching between multiple versions of Python (e.g. change the global Python version between Python 2 and 3).

pyvenv - a built-in command line tool for creating “virtual environments”. It helps separate packages dependence between projects. Added since Python 3.3.

venv - a built-in API module for creating "virtual environments". Added since Python 3.3.

virtualenv -a 3rd party tool for creating "virtual environments".

Python: pyenv, pyvenv, virtualenv – What’s the difference? | Abu Ashraf Masnun
PEP 405 -- Python Virtual Environments |

Tuesday, May 10, 2016

Mac: Default email reader keep resetting to Mail

On Mac OS X El Capitan (10.11.4), I was trying to change the default email reader to MS Outlook. So I went to Mail > Preferences > General, and changed Default email reader to Outlook. However, if I re-open the Preferences dialog, I noticed the setting is reverted back to Mail.

I was able to resolve the issue by resetting LaunchServices. Open Terminal and run the following command:
/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister -kill -seed

OS X 10.11.4 - Setting the default email to one... | Apple Support Communities

Wednesday, March 30, 2016

Wireshark: Search for GET and POST requests

When analyzing a packet capture file (*.pcap) with Wireshark, it can be handy to view just the GET and POST requests.

To view GET requests, set display filter to:
http.request.method == "GET"

To view POST requests, set display filter to:
http.request.method == "POST"

To view both GET and POST requests, use the or operator:
http.request.method == "GET" or http.request.method == "POST"