Thursday, September 12, 2013

Opening a URL in java

Do you want to launch a URL from your default browser maybe after a button is pressed.
Just attached these lines of code under the button action performed.

   import java.awt.Desktop;
   import java.net.*;
URI uri = new URI("http://moumie.org") ;
Desktop desk= Desktop.getDesktop();
desk.browse(uri);
And life goes on.

Delay execution in Java

It is indeed funny talking about delaying execution in java, but trust me this line of java code is worth mentioning.

Thread.sleep(your time in millis);
That is all.
have fun !

Saturday, September 7, 2013

Big Data, what is it ?

Few years ago a company needed only a traditional database system such as Oracle, mysql , MS Server , Sybase etc to smoothly run its business. Nowadays for the same company to remain competitive, there is a need to take into account not only employees , transactional records and others but online data, and more. All possible sources of information related to that particular company need to be analyzed properly. However our traditional data cannot easily store or manage these highly unstructured data. NoSql related databases enter into the play...
In short the following figure shows a view of Big Data within an organisation:

  
With the current trends, willing or not any company today aspiring to survive must join the dance. In general Big Data is a term used to describe the exponential growth and availability of both structured and unstructured data. While a properly analysis of these massive data may offer enterprises tremendous benefits, there are also risks of being overwhelmed. 
  • How can you use it to suit your need ?
  • How can you analyze it all ?
  • How do you store all these data ?
  • How do you extract intelligence from it ?
  • Do you have enough to professionals to handle and analyze it ?
 As stated by Scott Zucker : Small data is gone. Data is just going to get bigger and bigger and bigger, and people just have to think differently about how they manage it.

Add an internal page to Koha

Koha is one of the most commonly used open source fully automated library management system used by libraries today. Even though koha an opac interface, many librarians and user espicially would like to have a portal where all library resources and information can easily be accessed. In an attempt to offer this feature to the koha's opac many opt for attaching external link sometime referring to the library website or a standalone web page.  Leaving koha to another different page or website is odd and not effective, as it really disturbs a smooth user navigation.
   Many librarians or IT professional setting up koha find it difficult  or have either forgotten that koha offer indeed an option create internal page. With a good skills of css and html only, the OPAC can easily be converted to a web portal. Through out this post and other that will follow, I will try to share the little I know on this issue.

 1- login as the root user:
  --$ su
  Password:
 2- create the first page to be served as templates called page.pl:
  --# cp  /usr/share/koha/opac/cgi-bin/opac/opac-main.pl  /usr/share/koha/opac/cgi-bin/opac/pages.pl

 3-  Edit the newly created page.pl from your preferred text editor like gedit (debian) or leafpad (ubuntu)
  --# gedit /usr/share/koha/opac/cgi-bin/opac/pages.pl

 4- At around line 30 just before my ( $template, $borrowernumber, $cookie ) = get_template_and_user( add the following statement:
  : my $cgi = new CGI;






 5- Make this change to the code at around line 33:

    template_name   => "opac-main.tt", change to  template_name   => "pages.tt",




 6- Approximately at 56 add this code:

 my $page = "page_" . $cgi->param("p");
          $template->param(
          koha_news => $all_koha_news,
          koha_news_count => $koha_news_count,
          local_page => "" .
          C4::Context->preference($page)
          );



 7- Save page.pl and exit.

 8- Create a second page called page.tt
 --# cp /usr/share/koha/opac/htdocs/opac-tmpl/prog/en/modules/opac-main.tt  /usr/share/koha/opac/htdocs/opac-tmpl/prog/en/modules/pages.tt

 9- At approximately  line 40 make this change:
        
        Change
      [% IF ( OpacMainUserBlock ) %]<div id="opacmainuserblock" class="container">[% OpacMainUserBlock %]</div>[% END %]

       to

      [% IF ( local_page ) %]<div id="opacmainuserblock" class="container">[% local_page %]</div>[% END %]



   10- Save page.tt and exit.

   11- In system preferences in the staff client, click the button for "New Preference" under "Local Use"
  
   12-

  Fill it out as follow:

      Explanation: demo page for an internal koha page
 
      Variable: page_demo

      Value: What is up , this is my demo page.

      Click the TextArea link (or enter "TextArea" into the input field below it)
 
      variable options (last field): 100|80

  13- In a browser go to http://youraddress/cgi-bin/koha/pages.pl?p=demo
      youraddress can be localhost or 127.0.0.1

 14- To add more pages simply create a system preference where the title begins with "page_" followed by any arbitrary letters. You can add any markup you want as the value of the field. Reference the new page by changing the value of the "p" parameter in the URL.

 15- Hope it works. For any issue drop me a comment.

Monday, September 2, 2013

Mysql Reset Auto_increment

Hi, recently I have come across this small issue and would like to share it with you.
After deleting all records from the table, and inserting new rows I noticed the  primary key continue to increment from the last (old) id. Because of the foreign key constraints I could not even drop the table without extra burden.
Luckily trying the following simple sql statement easily solves the problem:

ALTER TABLE table_name AUTO_INCREMENT = initialValue

Here the initialValue can be 1 or any integer value.
Cool isn't it ?