Skip to content

Instantly share code, notes, and snippets.

@ltddev
ltddev / PythonistaConsoleTests.py.py
Created March 19, 2014 22:00
PythonistaConsoleTests.py
# PythonistaConsoleTests.py
# This script uses the custom console module and all exposed methods.
import console
# Clears all content from the console.
console.clear()
console.show_activity()
# Display a clickable web link which is opened in default browser or a specific one
# for atypical protocols.
@ltddev
ltddev / Text2Speech.py
Created March 27, 2014 19:53
Text2Speech
import console
import speech
title = "Text 2 Speech"
message1 = 'This Text to Speech application will speak the words you enter.'
speech.say(message1, "en-US", 0.2)
message2 = "Enter the text you want me to say, then click the 'Speak it!' button"
speech.say(message2, "en-US", 0.2)
textToSpeak = console.input_alert(title, message2,"Hello!","Speak it!")
speech.say(textToSpeak, "en-US", 0.2)
@ltddev
ltddev / HttpServletInvocationRequests.py
Created March 27, 2014 20:22
HttpServletInvocationRequests
'''
HttpServetInvocationRequests.py
This script aims to demonstrate the same servlet invocation using a basic
REST architecture but instead of using the urllib2 which is part of the
standard Python library it uses Requests (which Pythonista supports)
library which is intended to be far less verbose and a much simpler api.
The target servlet represents the entry point of any sevice or extension
of the web server. in this simple use case it simply prepares a Java
@ltddev
ltddev / HttpServletInvocationTests.py
Created March 27, 2014 20:22
HttpServletInvocationTests
'''
HttpServletInvocationTests.py
A simple test harness to invoke servlet on web server to provide a simple
REST architectured service, in this simple test case a servlet that simply
returns the string format of a Java Date object instance. this is chosen
because of its simplicity but also because re-running it clearly shows
that the output is dynamic and not static and so fits nicely with the
REST architecture I am attempting to build serverside and the REST client
running on the mobile device. for this test case/Usecase I am using
@ltddev
ltddev / RestTimeClient.py
Created March 27, 2014 20:23
RestTimeClient
'''
RestTimeClient.py
This script provides s simple one-function REST client to a "Date and Time
Service" running as as REST service on a remote server. It uses the Requests
api and the various alert dialogs in the Pythonista console module to both
get input and recieive output from thid 'service'. in addition it uses the
clickable link method of the same console module to invoke the same service
whose output is simply written to the console. Thus it provides two simple
frameworks to build REST clients for ios.
@ltddev
ltddev / CalcClient.py
Created April 5, 2014 20:40
Pythonista Scripts
import console # for clear() method
# Notice you can list multiple files/compostion units with a single from..import statement.
# if the package is small you can accomplish same thing with:
# from calc import *. For a large package that you are importing a small subset, it is probably
# more efficient to import individual files either as below or with multiple imports, very similar
# to the way its done in Java.
from calc import add, subtract, multiply, divide
#from calc import *
@ltddev
ltddev / CalcClient.py
Created April 5, 2014 20:44
Pythonista Scripts
import console # for clear() method
# Notice you can list multiple files/compostion units with a single from..import statement.
# if the package is small you can accomplish same thing with:
# from calc import *. For a large package that you are importing a small subset, it is probably
# more efficient to import individual files either as below or with multiple imports, very similar
# to the way its done in Java.
from calc import add, subtract, multiply, divide
#from calc import *
@ltddev
ltddev / test_aima.py
Created April 6, 2014 08:16
test_aima
'''
test_aima.py - this is a simple test harness to test making a module
out of the aima python library (the library used in the book "Artificial
Intelligence - A Modern Approach, 3rd Edition, 2010") then calling a
single method in the logic.py composition unit in a Pythonista script.
If successful, I plan to do further experiments of machine learning. Note
that aima python is a pure python module with no special dependencies and
therefore is a module Pythonista can currently handle without numpy and
scipy which are not pure python libraries and Pythonista v1.4 cannot
make use of modules that have non-python dependencies.
@ltddev
ltddev / HelloWorld_.idea_.name
Created April 7, 2014 03:35
Learning about Python modules and import sequences.
HelloWorld
@ltddev
ltddev / ImportNltkData.py
Created April 15, 2014 04:45
ImportNltkData
'''
ImportNltkData.py - This scriot is a wrapper to invoke the NLTK downloader
in an interactive commanline format. It will first try to, by default, call
the graphical downloader, but once it finds no support for the graphical
mode it, which is currently the case for Pythonista, it falls back to the
non-graphical, interactive mode which is still quite useful to list and
download some or all of the data sets or copora. When the downloader
comes up it presents the following to the user:
<open file 'NLTK_DATA', mode 'r' at 0x5c7c338>