Wednesday, February 26, 2014

Ramdisk automation

I have replaced the HDD of my laptop with SSD. The speed increase was amazing. The drawback is that the frequent compilation could use up the storage quickly.
Ramdisk was proposed to be used for cache area of browsers and I have also found some interesting posts about persistent ram disk usage.
The point was to get rid of the frequent update of the files in the target directory of my java projects (that was typically caused by mvn clean install/package).

I have put together a nice little script that replaces the current working directory with an in-memory version. It also takes care of synchronizing back the data every once in a while.

#! /bin/sh 
#
if [ -z "$2" ]
then
  echo "Usage: bin/ramdisk.sh {start|stop|sync} {dir}"
  exit 1
fi
 
case "$1" in
  start)
    mkdir -p /tmp/$2
    rsync -aF $2/ /tmp/$2
    mv $2 $2.save
    ln -s /tmp/$2 $2
    crontab -l | cat - $2/.crontab | crontab -
    ;;
  sync)
    echo [`date +"%Y-%m-%d %H:%M"`] Ramdisk Synched to HD >> log/ramdisk_sync.log
    rsync -aF --delete --recursive --force /tmp/$2/ $2.save
    ;;
  stop)
    echo [`date +"%Y-%m-%d %H:%M"`] Ramdisk Synched to HD and STOP >> log/ramdisk_sync.log
    crontab -l | sed -e "\,$2,d" | crontab -
    rm $2
    rsync -aF --delete --recursive --force /tmp/$2/ $2.save
    mv $2.save $2
    rm -rf /tmp/$2
    ;;
  *)
    echo "Usage: bin/ramdisk.sh {start|stop|sync} {dir}"
    exit 1
    ;;
esac

exit 0

It seems just good enough.
The point is that I put a .crontab file in the working directory, so each project can define its own synchronization policy.
The typical crontab file looks like this:
*/10 * * * * bin/ramdisk.sh sync proj/xpbydoing
Happy ramdisk usage!

Wednesday, August 21, 2013

SCP could fail

What could go wrong with scp?

Recently I am using Oracle Developer Day virtual machine to test Oracle DB. Transferring files between the host and the VM by scp failed as both .bash_profile and .bashrc of the oracle user contains some output commands. scp is not interactive so those lines must be commented out as the following comment points out.

Thursday, August 1, 2013

Terminator startup

Terminator is a terminal emulator for multiple platforms.
I just have replaced the gnome-terminal with it, as it has really nice and usable features.
My favorite is the possibility to create layouts and with one command I can spawn a new terminal window that is split to separate command areas. I use command prompt a lot: for git, maven, ssh or just for finding files. So it is really nice that for one project I create just one layout with all the necessary command shells that I need usually.
One point that hold me back for a while was that I wanted the separate shell prompts to start from different folders. In the layout menu there is a possibility to specify a startup command for a given terminal. It took me some time to realize though that this command replaces the terminal. So if there is no command it starts my shell. If a command is given it executes it, but the shell will not be started. So my first trial to write
cd /home/tyufi/tools/jboss
was not enough it must have been extended to
cd /home/tyufi/tools/jboss; bash
Now it works perfectly!

A complete guide can be found here.

Saturday, September 22, 2012

Agile Architect


Does it exist at all?


When we are talking about agile we can say: agile methodology, agile team, agile programmer. But who is the architect?
Architect used to be the mediator between the business and the IT. He has been used to feel safe that programmers did not fool poor users. Another part of his job was to preserve code quality and system integrity against stupid programmers.

Isn't it enough to think of programmers as lazy, dumb, bad ass guys?


With agile methodologies an era has ended: the era of quantity. Now we esteem quality. What matters more: the quality is measured by the customer, not by an abstract QA team. Agile team members (not just the programmers only) are devoted to deploy value. From this point of view who needs yet another guy to point out the relevance of quality?

We are not yet there!


The problem is that most of companies do want to change (speed up, make cheaper, stabilize) their development methodology to gain business advantage (or just catch up with the others) but their agile is just something that can be used to push their requirements (without much resistance from programmers). The problem is that most programmers do want to move from making piece of crap to make pieces of craft but their agile is just something where one can have enough time to make something real cool.
Both intents are understandable and acceptable. But agile is more! Agile is about the customer. Agile is an open, honest relationship between the participants of the project. And most people do not know that. And that is where the agile architect comes in!

