Flask in Windows

I’m using Python 2.7.17 on Windows 8, virtualenv already installed (pip install virtualenv), here’s my simple step to create hello world style app

$ set FLASK_APP=app.py
$ set FLASK_ENV=development
$ virtualenv venv
$ cd venv/Scripts
$ activate
$ pip install flask
$ cd ..
$ touch app.py
$ subl app.py
from flask import Flask

app = Flask(__name__)

def welcome():
return '<p>welcome to the jungle</p>'

if __name__ == '__main__':
$ python app.py


$ flask run
Then, point browser to http://localhost:5000


VirtualBox – Change Focus from Guest to Host and Vice Versa (Windows Host)

I use Windows 7 host with Ubuntu Server and Centos Minimal guest, sometimes when I move mouse cursor into virtualbox window it will disappear, even I’ve tried to move the mouse everywhere the cursor could not appear outside virtualbox window. I just found that pressing RIGHT CTRL key will bring the cursor back outside virtualbox window

Create Your First Android App in Windows 7

1. install nodejs
2. npm install -g phonegap
3. npm install -g cordova

1. install java sdk
2. set JAVA_HOME environment variable. eg: JAVA_HOME=C:\Program Files\Java\jdk1.8.0_05
3. add JAVA’s bin folder to PATH environment variable, eg: C:\Program Files\Java\jdk1.8.0_05\bin

1. copy to desired location, eg: C:\dev
2. set ANDROID_HOME environment variable, eg: ANDROID_HOME=C:\dev\adt-bundle\sdk
3. add ANDROID’s tools and platform-tools folder to the PATH environment variable, eg: %ANDROID_HOME%\tools;%ANDROID_HOME%\platform-tools

1. copy to  sdk/tools folder
2. set ANT_HOME environement variable, eg: ANT_HOME=C:\dev\adt-bundle\sdk\tools\ant
3. add ANT’s tools and bin folder to PATH environment variable, eg:  %PATH%\tools;%ANT_HOME%\bin


java -version
java version “1.8.0_05”
Java(TM) SE Runtime Environment (build 1.8.0_05-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.5-b02, mixed mode)

ant -version
Apache Ant(TM) version 1.9.3 compiled on December 23 2013

cordova -version

phonegap -version

$ cordova create hello com.example.hello “HelloWorld”
$ cd hello
$ cordova platform add android
$ cordova build
$ cordova emulate android

deploy to the device (enable USB DEBUGGING first, the connect the device via USB)
$ cordova run android

PHP – Enable FileInfo in Windows

1. Add php_fileinfo.dll to the list of enabled extensions 


2. Download GNU file package for windows
get it from here: http://gnuwin32.sourceforge.net/downlinks/file-bin-zip.php

Extract the folder from the archive called shared\file which contains 4 magic files (magic, magic.mgc, magic.mime, magic.mime.mgc).

3. Place these 4 files in a known place

4. Add system enviroment variable MAGIC that points to the file called magic. For example if you placed magic files in folder called magic in c:\php that means that the propper path is c:\php\magic\magic

5. If you use IIS restart it and fileinfo is ready for use

5a. If you use apache you will have to restart operating system for the service to acknowledge MAGIC env. variable.




PHP, Crystal Report, MS SQL Server

PHP 5.1.6, MSSQL2005 and Crystal Report Server XI RL2

//- Variables – for your RPT and PDF
echo “Print Report Test”;
$my_report = “D:\\Folder1\\SubFolder1\\Report.rpt”; //
rpt source file
$my_pdf = “D:\\Folder1\\SubFolder1\\Report.pdf”; // RPT export to pdf file
//-Create new COM object-depends on your Crystal Report version
$ObjectFactory= new COM(“CrystalReports115.ObjectFactory.1”) or die (“Error on load”); // call COM port
$crapp = $ObjectFactory-> CreateObject(“CrystalDesignRunTime.Application”); // create an instance for Crystal
$creport = $crapp->OpenReport($my_report, 1); // call rpt report

// to refresh data before

//- Set database logon info – must have
$creport->Database->Tables(1)->SetLogOnInfo(“servername”, “DBname”, “user”, “password”);

//- field prompt or else report will hang – to get through
$creport->EnableParameterPrompting = 0;

//- DiscardSavedData – to refresh then read records
//export to PDF process
$creport->ExportOptions->DiskFileName=$my_pdf; //export to pdf
$creport->ExportOptions->DestinationType=1; // export to file
$creport->ExportOptions->FormatType=31; // PDF type

//—— Release the variables ——
$creport = null;
$crapp = null;
$ObjectFactory = null;

//—— Embed the report in the webpage ——
print “





Windows – Set JAVA_HOME

Stage 1. Locate the JRE Installation Directory

If you already know the installation path for the Java Runtime Environment, go to Stage 2 below. Otherwise, find the installation path by following these instructions:

  1. If you didn’t change the installation path for the Java Runtime Environment during installation, it will be in a directory under C:\Program Files\Java. Using Explorer, open the directory C:\Program Files\Java.
  2. Inside that path will be one or more subdirectories such as C:\Program Files\Java\jre6.

Stage 2. Set the JAVA_HOME Variable

Once you have identified the JRE installation path:

  1. Right-click the My Computer icon on your desktop and select Properties.
  2. Click the Advanced tab.
  3. Click the Environment Variables button.
  4. Under System Variables, click New.
  5. Enter the variable name as JAVA_HOME.
  6. Enter the variable value as the installation path for the Java Development Kit.
    • If your Java installation directory has a space in its path name, you should use the shortened path name (e.g. C:\Progra~1\Java\jre6) in the environment variable instead.
  7. Click OK.
  8. Click Apply Changes.
  9. Restart Windows. (This is not always necessary, but it often prevents problems.)
  10. If you are running the Confluence EAR/WAR distribution, rather than the regular Confluence distribution, you may need to restart your application server.