Rough Book

random musings of just another computer nerd

bAdkOde: An Esoteric Language

I’ve added another project to the projects page. It’s called bAdkOde, an interpreter for an esoteric language that I designed. The very first incarnation of bAdkOde was written in Java and I actually posted it (or made a blog entry about it) over 8 years ago. For some reason I took it down. Probably because I stopped working on it. Anyway, I redesigned the language and wrote an interpreter for it in Perl about 4 or 5 years ago. I finally got around to posting it. Check out the project page for more details. Let me know what you think.

Popularity: unranked [?]

December 13, 2009 Posted by | Java, Perl, Programming and Development, Projects | , , , , , , , , , , | Leave a Comment

An update to the Grinder testing-framework

Mukesh alerted me to a problem with the Perl conversion script (that converts the XML produced by the Grinder recorder into a Jython file). It wasn’t parsing all the parameters in a GET request properly. I’ve fixed the bug and uploaded a new version of the script. You can download it here.

Popularity: unranked [?]

December 7, 2009 Posted by | Java, Jython, Perl, Programming and Development, Python | , , , , , , | Leave a Comment

JSTL, instanceof, and hasProperty

I’ve been doing a little bit of JSTL over the past week, especially custom tags. I’ve written custom tags in Grails before, and there you use actual Groovy code. I guess this was how custom tags used to be written (in Java), but now you can can build your own custom tags using the standard tag library. The standard tag library is still pretty useful when it comes to building custom tags. Since it’s not straight Java, it forces you think really hard about your logic. You don’t want to put any business or application logic in your tag, and you want to restrict everything to view or presentation logic. A side effect of it not being Java is that if you want to do anything extremely complicated, you’re probably better off writing the tag in Java (making sure that you don’t let any business logic creep in).

While writing my own custom tag, I noticed that although instanceof is a reserved word in the JSTL EL (expression language), it is not supported as an operator. The reason I wanted to use the instanceof operator is that I have an attribute that could either be a List or a Map and depending on the type, I wanted to do different things.

Another thing I was trying to do, was to inspect the incoming object to see if it had a certain property (reflection). JSTL uses reflection so that you can access the properties of an object via dot notation, if they follow the JavaBean naming-convention. However, there was no way for me to see if an object had a certain property. To solve both these problems, I wrote my own JSTL functions.
Read more »

Popularity: 9% [?]

December 4, 2009 Posted by | Java, Programming and Development, Web | , , , , , , , , , | 6 Comments

Writing Performance Tests in Grinder using a Framework

This project is now available on GitHub.

Before reading this tutorial (if you haven’t already), please took at look at my last two tutorials (Performance Testing using The Grinder and Anatomy of a Grinder test-script). In this tutorial I’ll talk about easily writing Grinder test-scripts using a framework I designed. As a disclaimer, I’d like to point out that I’m not a Python programmer and therefore certain things may not be very python-esque. If that’s the case, I apologize. My personal opinion is that this framework is especially useful (of course, since I wrote it ;) ) for web applications where you have a already have a lot of test data. In that case, you can simply record all your discrete tasks once and then construct different scenarios with them. But if you feel differently and have some constructive criticism, I do look forward to hearing from you! Also, if you’d like to try out the framework I’ve got a tarball and a zip file available for download on the very last page.
Read more »

Popularity: 99% [?]

September 16, 2009 Posted by | Java, Jython, Programming and Development, Python | , , , , , | 40 Comments

Anatomy of a Grinder test-script

This is my second post regarding Grinder. In this post I’ll go over the anatomy of a recorder Grinder test-script. If you haven’t read my previous post, please take a look at it. Otherwise this post won’t make much sense!

High-level structure of a Grinder script

The high-level structure of a recorded Grinder-test-script looks like this:

[
...
import statements
...
]

[
...
header definitions
...
]

[
...
url definitions
...
]

[
...
request and test definitions
...
]

