A script for adding multiple twitter follows….

@magitam had an interesting problem and I had an itch to try out the python-twitter API.

follow.py is the result.

Usage: ./follow.py <twitter username> <twitter password> <filename.csv>”)

Copy the code above and save it using notepad as follow.py

You will need a python interpreter and the python-twitter API to run it. Tested on Linux but should run anywhere.

The input file can be either:

friend1

friend2

friend3

or

friend1,friend2,friend3

or

friend1,friend2

friend3

Disclaimer: I will not take responsibility for loss of life, revenue, sex drive, property or any negative consequence suffered as a result of using the above code.

Source Code for masaajid map…

Though I’d share the code for those interested in how I did the masaajid maps:

<gm:page title=”Masaajid in South Africa” authenticate=”false” onload=”kmlPE()” gadget=”true”>
<!–
The mashup application demonstrates taking a Google Earth KML file and mapping it on a Google Map.
@author: GME Team & Valery Hronusov
–>
<h2>Masaajid in South Africa</h2>
<!– Map definition –>
<gm:map id=”map” height=”600px” width=”800px”
lat=”-28.7500″ lng=”24.7700″ zoom=”5″ maptypes=”true”/>
<script>
function kmlPE()
{
var myMap = google.mashups.getObjectById(‘map’).getMap();
var geoXml = new GGeoXml(“http://yusufk.googlepages.com/masjids.kml”);
myMap.setMapType(myMap.getMapTypes()[0]);
myMap.addOverlay(geoXml);
myMap.enableDoubleClickZoom();
}
</script>
</gm:page>

The above code can be easily pasted/ test using the Google mashup editor.

Webservices on a J2ME mobile device

My latest experimenting with J2ME has led me to webservices. I’ve
managed to communicate with several online webservice providers
including http://www.xmethods.net/ and http://www.google.com/apis/ . I
managed to do this using the small footprint SOAP package kSOAP
http://ksoap.enhydra.org/ or http://www.ksoap.org/ .Here is a copy of
the template java midlet that I use to communicate to web-services
with:

Template.java

import java.io.IOException;

import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Form;
import javax.microedition.lcdui.ImageItem;
import javax.microedition.lcdui.StringItem;
import javax.microedition.lcdui.TextBox;
import javax.microedition.lcdui.TextField;
import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;

import org.ksoap.SoapObject;
import org.ksoap.transport.HttpTransport;

/**
* @author Yusuf
*
*/
public class Template extends MIDlet implements CommandListener {
private Display display;

private String url = “”;

private String nameSpace = “”;

private String name = “”;

private String key = “”;

private Command sendCommand;

private Command exitCommand;

private Command backCommand;

private StringItem stringItem;

private Form form1;

private TextField textField1, textField2;

private String choice;

private ImageItem background;

public Template() {
display = Display.getDisplay(this);
stringItem = new StringItem(“”, “”);
textField1 = new TextField(“Input 1:”, choice, 30,
TextField.ANY);
textField2 = new TextField(“Input 2:”, choice, 30,
TextField.ANY);
exitCommand = new Command(“Exit”, Command.EXIT, 1);
sendCommand = new Command(“Invoke”, Command.SCREEN, 1);
backCommand = new Command(“Back”, Command.BACK, 1);
background = new ImageItem(“”, null,
ImageItem.LAYOUT_CENTER, “no pic”);

// TODO Auto-generated constructor stub
}

/*
* (non-Javadoc)
*
* @see javax.microedition.midlet.MIDlet#startApp()
*/
protected void startApp() throws MIDletStateChangeException {
form1 = new Form(“Webservices”);
try {
//background.setImage(Image.createImage(“/google.png”));
url = getAppProperty(“URL”);
nameSpace = getAppProperty(“NAMESPACE”);
name = getAppProperty(“NAME”);
key = getAppProperty(“KEY”);
//form1.append(background);
form1.append(textField1);
form1.append(textField2);
form1.append(stringItem);
form1.addCommand(sendCommand);
form1.addCommand(exitCommand);
form1.setCommandListener((CommandListener)
this);
display.setCurrent(form1);

// TODO Auto-generated method stub

} catch (Exception e) {
// TODO Auto-generated catch block
System.out.println(e);
e.printStackTrace();
}

}

/*
* (non-Javadoc)
*
* @see javax.microedition.midlet.MIDlet#pauseApp()
*/
protected void pauseApp() {
// TODO Auto-generated method stub

}

/*
* (non-Javadoc)
*
* @see javax.microedition.midlet.MIDlet#destroyApp(boolean)
*/
protected void destroyApp(boolean arg0) throws
MIDletStateChangeException {
// TODO Auto-generated method stub

}

public void doInvoke(String in1, String in2) throws Exception {
StringBuffer stringBuffer = new StringBuffer();
TextBox textBox = null;
SoapObject client = new SoapObject(nameSpace, name);
//client.addProperty(“LKEY”, “0”);
//client.addProperty(“FromName”, “Yusuf”);
//client.addProperty(“ToUserID”,
“yusufk18@hotmail.com”);
//client.addProperty(“Message”, “Watse”);
//client.addProperty(“CityName”, “Pretoria”);
//client.addProperty(“CountryName”, “South Africa”);
//client.addProperty(“myString”, “hello”);
client.addProperty(“FromCurrency”, in1);
client.addProperty(“ToCurrency”, in2);
HttpTransport ht = new HttpTransport(url, nameSpace);
try {
stringBuffer.append(ht.call(client));

} catch (IOException e) {
// TODO Auto-generated catch block
System.out.println(e);
e.printStackTrace();
System.out.println(client.getNamespace());

}
stringItem.setText(stringBuffer.toString());
System.out.println(stringBuffer);
}

/*
* (non-Javadoc)
*
* @see
javax.microedition.lcdui.CommandListener#commandAction(javax.microedition.lcdui.Command,
* javax.microedition.lcdui.Displayable)
*/
public void commandAction(Command command, Displayable arg1) {
if (command == sendCommand) {

Thread t = new Thread() {
String input1 = textField1.getString();

String input2 = textField2.getString();

public void run() {
try {
doInvoke(input1,
input2);
} catch (Exception e) {
e.printStackTrace();
}
}
};
t.start();

} else if (command == backCommand) {

display.setCurrent(form1);

}

else if (command == exitCommand) {
try {
destroyApp(false);
notifyDestroyed();
} catch (Exception e) {
e.printStackTrace();
}

}

}

}


This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
MailScanner thanks transtec Computers for their support.

J2ME and JSP advances

I’ve managed to get a stable development environment going using:
Tomcat 5.0
Eclipse 3.0 RC1
Plugins:
eclipseme-0.4.5
net.sf.solareclipse_0.4.0.bin.dist.zip NOT 0.4.1 (cant save JSPs)
tomcatPluginV3beta.zip

Works like a charm!


This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
MailScanner thanks transtec Computers for their support.