Resizing (multiple) images with IrfanView and VBScript on Windows

I’ve just created a VBScript ( Visual Basic Script ) on windows to help me automatize the process of resizing images, without having to do each photo manually.

If you want to test this little tools, be sure to download IrfanView here 

and my code here on my pastebin account .
Be sure to save the code listed as plain text ( no .rtf/.txt/.whatever stuff ) and with .vbs extension.
Feel free to modify the code and/or to leave a comment to let me know if it helped you.

Successfully tested on Windows 7 and Windows XP.


Java Installations on Windows 7

As usual, something does not work right away, and you lose those two or three hours to wander the Internet looking for useful solutions.
This time it’s the turn of Java, the java media framework package for Windows.
On Windows 7, I launched the executable, but nothing appears, then rerun several times, but still nothing appears.
I gave up and start doing other things, for ten minutes more or less, and then about 4 or 5 installers of the JMF came up on screen. Nice!

Also I remember that on Windows 7 I recently had problems with Java installations, for Matlab7.0.

The problem shared by this type of installation is a problem of compatibility of the jdk (IMHO) with Windows 7.

0. Right-click the executable installation and select the voice file properties, and then go to the compatibility section
1. tick the box to use the mode compatibility
2. choose the compatibility with Windows Vista Service Pack 2 (the really-working  compatibility option for this kind of things)
3. make sure you launch the executable as an administrator

In the end, installation starts where it didn’t started before (for matlab 7), and starts instantly (instead of waiting tens of minutes ) for JMF.
I hope that this will come in handy in some way.


This ‘trick’ also works for Tomboy notes, typical note-app for linux, also available for windows after installing gtk#

Android, BroadcastReceiver, headset controls

Power to opensource!

Because of it I could personalize an app by adding a few lines of code, without reinventing the wheel.

Goal: improve a mediaplayer app to handle headset controls events, even if the screen is off or I’m using another app (there it goes the broadcast receiver functionality).

First, main activity must implement OnKeyListener

