Monday, August 13, 2012

Simple HTTP server using Python

1) Change to your www directory, a location of your files, include at least index.html:

$ cd /Users/uki/Python/web/SimpleHTTPServer/www 

2) Start server at port you want:

$ python -m SimpleHTTPServer 8080

3) Open: http://localhost:8080/

4) Monitor requests:

uki:www uki$ python -m SimpleHTTPServer 8080
Serving HTTP on port 8080 ... - - [13/Aug/2012 20:21:00] "GET / HTTP/1.1" 200 - - - [13/Aug/2012 20:21:00] code 404, message File not found - - [13/Aug/2012 20:21:00] "GET /favicon.ico HTTP/1.1" 404 - - - [13/Aug/2012 20:21:12] "GET / HTTP/1.1" 200 - - - [13/Aug/2012 20:21:12] code 404, message File not found - - [13/Aug/2012 20:21:12] "GET /favicon.ico HTTP/1.1" 404 -

Transparent Button with an Icon

To create a button that is wide enough to press, but transparent, with the icon inside:     

                android:src="@drawable/save" />

Friday, August 10, 2012

svn: Commit failed

svn: Commit failed (details follow):
svn: Directory '/trunk/XYZ' is out of date


Delete the project including the source files and check it out again.

Conversion to Dalvik format failed with error 1

java.lang.IllegalArgumentException: already added: Lcom/androidquery/AbstractAQuery;

[2012-08-09 22:41:36 - Yachts and Tall Ships] Dx 1 error; aborting
[2012-08-09 22:41:36 - Yachts and Tall Ships] Conversion to Dalvik format failed with error 1


Once again, I looked thru all sub projects (library projects) and noticed that I have android-query-0.22.10.jar included twice in two library project libs folders.

I moved the jar to what we call lib_common/libs and referenced that jar from there everywhere I needed.

Do not include the same class name in different library projects, use a single common project were you keep your commonly used jars.

Wednesday, August 8, 2012

Format JSON in free TextWrangler

Here is an easy way to get formatted JSON in FREE TextWrangler:

Create text (Python) file:
~/Library/Application\ Support/TextWrangler/Text\ Filters/Format\

import fileinput
import json
if __name__ == "__main__":
  text = ''
  for line in fileinput.input():
    text = text + ' ' + line.strip()    
  jsonObj = json.loads(text)  
  print json.dumps(jsonObj, sort_keys=True, indent=2) 

or shorter:

import fileinput
import json
print json.dumps( json.loads(''.join([line.strip() for line in fileinput.input()])), sort_keys=True, indent=2)

Save it and use it!

It take time and effort to create tutorials, please support my efforts with a couple dollar donation, any amount will be greatly appreciated!