Design Agile


Agile architect is the mapping tool and navigation assistant to teams in moving from traditional projects to agile projects. The destination must be estimated according to the life situation of the team, company and customer. The road must be planned to make thing more and more agile. The progress must be reflected during the ride. Off-tracking must be watched and corrected (even by recalculation of the path). That is what architects are for.
mapping icon


Tuesday, April 17, 2012

Installing WebSphere 6.1 on Ubuntu

Recently I have upgraded my Ubuntu to Precise (12.04). I always prefer a clean install which implies to reinstall some proprietary application like WebSphere.
It is always a pleasure to do that.

From time to time I wonder: why is it so hard to provide a .deb package...

Installation steps:

1. replace /bin/sh

/bin/sh points to dash which does not fulfill the expectations of the installer.
cd /bin
sudo ln -sf /bin/bash sh

2. install sun jdk 6

Other weak point is the OpenJDK.
In order to install the other jdk one must register (uncomment) the partner repository.
Recently Canonical does not support SunOracle JDK for legal and stability reasons.

3. install ia32-libs

In the XXI. century it does seem a bit old fashioned to install a 32 bit application, but WAS6.1 installer is 32 bit, so we have to get the support for that
sudo apt-get install ia32-libs

4. install WebSphere

run java -jar setup.jar

4.5 delete profiles created before installing feature pack

./manageprofiles.sh -delete -profileName profile_name

4. install feature pack

Which in turn installs some fixpacks first.
run java -jar setup.jar

5. install fixpacks

Fixpacks are handled through IBM Update Installer. After downloading, run the same old
java -jar setup.jar
The first thing to install must be the PK53084 fix, then come the two fix packs of 39.

6. create the profile

run pmt.sh from the ProfileManagement dir of the new WAS61 installation

7. start server

And now we come to a magical moment of firing up our brand new server

8. after party

In order to work correctly some settings must be applied:

TADAA!!!
We are done!
Have a beer!
Or maximum two!

Friday, January 20, 2012

Feeling Groovy II - https

In my former post I wrote about making direct get and post request to a webserver. Now I had to add some support for https protocol. Of course changing the URL was not enough as the SSL communication needs to know if the server certificate can be trusted or not. Well it was fun to google around for the details, but I do not really want to do it again.
So here are the steps:

1. Get the certificate!
2. Create a keystore!
keytool -import -file cert.cer -alias server -keystore server.jks
3. Modifiy the connection to use keystore and ignore some errors!
def decorateConnection(url, connection) {
    if (url.startsWith('https:')) {
        KeyStore keyStore = KeyStore.getInstance(KeyStore.defaultType)
        keyStore.load(getClass().getResourceAsStream('server.jks'), 'xxx'.toCharArray())
        TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.defaultAlgorithm)
        tmf.init(keyStore)
        SSLContext ctx = SSLContext.getInstance("TLS")
        ctx.init(null, tmf.trustManagers, null)
        connection.SSLSocketFactory = ctx.socketFactory
        connection.hostnameVerifier = new HostnameVerifier() {
            public boolean verify(String hostname, SSLSession session) {
                return true
            }
        }
    }
}
When you create the keystore a password must be specified, that is that 'xxx' in the row 4.
Special thanks to people on stackoverflow.com and coderanch.com!

Tuesday, April 5, 2011

Prezi

Again a topic that might be well known to others already, and I am a bit of late. It is already 2 years since Prezi is in production. Its simplicity is powerful, the design is amazing. It changes the way people make presentations - actually they enjoy it!
But the thing that makes the whole thing outstanding is the focus.

As a programmer I always try to think abstract, solve problems by decomposition, trying to focus on a context that is small enough for resolution. Mindmaps are handy in such a process and I always use them to structure information. And now I have found a tool where I can map the mindmap into a presentation! And we can do even more:
  • use orientation
  • use pictures (effectively!)
  • share prezentations and cooperate on them
  • easily emphasize things in focus
I wonder if it could be used in schools. Maybe children could gain a more structured knowledge of curriculum. Maybe they could learn easier ways to learn.

All in all Prezi is worth to be praised.
And - as it was 5th of April in 2009 when Prezi went public - we wish it a happy birthday!