import .........
public class MPlayer extends Activity implements OnKeyListener {...

Second, implement the method OnKeyDown

public ImageButton playButton;
public ImageButton stopButton;
public ImageButton skipButton;
  oncreate method that instantiates those buttons, by findviewbyid for example
public boolean onKey(View arg0, int arg1, KeyEvent arg2) {
// TODO Auto-generated method stub
	return false;

/* media controls */
public boolean onKeyDown(int keyCode, KeyEvent event) {
super.onKeyDown(keyCode, event);
switch (keyCode) {
		return true;
		return true;
		return true;
		return false;

Third, create the receiver

/* creating an intent filter */
private final BroadcastReceiver headsetReceiver = new BroadcastReceiver() {
public void onReceive(Context context, Intent intent) {
	String intentAction = intent.getAction();
	if (!Intent.ACTION_MEDIA_BUTTON.equals(intentAction))
	KeyEvent event = (KeyEvent) intent
	int keycode = event.getKeyCode();
	int action = event.getAction();
	Log.i("keycode", String.valueOf(keycode));
	Log.i("action", String.valueOf(action));
                 //onKeyDown(keyCode, event)
	if (keycode == KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE
			|| keycode == KeyEvent.KEYCODE_HEADSETHOOK)
			if (action == KeyEvent.ACTION_DOWN)
	if (keycode == KeyEvent.KEYCODE_MEDIA_NEXT)
			if (action == KeyEvent.ACTION_DOWN)
	if (keycode == KeyEvent.KEYCODE_MEDIA_PREVIOUS)
			if (action == KeyEvent.ACTION_DOWN)



/* unregistering intent receiver */

public void onDestroy() {

Last, registering the intent receiver in onCreate method

/** Called when the activity is first created. */
public void onCreate(Bundle savedInstanceState) {
		/* creating and registering intent receiver */
	IntentFilter mediaFilter = new IntentFilter(Intent.ACTION_MEDIA_BUTTON);
	registerReceiver(headsetReceiver, mediaFilter);

Last but not least, even if you declare and register the intent receiver via code, you can also add a couple of lines of code in your app manifest

<activity android:name=".MPlayer" android:label="@string/app_name">
		<action android:name="android.intent.action.MAIN" />
		<category android:name="android.intent.category.LAUNCHER" />
	<intent-filter android:priority="1000000000">
		<action android:name="android.intent.action.MEDIA_BUTTON" />

Sources: various( I mean VARIOUS, like ALOT) android articles, android developers docs and google results and my working app. Headset finally plugged in and controls being used!

Try (hd0,0): NTFS5: No wubildr

UPDATE(for those who want to follow this guide or have already followed in past times): Gnu grub shell might appear if you are going to install another linux distribution using wubi, let’s say another version of ubuntu. This is due to the fact that you’ve removed ubuntu but not the wubildr files in the hidden partition(trick to get wubi working on windows, shown later in this article), and they must be updated to perform a new installation…more here

You’ve just installed your brand new ubuntu 10.10, then you reboot, and…

Try (hd0,0): NTFS5: No wubildr


And this for about 1 or 2 minutes! then ubuntu boots up..

The problem is that an hidden partition that windows 7 creates, reserved for the system, about 100mb in size, keeps our loader from ..well.. LOADING our O.S..

How to solve:

  1. go to “File System”\host\ubuntu\winboot     and copy ALL of its content.
  2. go to (and mount with double-left-click) “System Reserved” and paste ALL you’ve COPIED in step 1.
  3. then you can reboot and no-more-hanging of our loader, that finally..well..LOADS..

UPDATE: Where does this hidden partition come from? Here’s a pic from the installation process of windows 7!

Experiencing with kSoap 2 and complex objects

As usual, I stumbled upon a problem, but this time during application development for Android.(Jump right into the problem explanation)

Imagine having to develop the application so that it can communicate with a webservice that you have already built some sort of programming language, such as in Java by using Axis2 (maybe in version 1.5.1) and a tomcat server (maybe in version 6).

kSoap 2 is an API designed to enable communication between mobile applications programmed in Java and web services.

I’m not very experienced in the use of this API, but it seemed a common problem of many people who use it, the impossibility of working with a list of objects, or rather with arrays of objects coming back as a result of a method of ur webservice.

Since my problem was a ClassCastException, due to the impossibility of casting the type ‘anyType‘ into something useful, like an object of my creation, or maybe an array of my objects, the solution was found using a method similar to Russian dolls.

Now let me explain better.

In the side of the web service application, you use data types that you created through the classes, but maybe you should call them by their name objects.

These objects are Java Beans suitably designed to be serialized into SOAP messages through the use of Axis2.

Axis2 supports the return lists of objects, so that through the use of SoapUI you can read the SOAP message response from the webservice and note the list of returned items. Even more, in the WSDL file that describes the web service, the return value of this method is marked as ‘sequence‘ object of our type.

The problem is kSoap that fails to convert and manage complex data type as the array of our objects, declaring it as ‘anyType‘.

Fortunately it is possible to decompose the object ‘anyType‘ for extracting fields(actually is a SoapObject, and we can use his methods like .getProperty(index) and .getPropertyCount() ).

The problem is that it does not handle arrays, it only returns the first object instead of the whole list. At this point I had to create an additional class that enclose my array of objects and then I edited the method of the webservice to return this new ‘wrapper‘ object.

kSoap doing so receives a single object that contains within it a sequence of objects that make up the array correctly serialized by Axis2. Here is an explanation of the Russian dolls.A big complex and custom object that include small complex objects.

Is our task in the client side of android, provide to the unwrapping of the object, that is remapped into the corresponding complex-object instances.
This is not a solution but a patch to the problem, a patch that I decided to take as we have upcoming deadlines on the development/deployment of the application.

Here is a picture to express a thousand words I wrote and made you read so far.

Drawing done with Balsamiq Mockups (for Desktop [demo]).

Here is a sample of code that unwraps soapObjects using .getProperty(index) and .getPropertyCount().





first I create my array of AccessoBean objects, then I give it to  the

.setListaAccesso(AccessoBean[] list)

method of my ArrayOfAccessoBean wrapper object.

My object  ‘AccessoBean’

My wrapper object for an array of  ‘AccessoBean’ (how to do a simple wrapper class)

So, instead of returning an array( ‘list’ of objects ), I’m returning a single object that contains my array of objects.

Please let me know if you solved this problem in another and/or more elegant way!

Rails and rust

It’s almost a day that I’m trying to get things working in here.

I’ve set-up a small home server (actually is my old HP laptop running ubuntu 10.04) with some server applications like apache, mysql-server and other stuff like php5, ruby, and RAILS.

So reading TFM, I’ve installed ruby, then gems and finally rails…

My command history looks something like this:

sudo apt-get install ruby rubygems ...
gem install -y rails

Then I used the rails command to build a new web application, and then I’ve tested if all worked correctly

rails blog
cd blog
ruby script/server

Directed my browser to the famous address(localhost:3000), first I’ve got the message

Welcome aboard

then I decided to refresh the page and then I’ve got

Internal Server Error
private method `gsub!' called for #<Class:0xb6ff44dc>

After that, it been a long road until now, with installs , remove , clean, installs of various combinations of ruby and rails versions…untile I finally decided to give up.

For the last time I was installing RoR, but this time I tried without installing ruby and gems, but I let ubuntu install rails for me

sudo apt-get install rails

After this last command I found that ubuntu installs all that you may need for rails, with only one command.

‘Finally!’ – I said! Let’s try this time if it works!!

Not yet.

‘Maybe there is a problem with WEBrick!’ – I thought, and I’ve installed another ‘web server’ for rails, called Mongrel, and used that to launch my first web app.

sudo apt-get install mongrel
ruby script/server mongrel

Well, in this image, you can find the answer that I found at each refresh of the page…

Welcome aboard!!

…well, thanks man!

Let the journey with rails begin!