Geek Quickies

Stories from the cloudvergence.

Mirror a Git Repository Through SSH

Redmine can show the timeline of a Git repository but this repository needs to be local (see here). When you host your repository externally (on GitHub, for instance), you need to synchronize your remote repository on your Redmine server.

The following shell script is an All in one command that can be easily put in the crontab to mirror the repository on your Redmine server :

Checking Google Play Signatures on .Net

With In-App Billing on Android, each time a purchase occurs, your application receives a JSON payload containing information about the purchase, as well as its signature with your developer certificate.

Google encourages you to verify that the signature is valid to authentify the purchase. You can do that inside the application, but if the delivery of the purchase involves a server, it is better to do it on the server to prevent client code manipulation. The following show how to do it on .Net server application.

Avoid Thread Issues While Testing an Android Service

The Android Test Framework provides many tools to test parts of an Android application, and the ServiceTestCase in particular to test your Service classes.

This class is quite useful but you may find yourself scratching your head because your test does not work like it should. This happens in particular if you’re doing some background work in your service, relying for example on AsyncTask for it.

Read on if you want to understand why it doesn’t work and find a solution for it.

Unlock and Root a Nexus Device

Having an unlocked and rooted device provides several advantages :

  • Easy backup and restore with Nandroid backup,
  • Easy firmware replacement and updates installation,
  • Advanced debugging capabilities.

The following instructions allow unlocking and rooting a Nexus device (Galaxy Nexus, Nexus 7) from the command line on a Linux machine. It involves:

  • Backuping your device,
  • Unlocking the bootloader,
  • Restoring the backup,
  • Rooting the device.

Quickly Deploy a Git Project on a Server With SSH

So you have this brand new project my_project of yours with your local Git repository set up and you want to quickly make it available for others to clone on your repository server.

All your projects are located in your server git.mycompany.com under /srv/git. You’re using the user named git to connect to your server with the SSH private key located in ~/.ssh/git.

Here is the quickiest way to deploy your projet:

Running Django Under Windows With IIS Using FastCGI

Update: The configuration process described in this post can be achieved with only one management command if you install the django-windows-tools application.

Windows is probably not the best production environment for Django but sometimes one doesn’t have the choice. In that case, a few options aleardy exist, most notably the one developed by helicontech that relies on Microsoft’s Web Platform Installer. This solution, which is described here, relies on the installation of a specific native Handler developed by Helicontech.

This handler manages the communication between IIS and the Django application through the FastCGI protocol with the help of a little python script that bridges FastCGI to WSGI. This script is derived from the Allan Saddi flup package that is already used by Django in the manage.py runfcgi command. The flup package doesn’t work under Windows and Helicontech has made the necessary adaptations to make it work with its handler.

Since its version 7, IIS does however support FastCGI natively, so the use of a specific handler to support Django is not needed. This post describes how to configure and run a Django application with the native FastCGI IIS handler. For that, I have myself adapted the Helicontech FastCGI to WSGI script to make it a Django management command.

Using Eclipse Templates to Ease Android Logging

Adding logs to your Android source code is sometimes the only way to really understand what happens , especially in asynchronous situations.

If you are lazy like me, you may insert lazy logs like this one:

1
  Log.v("#LOOK#", "onStart()");

Instead of having less lazy code like:

1
2
3
4
5
6
7
8
9
10
public class SomeActivity extends Activity {
  private static final String LOG_TAG = SomeActivity.class
          .getSimpleName();
  private static final int LOG_LEVEL = Log.VERBOSE;
...

    @Override
    public void onStart() {
      if (LOG_LEVEL <= Log.VERBOSE)
          Log.v(LOG_TAG, "onStart()");

But Eclipse can easily help you to avoid this and then the need to clean up your code after debbuging.

Get the Height of the Status Bar in Android

Sometimes in Android, the flexible layout system is not flexible enough and you need to make some computations inside your code. In these computations, you may need to subtract the size of the status bar. Stackoverflow gives you some answers, but they all rely on the fact that te status bar is shown at the time you make your computation. If you are in full screen mode, by having called for instance:

1
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN)

It doesn’t work.