class TestRunner:
     [
     ...
     method definitions - a method is defined for each recorded page
     ...
     ]

     def __call__(self):
     [
     ...
     calls to defined methods, which actually runs the requests
     ...
     ]

     [ utility function (I'll go over this later) ]

     [
     ...
     calls to utility function to wrap/instrument tests (I'll go over this later)
     ...
     ]

Read more »

Popularity: 20% [?]

August 14, 2009 Posted by | Java, Jython, Programming and Development, Python | , , , , , | 12 Comments

Performance testing using The Grinder

About a month ago at work, I was trying out a bunch of different performance-testing tools to figure out which one to use to performance-test our software. I ended up discovering a tool called The Grinder which uses Jython to build performance-testing scripts that you can then use to test your application. I even built a little framework in Jython to make the test scripts more modular and reusable. Over the next few days I’ll be publishing three articles (this one included) that talk about Grinder.

Introduction

In this article I’ll go over installing and setting up Grinder. I am not going to go into too many details since my aim is to provide information that will enable you to have Grinder up and running quickly. If you want more information, you can look at the rather thorough Grinder User Guide. At the end of this guide, you’ll know how to install and set up grinder, record a test, modify (and/or parameterize) it, start running it through the console, and record data from the test. Note: The instructions in this guide relate to a Linux environment. You can run Grinder in Windows; the set-up is not much different. The only differences will be in installation locations and shell scripts. If you want more information about setting up Grinder in a Windows environment, please take a look here.
Read more »

Popularity: 32% [?]

July 27, 2009 Posted by | Java, Jython, Programming and Development, Python | , , , , , , , , | 22 Comments

Running the JavaFX 1.1 SDK on Linux

This is an update to my instructions on running the JavaFX 1.0 SDK on Linux. Those instructions do not work on the dmg image for the 1.1 version of the SDK.

Mike (thanks Mike!) posted a comment on that blog mentioning a small change that needed to be made. To get JavaFX 1.1 on Linux, first follow the steps in the original guide. When you need to mount the dmg, you need to provide an offset. So instead of the original command, do the following:

vivin@dauntless ~
$; sudo mount -o loop,offset=$((1024*17)) -t hfsplus javafx_sdk-1_0-macosx-universal.dmg.out javafx

The dmg should be mounted now.

Popularity: 1% [?]

April 30, 2009 Posted by | Java, Linux, Programming and Development | , , , , , , , , , , , , | Leave a Comment

Running the JavaFX 1.0 SDK on Linux

The JavaFX 1.0 SDK was released today. I’ve played with the preview SDK, so I was pretty excited to try out the 1.0 SDK. Inexplicably, and this was the case with the preview SDK as well, Sun hasn’t released a version of the SDK for Linux. However, this wasn’t a problem because it was possible to run the Mac version of the Preview SDK on Linux. The preview SDK came in the form of a zip, but the 1.0 SDK comes in the form of a dmg, so I was initially stumped. But I’ve figured out how to get the Mac version of the SDK to work on Linux. It’s a little more complicated than getting the preview SDK to work, but it works!

The thing about dmg files is that you can easily mount them on Linux since they are essentially stored in the HFS Plus filesystem format. So I immediately set about trying to mount it:

vivin@dauntless ~
$ mkdir javafx

vivin@dauntless ~
$ sudo mount -o loop -t hfsplus javafx_sdk-1_0-macosx-universal.dmg javafx
[sudo] password for vivin:
mount: wrong fs type, bad option, bad superblock on /dev/loop0,
       missing codepage or helper program, or other error
       In some cases useful info is found in syslog - try
       dmesg | tail  or so

Hmm… ok, that wasn’t what I expected, so I tried to see what type of file it was:

vivin@dauntless ~
$; file javafx_sdk-1_0-macosx-universal.dmg
javafx_sdk-1_0-macosx-universal.dmg: bzip2 compressed data, block size = 100k

Ok, so it look’s like it’s a bzipped file. All we need to do then, is bunzip it and mount it:

vivin@dauntless ~
$ bunzip2 javafx_sdk-1_0-macosx-universal.dmg
bunzip2: Can't guess original name for javafx_sdk-1_0-macosx-universal.dmg -- using javafx_sdk-1_0-macosx-universal.dmg.out

bunzip2: javafx_sdk-1_0-macosx-universal.dmg: trailing garbage after EOF ignored

vivin@dauntless ~
$ sudo mount -o loop -t hfsplus javafx_sdk-1_0-macosx-universal.dmg.out javafx

vivin@dauntless ~
$ ls javafx
javafx_sdk-1_0.mpkg

Awesome! So we were able to get the dmg mounted. Now all we need to do is find were the SDK lives. After going through the dmg, I found out that the SDK is stored in a compressed (gzipped) file. You can find it at <mountpoint>/javafx_sdk-1_0.mpkg/Contents/Packages/javafxsdk.pkg/Contents/Archive.pax.gz. Copy this file into another working directory (or wherever you want your SDK to reside. I put mine in /usr/local):

vivin@dauntless ~/working
$ cp ~/javafx/javafx_sdk-1_0.mpkg/Contents/Packages/javafxsdk.pkg/Contents/Archive.pax.gz .

vivin@dauntless ~/working
$ gunzip Archive.pax.gz

vivin@dauntless ~/working
$ file Archive.pax
Archive.pax: ASCII cpio archive (pre-SVR4 or odc)

When I gunzipped the file, I got Archive.pax, and I wasn’t sure what to do with it. So I ran file on it and discovered that it was a cpio file. Some quick Googling and man-page perusal later:

vivin@dauntless ~/working
$ cpio -i <Archive.pax
65687 blocks

vivin@dauntless ~/working
$ ls
Archive.pax  COPYRIGHT.html  lib          profiles     samples     src.zip                      timestamp
bin          docs            LICENSE.txt  README.html  servicetag  THIRDPARTYLICENSEREADME.txt

vivin@dauntless ~/working
$ bin/javafx

Usage: java [-options] class [args...]
           (to execute a class)
   or  java [-options] -jar jarfile [args...]
           (to execute a jar file)

where options include:
    -d32          use a 32-bit data model if available

    -d64          use a 64-bit data model if available
    -client	  to select the "client" VM
    -server	  to select the "server" VM
    -hotspot	  is a synonym for the "client" VM  [deprecated]
                  The default VM is server,
                  because you are running on a server-class machine.

    -cp <class search path of directories and zip/jar files>
    -classpath <class search path of directories and zip/jar files>
                  A : separated list of directories, JAR archives,
                  and ZIP archives to search for class files.
    -D<name>=<value>
                  set a system property
    -verbose[:class|gc|jni]
                  enable verbose output
    -version      print product version and exit
    -version:<value>
                  require the specified version to run
    -showversion  print product version and continue
    -jre-restrict-search | -jre-no-restrict-search
                  include/exclude user private JREs in the version search
    -? -help      print this help message
    -X            print help on non-standard options
    -ea[:<packagename>...|:<classname>]
    -enableassertions[:<packagename>...|:<classname>]
                  enable assertions
    -da[:<packagename>...|:<classname>]
    -disableassertions[:<packagename>...|:<classname>]
                  disable assertions
    -esa | -enablesystemassertions
                  enable system assertions
    -dsa | -disablesystemassertions
                  disable system assertions
    -agentlib:<libname>[=<options>]
                  load native agent library <libname>, e.g. -agentlib:hprof
                    see also, -agentlib:jdwp=help and -agentlib:hprof=help
    -agentpath:<pathname>[=<options>]
                  load native agent library by full pathname
    -javaagent:<jarpath>[=<options>]
                  load Java programming language agent, see java.lang.instrument

As you can see, you now have a working JavaFX 1.0 SDK on your Linux box!

Popularity: 1% [?]

December 4, 2008 Posted by | Java, Linux, Programming and Development | , , , , , , , , , , , , | 5 Comments

My new T-Mobile G1 Android Phone

So I got my T-Mobile G1 Android phone yesterday, and boy am I excited! I had mixed feelings about it initially because I wasn’t so sure of the form factor. I remember thinking that it looked a little clunky, but now that I have it here, in my hand, I have to say that it feels well-made and rather solid. The exterior is made of plastic, and it feels smooth to the touch and not cheap at all. The keyboard slides out smoothly and I’ve had no problem typing on it. The interface is pretty snappy. I was actually surprised at how smooth and responsive it was. As far as the interface is concerned, the only issue I have is with the zooming. It may just be that I haven’t figured out to activate it reliably. I guess they had to go with this method because Apple is trying to patent the “pinch” motion for zooming. I think that is completely stupid, of course, and the patent office should throw it out.

Anyway, so once I picked up the phone I opened up the package and carefully laid everything out. T-Mobile sent me another SIM card with it, which didn’t work; I guess you have to activate it. But that really wasn’t a problem since I have my old SIM card. Once I put it in the phone and hooked up the new battery, I started up the phone. When it firsts starts up, it asks you for your Google account information so that you can sync everything with your phone. As soon as it synced up (which happened within a matter of seconds), I was good to go. I started off by trying to import my contacts from the SIM card. This is where I came across a problem. Apparently (I could be wrong, I was too impatient to explore more options) you can’t import all your SIM contacts in one go. You have to do it one by one. I found that a little annoying. You can either import your contacts one-by-one, or import them all in one go by hitting the Menu button and then choosing the Import all option. As soon as I had my contacts imported, I started exploring the other options. The home screen is pretty sweet. You can drag and drop icons on there, and swipe left and right to either add more icons or run google search. In addition to GMail, you can add other POP3/IMAP accounts and you can also use other IM networks in addition to GTalk. The G1 also has a music player and a bunch of sample tracks (including Flight of the Conchord’s “The Most Beautiful Girl in the Room”). The phone doesn’t have a headphone jack, so you have to get a USB to 3.5mm converter. The Bluetooth works fine and synced up to the Hands-free Link in my Acura without any problem. Although, like the iPhone, you can’t transfer files via bluetooth. I imagine that they will fix this eventually. The phone also has a feature where you can set up a “pattern” to unlock it. You have to “draw” a pattern on the screen connecting nine dots (laid in a 3×3 grid pattern) to unlock the phone. The other cool thing was the “Compass Mode” in the Google Maps street view. The phone adjusts the street view based on where you’re pointing it, and so the scene on the phone actually moves when you move the phone. It’s pretty neat!

So, my opinion? As far as a phone (or PDA) goes, I think that the G1 is pretty solid. I know that some reviewers claimed that they didn’t think it would really appeal to most people. However, I think that it will. It has a pretty slick interface and a lot of neat features. Additionally, I think the demographic it will appeal to most, is people like me – developers and people who like to play with neat gadgets. I know that once I get some more time on my hands, I’m going to try and develop stuff on it. iPhone killer? I don’t know. But I think the G1′s strength is that it is completely open. In effect, it is the antithesis to the iPhone, or the anti-iPhone. Google doesn’t control the G1 (or Android) as strictly as Apple controls the iPhone, and especially with regard to the SDK. Google seems to want to encourage developers whereas Apple seems to want to encourage them only as long as they play by Apple’s rules. Consider also the fact that if you do want to develop for the iPhone, you can only do it on a Mac. Whereas you can develop apps that will run on Android on Windows, Mac, or Linux. I guess we’ll have to wait and see. But for now, I’m just happy to have a cool new toy er… I mean, phone!

Update

I’ve noticed a lot of queries to this blog post regarding the importing of SIM contacts into the G1. The process is quite simple:

  • Swipe the dock at the bottom of the screen upwards to access the G1′s menu.
  • Select Contacts from the menu.
  • Hit the Menu button and then select Settings
  • You should now see “Sync Groups” and “SIM contacts importer”
  • Select SIM contacts importer. You should now be able to import your contacts.
  • If you want to import them all in one go, hit Menu and then select Import all

As a general rule, if you’re having trouble finding (extra) options, hit the Menu button. It should show you a few more options.

The G1's outer box
The G1′s outer box

The G1's inner box
The G1′s inner box

The G1 inside the box
The G1 inside the box

The G1's accessories and manuals
The G1′s accessories and manuals. The accessories you get are a carrying case, battery, headphones, USB cable, and charger. Oh, and you get a SIM card too (if you ordered through T-Mobile’s website)

The G1 inside the box
The G1 inside the box

The T-Mobile Android G1
The T-Mobile Android G1

G1 side view
G1 side view

G1 keyboard flipped out
G1 keyboard flipped out

G1 home screen
G1 keyboard flipped out

G1 menu
G1 menu

G1 dialer
G1 dialer

G1 displaying Google Maps
G1 displaying Google Maps

G1 displaying Google Maps (side view)
G1 displaying Google Maps (side view)

G1 displaying Google Maps Satellite View (side view)
G1 displaying Google Maps Phoenix Satellite View (side view)

G1 displaying Google Maps Street View
G1 displaying Google Maps Street View

G1 vivin.net
G1 displaying vivin.net

The G1 in its case
The G1 in its case

Popularity: 2% [?]

October 21, 2008 Posted by | Computers, Hardware, Java, Programming and Development | , , , , , , , , , , , , , | 24 Comments

JavaFX: The New Hotness

I went to JavaOne a few months ago. It was a pretty neat experience and I learnt a lot of cool things. One of the things Sun was touting was the JavaFX family of technologies. It allows you to create RIA (Rich Internet Applications) using JavaFX Script, a domain-specific language built on top of Java. The demos were pretty impressive and it looks like Sun’s answer to Flash and Silverlight. I went to a few JavaFX sessions and I signed up for the preview SDK, which came out a few weeks ago. Since then, I’ve been playing around with the language to see what it can do. The language is pretty neat and being dynamic, has some pretty cool features like closures, list comprehension, lazy/incremental evaluation (through binding), and triggers. In addition, it uses a declarative model (although you can still use the traditional model) for describing a GUI. The API provides Swing components, but I believe the intent is to completely move away from that and use only JavaFX GUI components.

Calendar widget

Using a language that is only in preview is pretty interesting. The API is unfinished and the language isn’t completely mature, but this is to be expected. That being said, it still looks promising and seems to be a very capable and expressive language. Also, seeing as it is built on top of Java, you have access to all of Java’s rich API in addition to the numerous third-party Java libraries and API’s that are out there. I’ve been playing around with it for the last week or so and I was able to write a small calendar widget. It simply shows a month view for the current month, with the current date highlighted. I haven’t had much experience with writing GUIs in Java, so it took me a while to figure it all out. I shamelessly stole the colour gradient background from one of the demos in the preview SDK. The only issue I have right now is the load-time of the widget. It seems to take a while when you load it first. I don’t know if it has to do with the way I coded it or not. I’m pretty sure I’m not doing it the best way, but I expect to get better once I get more familiar with the language.

Here’s a screenshot of the widget running on Firefox 3 on my Ubuntu laptop (the theme is a Leopard theme):

Calendar widget

I have more details on the project page.

Popularity: 1% [?]

August 24, 2008 Posted by | Java, Programming and Development | , , , , , , , , , , , | 3 Comments

All original content on these pages is fingerprinted and certified by Digiprove