Tuesday, June 18, 2013

HTC One + I-Blason PowerGlider + Moga Pro Review

I bought the I-Blason PowerGlider battery pack thinking that it would fit in a moga pro for extended gameplay use, because there was a review somewhere in xda that the mophie doesn't fit in the moga pro. So here is a quick video to demo it altogether.


It does fit, but it can slip its heavy and hard to play while laying head up because the moga pro grip don't have a lock it might be the same issue with htc one alone. Although in the video it doesn't drop it does feel that it might, but it still fits which is the most important.

Here are more photos:



I used the moga tablet stand cause the HTC One + PowerGlider is too heavy to stay upright. For battery life, I've never ran out anymore, although sometimes I remove it and charge it by itself so I can still use the phone and never had to charge it directly. Beware though it only has half the mAh output of the charger, people say its fine but I really don't know how it would affect its battery.

Connecting the moga pro to my phone seems to disconnect the wifi, not sure if this is a common issue. It is having hard time to find the controller with wifi on. Other than that everything seems smooth, the moga is very responsive.


Friday, June 14, 2013

Google App Engine VirtualEnv Tool that is not virtualenv for Python

When I build app engine projects and I want to include python package, what I do is download the source and symlink/include it in the project. I have tried the virtualenv approach but it didn't feel clean and I couldn't find anything that will suit my needs in a simple way. So I created this new tool called gaenv which will automate installation/linking of your installed packages to your gae project, it doesn't really need to be a gae project since what it does is just create a folder of symlinks following your requirements.txt so this can be useful to any container base deployment packages that follows symbolic links.

Installation & usage:
    # Note that if you install on a system with multiple python, 
    # you need to call the correct binary on which it looks up packages
    $ sudo pip install gaenv
    $ cd to/your/gae-project
    # Create your requirements.txt & run this to install it
    $ pip install -r requirements.txt
    $ gaenv

That's it, this should create a folder named gaenv_lib on the same path you execute it on and if you said "y" on the detect insert import it will look into your app.yaml and try to add import gaenv_lib before any other import happens. You should just do it manually if you have complex  setup on your project, what it basically does is simply add gaenv_lib in sys.path. To overwrite those names you can check with gaenv -h

To people that haven't experienced using requirements.txt it's basically a list of your python packages  per line. Then using pip install -r requirements.txt just install them all. gaenv follows the same format. Here is a sample:

boto>=2.8.5
peewee
flask==0.9


You can download and install manually at
https://pypi.python.org/pypi/gaenv
it's also on github at
https://github.com/faisalraja/gaenv

Hope someone finds it useful as I did. Enjoy.

Also note that this shouldn't stop you from using virtualenv with all your gae compatible packages then just run install gaenv on that virtualenv and run the binary from it's bin folder, this way you just maintain one virtualenv.
Tuesday, June 11, 2013

Windows Process Monitor Script in Python

I have a windows desktop that is always tunneled to some server for reason that is not important. I use kitty.exe an improved putty with auto re-login and more, but only needed that feature that's why I'm using that. But for some reason it stops responding if a lot of traffic has passed to the tunnel and it has now happened too frequent that I just had to auto restart it, there might be softwares that does this already but here is what I did using python. This should be reusable with any process just change the variable names you want to monitor.


import os
import subprocess
import time

__author__ = 'faisal'

# Change this if you want to monitor a different process
process_name = 'kitty.exe'
# Separate your parameters
start_command = ['C:\Applications\Putty\kitty.exe', '-load', 'MyTunnelSession']
# Sleep time in seconds before checking again
sleep_time = 60


while True:
    # Filter a list of windows process that has stopped responding
    r = os.popen('tasklist /FI "STATUS eq Not Responding"').read().strip().split('\n')
    for p in r:
        if p.startswith(process_name):
            # It's a quick script so just go get the
            # first # valid info which is the PID
            d = p.split(' ')
            d.pop(0)
            i = d.pop(0)
            while not i:
                i = d.pop(0)
            # Kill by PID
            k = os.popen('taskkill /F /T /PID %s' % i).read()
            print k

    # Now we check if kitty.exe is running then run it if its not loaded
    r = os.popen('tasklist /FI "STATUS eq Running"').read().strip().split('\n')
    found = False
    for p in r:
        if p.startswith(process_name):
            found = True

    if not found:
        with open(os.devnull, 'wb') as devnull:
            subprocess.Popen(start_command, stdout=devnull, stderr=subprocess.STDOUT)

    print 'Running time: %s' % time.time()
    time.sleep(sleep_time)

Also let this start your process instead of having it already started.