Code Handover

If you are handing over the code for an Android Studio project here are the kind of commands you might want to execute:

export ANDROID_HOME=/Development/android-sdk-macosx
export RELEASE_STORE_PASSWORD=store_password
export RELEASE_KEY_ALIAS=release_key
export RELEASE_KEY_ALIAS_PASSWORD=alias_password
git clone ssh://git@bitbucket.com/myproject.git myproject
cd myproject/
git checkout -b release origin/release
rm -rf .git git README .gitignore .arclint .arcconfig test_all.sh
./gradlew assembleProd
rm -rf */build

Android Action Bar Overlay

To enable overlay mode for the action bar, you need to create a custom theme that extends an existing action bar theme and set the android:windowActionBarOverlay property to true.

<resources>
    <!-- the theme applied to the application or activity -->
    <style name="AppTheme" parent="@android:style/Theme.Holo">
        <item name="android:windowActionBarOverlay">true</item>
    </style>
</resources>

If you’re using the Support Library

<resources>
    <!-- the theme applied to the application or activity -->
    <style name="AppTheme" parent="@android:style/Theme.AppCompat">
        <item name="android:windowActionBarOverlay">true</item>
        <!-- Support library compatibility -->
        <item name="windowActionBarOverlay">true</item>
    </style>
</resources>

When the action bar is in overlay mode, it might obscure some of your layout that should remain visible. To ensure that such items remain below the action bar at all times, add either margin or padding to the top of the view(s) using the height specified by actionBarSize. For example:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingTop="?android:attr/actionBarSize">
    ...
</RelativeLayout>

If you’re using the Support Library for the action bar, you need to remove the android: prefix. For example:

<!-- Support library compatibility -->
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingTop="?attr/actionBarSize">
    ...
</RelativeLayout>

In this case, the ?attr/actionBarSize value without the prefix works on all versions, including Android 3.0 and higher.

 

Reference: http://android.xsoftlab.net/training/basics/actionbar/overlaying.html#EnableOverlay

Git – Quick Tips

Amend Last Commit Message

git commit --amend -m "New commit message"

Clean up any untracked files

Preview what’s to be deleted
git clean -n
Remove the untracked files from your workspace
git clean -f

Revert the workspace to the last committed state

git reset --hard

Writing to NTFS in OS X Yosemeti/El Capitan

If you have brewed osxfuse installed, you have to uninstall it.

brew cask uninstall osxfuse

Run the following to install Homebrew ntfs-3g which depends on osxfuse

brew update
#Install Homebrew Cask
brew install caskroom/cask/brew-cask
#Install a binary osxfuse package from Homebrew Cask
brew cask install osxfuse
#Install ntfs-3g
brew install homebrew/fuse/ntfs-3g
[El Capitan Only] [reboot by holding CMD+R to get in recovery mode]
[El Capitan Only] csrutil disable
[El Capitan Only] [reboot normally]
#Create a symlink for mount_ntfs, to make drives mount automatically
sudo mv /sbin/mount_ntfs /sbin/mount_ntfs.original
sudo ln -s /usr/local/sbin/mount_ntfs /sbin/mount_ntfs
[El Capitan] [reboot by holding CMD+R to get in recovery mode]
[El Capitan] csrutil enable
[El Capitan] [reboot normally]


Download / Export Google App Engine Logs

To download Google App Engine request logs, run something similar like this in the command prompt:

D:\Google\appengine-java-sdk-1.8.9\bin>appcfg --num_days=30 --severity=4 --request_logs D:\MyAppEngineProject\war D:\MyAppEngineProject\requests.log

–num_days=…
The number of days of log data to retrieve, ending on the current date at midnight UTC. A value of 0 retrieves all available logs. If –append is given, then the default is 0, otherwise the default is 1.

–severity=…
The minimum log level for the log messages to retrieve. The value is a number corresponding to the log level: 4 for CRITICAL, 3 for ERROR, 2 for WARNING, 1 for INFO, 0 for DEBUG. All messages at the given log level and above will be retrieved. Default is 1 (INFO).

Mac OS X – Extra Listening port for SSH

Firstly make SSH listen on an extra port, say 2222:

<key>Sockets</key>
<dict>
         <key>Listeners</key>
         <dict>
                 <key>SockServiceName</key>
                 <string>ssh</string>
                 <key>Bonjour</key>
                 <array>
                         <string>ssh</string>
                         <string>sftp-ssh</string>
                 </array>
         </dict>
         <key>Listeners2</key>
         <dict>
                 <key>SockServiceName</key>
                 <string>2222</string>
         </dict>
</dict>

Reload the file by executing:

launchctl unload /System/Library/LaunchDaemons/ssh.plist
launchctl load /System/Library/LaunchDaemons/ssh.plist