The ubiquitous "Hello World" program has been written in Scala to highlight some of the features of the language. A compiled scala programs runs on jvm. It can also import all the java classes as the example below shows.
// _ the underscore is like wildcard to import all the classes of math package
import scala.math._
/**
* @author Rajeev
*
*/
// object keyword automatically created a singleton object for the class HelloWorld
object HelloWorld {
/*
just like java main is the starting point
we say 'obj : type' in scala rather than 'type obj' in java as type can be automatically inferred in many cases
def indicates it is a function
Unit indicates it is returning void
Array[String] means array of type string
without = sign in the definition it will become a procedure which returns nothing rather than a function
*/
def main(args: Array[String]): Unit = {
// greet invoked like any method in java but it is passing a function, myFunc, in the arguments too
println(HelloWorld.greet("Rajeev",myFunc))
}
/* note that the parameter type => indicates it a by name function and wherever its name occurs in the current function it will be executed.
We don't neeed {} for single line function definitions
*/
def greet (raj :String, afunc : => String) : String = "Hello World " + raj + " " + afunc + " " + math.Pi
def myFunc = "myfunc"
}
Monday, June 1, 2015
Wednesday, May 27, 2015
Apache Phoenix Installation
Apache Phoenix is the new kid on the block in HBase world http://phoenix.apache.org/ It provides a SQL layer on top of HBase and greatly improves productivity. It provides standard RDBMS create table statements and also the secondary indexes to be created. However, if HBase was a poor fit for the use case then Phoenix is not going to change the underlying reality.
Here are the instructions to install
This is how the final HBase architecture looks with Phoenix installed
Here are the instructions to install
This is how the final HBase architecture looks with Phoenix installed
Thursday, July 25, 2013
jQuery custom plugins
This article is a very lucid explanation of creating jQuery plugins. It explains the importance of $.fn and shows the use of $.extend and $.isFunction well. Obviously one can look at the source of jQuery but the author of the article has done a good job. The key points Are:
Wrapping your plug-in in (function( $ ){ // plugin goes here })( jQuery ); is desirable.
Don’t redundantly wrap the this keyword in the immediate scope of your plug-in’s function. Pay attention to this and $(this) in the article.
Payattaention to object chaining aspect by returning this. Unless you’re returning an intrinsic value from your plug-in, always have your plug-in’s function return the this keyword to maintain chainability.
Pass your plug-in settings in an object literal that can be extended over the plug-in’s defaults. Look at $.extend in the article.
Don’t clutter the jQuery.fn object (incidentally pronounced “jQuery effin”) with more than one namespace per plug-in.
Always namespace your methods, events, and data.
This good practice should get you going.
Wrapping your plug-in in (function( $ ){ // plugin goes here })( jQuery ); is desirable.
Don’t redundantly wrap the this keyword in the immediate scope of your plug-in’s function. Pay attention to this and $(this) in the article.
Payattaention to object chaining aspect by returning this. Unless you’re returning an intrinsic value from your plug-in, always have your plug-in’s function return the this keyword to maintain chainability.
Pass your plug-in settings in an object literal that can be extended over the plug-in’s defaults. Look at $.extend in the article.
Don’t clutter the jQuery.fn object (incidentally pronounced “jQuery effin”) with more than one namespace per plug-in.
Always namespace your methods, events, and data.
This good practice should get you going.
Sunday, July 7, 2013
activity android:name=”.ExampleActivity” or activity android:name=”ExampleActivity”
Should there be a dot in the activity name in the AndroidManifest file and, if so, why? The question had exercised my mind and this is a clear explanation. In short, prefixing with dot prefixes the activity name with package and application name. For itisconsulatants we have com.itisconsultants.myapp.ExampleActivity when we say .ExampleActivity.
Stackflow too has great explanation.
Stackflow too has great explanation.
Saturday, December 29, 2012
Learning Android Development
I have never done any mobile development so it is a new journey for me. I thought the others may benefit from my experience. The most difficult steps are the initial ones. After that the software experience kicks-in and the development process just becomes coming to grips with the Android libraries.
The first step is to get the environment set up by downloading appropriate software. The standard advice is to follow these steps:
1) set up java sdk
2) set up Eclipse
3) set up Android SDK
4) set up Android plug-in from
To my surprise, it is much easier than that. All one has to do is to download the Android bundle from http://developer.android.com/sdk/index.html which has all the necessary components. It is just a matter of unzipping the download in a preferred directory.
Before any application development starts, it is best to create an Android Virtual Device (AVD)emulator by going into Windows/Android Virtual Device Manager. The knowledge of setting up emulators will obviously help with testing the developed application on various platforms. I share my settings:
The SD card file shown as c:\sdcard.iso was created by using the mksdcard.exe in the sdk/tools directory of the bundle installation. Simply change to the tools directory and issue the command
mksdcard 64M c:\sdcard.iso
Obviously this step has to be done before the AVD creation. I had difficulty in getting the AVD setup correctly. There were initially errors:
35 - Emulator] Failed to create Context 0x3005 [2012-12-29 08:34:35 - Emulator] emulator: WARNING: Could not initialize OpenglES emulation, using software renderer. [2012-12-29 08:34:
The above set up resolved the issues for me so I have shared the image. OK. You are set to go. Enjoy!
1) set up java sdk
2) set up Eclipse
3) set up Android SDK
4) set up Android plug-in from
To my surprise, it is much easier than that. All one has to do is to download the Android bundle from http://developer.android.com/sdk/index.html which has all the necessary components. It is just a matter of unzipping the download in a preferred directory.
Before any application development starts, it is best to create an Android Virtual Device (AVD)emulator by going into Windows/Android Virtual Device Manager. The knowledge of setting up emulators will obviously help with testing the developed application on various platforms. I share my settings:
The SD card file shown as c:\sdcard.iso was created by using the mksdcard.exe in the sdk/tools directory of the bundle installation. Simply change to the tools directory and issue the command
mksdcard 64M c:\sdcard.iso
Obviously this step has to be done before the AVD creation. I had difficulty in getting the AVD setup correctly. There were initially errors:
35 - Emulator] Failed to create Context 0x3005 [2012-12-29 08:34:35 - Emulator] emulator: WARNING: Could not initialize OpenglES emulation, using software renderer. [2012-12-29 08:34:
The above set up resolved the issues for me so I have shared the image. OK. You are set to go. Enjoy!
Thursday, March 10, 2011
JUMP - Joint Up Means Payback
Yesterday I attended the joint meeting of British Computer Society and Chartered Institute of Management Accountants at the premises of BCS in London. The agenda was to review what business-IT alignment and business intelligence means from the perspective of these two organisations.
IT is a world with a bewildering array of technologies - Java, .net, c++, sql, ITIL, CMS, databases, Joomla!, XML, CSS, HTML, PHP, TCP/IP, SMTP, HTTP, Unix, Firefox, agile, SCRUM and one can go on. To harness these successfully for business has been the dream for last twenty-five years. In fact, I cannot remember a single year over the last two decades when one or other management consultancy did not emerge with a framework for successfully aligning IT with business. Historically, many organisations have moved their IT personnel into business departments or encouraged their IT people to acquire CIMA/MBA qualification to bridge the chasm between these two worlds. Yet it was sobering to discover that business perceptions remains that these two world are far apart and bridging them is still a burning issue. A framework was presented to bridge this divide by Dr James Bacon based upon system-thinking and Genuine Action Learning. The claim was that joint-up thinking leads to dramatic increase in profitability (JUMP).
Also I remember that in the early 90s the BI systems were called Executive Information Systems (EIS). In the mid-90s I remember dubbing EIS as Everybody's Information System as the technology was becoming ubiquitous and affordable for lower tiers in the organisation. Interestingly CIMA sees this shift now and believes that analytical processing will move from the hands of accountants to become more pervasive. This redefines the role to become more focused on planning and control rather than analysis.
The moral of the story is that we are still grappling with old problems and trying to find better solutions to them.
IT is a world with a bewildering array of technologies - Java, .net, c++, sql, ITIL, CMS, databases, Joomla!, XML, CSS, HTML, PHP, TCP/IP, SMTP, HTTP, Unix, Firefox, agile, SCRUM and one can go on. To harness these successfully for business has been the dream for last twenty-five years. In fact, I cannot remember a single year over the last two decades when one or other management consultancy did not emerge with a framework for successfully aligning IT with business. Historically, many organisations have moved their IT personnel into business departments or encouraged their IT people to acquire CIMA/MBA qualification to bridge the chasm between these two worlds. Yet it was sobering to discover that business perceptions remains that these two world are far apart and bridging them is still a burning issue. A framework was presented to bridge this divide by Dr James Bacon based upon system-thinking and Genuine Action Learning. The claim was that joint-up thinking leads to dramatic increase in profitability (JUMP).
Also I remember that in the early 90s the BI systems were called Executive Information Systems (EIS). In the mid-90s I remember dubbing EIS as Everybody's Information System as the technology was becoming ubiquitous and affordable for lower tiers in the organisation. Interestingly CIMA sees this shift now and believes that analytical processing will move from the hands of accountants to become more pervasive. This redefines the role to become more focused on planning and control rather than analysis.
The moral of the story is that we are still grappling with old problems and trying to find better solutions to them.
Friday, February 18, 2011
Mobile Joomla and TERAWURFL database
Mobile Joomla! is a great extension for making your Joomla site ready for mobile viewing but it adds in a 40M worth of tables into Joomla database. This potentially causes difficulty in database backup and recovery. So here are the steps to put all the terawurfl tables in a separate database.
1) Go into phpmyadmin and copy you Joomla database as terawurfl.
2) Go into information_schema database and run the query
select concat("drop table ",table_name,";") from tables where substr(table_name,1,4) = 'jos_' and
substr(table_name,1,13) != 'Jos_terawurfl';
Note: I am assuming you are running Joomla database with prefix 'jos_', if not then change the above accordingly
3) Copy all the drop statements into clipboard.
4) Go into terawurl database and run SQL with statements copied from the clipboard. At this stage you have a database with just the terawurfl tables.
5) Now go back to information_schema database and run the query
select concat("drop table ",table_name,";") from tables where substr(table_name,1,13) = 'Jos_terawurfl';
6) Copy the drop statements to clipboard.
7) Now go to your Joomla database and run the SQL with statements copied from the clipboard. At this stage you have a database with just the joomla tables.
The above process would have taken out the terawurfl tables and put them in a separate database.
Now go and set database name, user and pass in plugins/mobile/terawurfl.php, They are currently picked up from the configuration.php You probably will just have to change the line to set schema to terarwurfl as the user and password would still be valid as we follow the above procedure.
TeraWurflConfig::DB_SCHEMA = "terawurfl";
Now you can backup your dynamically changing Joomla database more frequently without having the overhead of copying terawurfl tables as well. Also the database recovery time for Joomla tables will be lower too.
1) Go into phpmyadmin and copy you Joomla database as terawurfl.
2) Go into information_schema database and run the query
select concat("drop table ",table_name,";") from tables where substr(table_name,1,4) = 'jos_' and
substr(table_name,1,13) != 'Jos_terawurfl';
Note: I am assuming you are running Joomla database with prefix 'jos_', if not then change the above accordingly
3) Copy all the drop statements into clipboard.
4) Go into terawurl database and run SQL with statements copied from the clipboard. At this stage you have a database with just the terawurfl tables.
5) Now go back to information_schema database and run the query
select concat("drop table ",table_name,";") from tables where substr(table_name,1,13) = 'Jos_terawurfl';
6) Copy the drop statements to clipboard.
7) Now go to your Joomla database and run the SQL with statements copied from the clipboard. At this stage you have a database with just the joomla tables.
The above process would have taken out the terawurfl tables and put them in a separate database.
Now go and set database name, user and pass in plugins/mobile/terawurfl.php, They are currently picked up from the configuration.php You probably will just have to change the line to set schema to terarwurfl as the user and password would still be valid as we follow the above procedure.
TeraWurflConfig::DB_SCHEMA = "terawurfl";
Now you can backup your dynamically changing Joomla database more frequently without having the overhead of copying terawurfl tables as well. Also the database recovery time for Joomla tables will be lower too.
Subscribe to:
Posts (Atom)