Thursday, February 27, 2014

PDF not working in Greenstone

If some of your PDF files cannot be built on greenstone, then they are some ways that you may use to solve your problem

1. Install the pdb-box plugin, for Greenstone 2.85 please have a look here
2. Convert your PDF to a lower version 1.5 or 1.4. Have a look here on how to proceed.

If you still have a problem or has found a better solution please drop a comment.

pdf-box plugin for greestone 2.85

I have noticed that they are many version of pdf-box plugin available out there. If by mistake you install a wrong one your Librarian Interface may fail to start. If you have greenstone 2.85 installed , you can try the plugin available in the following link. At least at the time of writing of this post, it was working properly.
I you have any further problem, knock me and will happy to help.

Note: You should put the extracted pdf-box in the ...\Greenstone\ext and restart the server.

Now that you've installed the PDFBox extension, this will be available as an option in the plugin's configuration dialog. To turn on the PDFBox extension for any collection you open in GLI, you would go to the Design panel, select Document Plugins from the left and on the right, double click the PDFPlugin (alternatively, select this plugin and click the <Configure Plugin...> below) to open the dialog to configure this plugin. In the Configure Plugin... dialog, scroll down to the section AutoLoadConverters and select the checkbox next to the pdfbox_conversion option. Click OK to close the dialog, switch to the Create panel and rebuild your collection. This time, PDF files will be processed by PDFBox which will extract their text.
Try this feature out on a collection of recent PDF files, by configuring its PDFPlugin with the pdfbox_conversion option turned on.

Wednesday, February 26, 2014

Change PDF version : Converting a PDF from one version to another

Are you having hard time trying to convert your PDF file from one version to another ? It is a common scenario with some software not accepting the latest version of PDF. I faced a similar probelm working a Greenstone library software which could only process at most the version 1.4.
No matter what you are going through this post is going help you move on with your task.

1. Download PDFCreator, don't panic as far as I know it is free.
    Jsut install it and it is straight forward.

2. Check the version of your PDF version
    Open the file with a pdf reader like acrobat ---> File --->Properties.
 
As you can see the version of this file is 1.6, so we have to convert it to lower one. 

3.  Launch PDFCreator:
   You will have the following small interface.
Click on Add and brwose to the file location. and you will get a pop window
4. Wait for 1 to 2 minutes you will get another windows
5. Click on Options :
 The button at the bottom center. And follow.

6. Click on Format:
 At the left side you see format, under click PDF.
Then at the right side set the Default settings (Ebook for my case),
Under compatibility choose your desired version (In my case i chose Adobe Acrobat 5 (PDF 1.4)).
Click on save and wait for a while. Your converted pdf will pop up.
Just save it and enjoy.
 Sorry for being long, I will try to come up with another short and better way on the matter in another post, till then stay tuned.
Aurevoir !!!!!!!

Tuesday, February 25, 2014

Production tips#5 : Glassfish Master Password

What is the master master password often referred to in Glassfish ? In this post I sharing with you some of the basic points regard the master password that can help you to administer your server confidently.

The master password is a password that is used to encrypt the DAS or Domain Administration Server and the instances keystores (IKS). The DAS and IKS used it to open instances at startup.
Another point worth mentioning is that the master password is not transmitted over the network nor is it used for authentication.
It is saved for the DAS and all the  instances in the domain. Contrary to what you may have in mind, the default master password is 'changeit' and not 'adminadmin'
For each domain like domain1 is it located inside  C:\glassfishv3\glassfish\domains\domain1
cmd: asadmin> create-domain  --savemasterpassword domain1

Start a domain:
asadmin> start-domain domain1

stop a domain:
asadmin> stop-domain domain1

You will have noticed that you are not prompted to enter the master password when it is starting the DAS just because it has been saved.

Change master password for a domain:
asadmin> change-master-password --savemasterpassword domain1

Delete a domain:
asadmin> delete-domain domain1


Monday, February 24, 2014

Production tips#4 : Create a secured domain in Glassfish console and assign it to the GUI in netbeans

What is really the issue here ?
Suppose you want to have your Netbeans IDE and an embedded Glassfish server GF attached to it. By default the web administration console page is not password protected. If you go directely to the web admin console page and change the admin password and hope it to work chances are that you will disappoint yourself. 
If that is the case then what to do ?
1. Go to the command prompt and navigate into the C:\glassfishv3\glassfish\bin.
   Clik on asadmin.bak
    or cd C:\glassfishv3\glassfish\bin
C:\glassfishv3\glassfish\bin> asadmin [ENTER]
asadmin > create-domain --adminport 5555--savemasterpassword domain3
 Follow the shell instruction it is interactive but enter your admin username, admin password and master password (at least 6 characters )
2. Assign the domain we just created to GUI so that we don't need to use the command line or asadmin shell  every time for the server administration.
 Go to Netbeans --> Services -->Servers :
        Right click Servers and Add a Glassfish server
 
Click Next  -->Next  and you are here
 Specify the same domain name you created previously : domain3
 
Finish and Restart you IDE, you can now visit the admin web console page by just right clicking the server name and click View Domain Admin Console  like here below
 Congratulation you just did it, feel to comment ...

Production tips#3 : Could not connect to admin listener for Glassfish Server ...Verify that NetBeans can make outbound connections to localhost:4848

How did I even get into this ?
Initially as part of security policy that consist of regularly changing the port of the application, I change the port information under the domain.xml situated in C:\glassfishv3\glassfish\domains\domain1\config. When I launch my application I received the following error message:

Before going to the solution there some points that are worth to be mentioned.

Inside the C:\glassfishv3\glassfish\domains\domain1\config, there is a replicate of domain.xml that I believe to the compiled file resulted from  the domain.xml each time you start the server. That file is domain.xml.bak .  Any change you make in domain.xml should be reflected in that bak file for it to be effective.
 However other solution have been suggested so far but none of them work in my situation.

Solution:

 If you have your glassfish embedded with netbeans, then just stop the glassfish server and restart netbeans .
 After restarting you should be able move on without any problem. Congratulation if you have succeeded otherwise throw some comment and I will assist you.

Saturday, February 22, 2014

Children Psychology in Education

Hi, as part of the requirement engineering analysis for a project on designing an android app to improve learning capabilities of kids, I have done the following observations. In fact to build an application for children it is very important for a system analyst or a developer to know how children think, how children behave, how children learn or in fact what is going on in their small brain : the kid psychology.
  You will definitely be overwhelmed reading this post, you will be surprised. This small people that you usually think you know are different, they have their own world apart. Of course the following points are not exhaustive.

  •   They like games.
  •   They like cartoons.
  •   Kids are curious. They often want to make sense out of things, and find out how things work.
  •   Kids like to be given a lot of freedom to learn in their own way.
  •   Visuals are crucial for young children and their learning process.
  •   Children learn to concentrate by doing things that interest them.  If an activity is too challenging for them, children either may choose not to participate or may stay with the activity only for a short time.
  •   They are great imitators, kids like trying what they see other people doing around them.
  •   A kid doesn’t not merely observe the world around him, but tastes it, touches it, hefts it, bends it, breaks it
  •   They are not afraid of making mistakes, nor do they shut themselves off from the strange, confused, complicated world around them. Kids play with snakes.
  •   They can also keep going for great lengths of time when they are involved in something important. If you take them away, they start screaming or say P-L-E-A-S-E.
The same goes for teachers or guardians who are expected to have certain special conducts while teaching children. Here are some important instructions for them to observe:

  •   Always encourage the children, and never point out a "mistake" in their drawing.
  •  Always have a sense of fun. A smile means a lot for children.
  •   As teachers it is recommend to support children in developing concentration for activities of their choosing (by providing ample time for them to choose each day). At the same time, we should encourage kids to experiment and stay with activities that challenge skills they are not comfortable with.
  •  Children’s moods also have an effect on their ability to focus. If a child comes to school upset, tired, or overly excited, he may be too distracted to concentrate on an activity, particularly a new or challenging one.
  •   Children need frequent breaks from academic work to keep their attention focused.
  •   When teaching them, we must relate new information to previous knowledge.
Tell us what you think, your experience with children !

Thursday, February 20, 2014

Production tips#2 : Glassfish Server cannot start. Port is occupied

Ports management is another key point to be taken serious especially when you deploying many application scattered over different domains, this in addition to your utilities software running in your PC. To come back to our concern :
 Then after getting this warning window popping up repeatedly what to do ?
 You need to know the port creating problem.
 In the case you are using glassfish with netbeans, right clicking the server will show you some useful information regarding the port.
Else you may go to your domain.xml file    under    C:\glassfishv3\glassfish\domains\domain1\config  to see the         <network-listeners> (around line 190) ports :

After your port is known , go to the command line or DOS. (CMD) and check the process id.

cmd> netastat -aon


     
kill the process. Here for port 8080 the pid=1988

cmd> taskkill /f /pid 1988

Finally it is done. Run your server now and enjoy !!

Production tips#1 : Glassfish admin page not loading

Running a random web application on test in one thing but when on production a new consistent mind set is needed. In  line with this principle I starting today a series of production tips that I hope will be useful to someone out there. That said, today I am going to talk about the importance of making your Glassfish server independent . What do I mean by independent ?
Yes, you don't have to depend on any online repository on internet in order to start your server.
Yes, you don't need any automatic update as it may cause more damage that good.
Yes, you need to have a total control of your server, by deciding what to update.
Yes , ...etc

When your server is dependent you will need to be connected to the internet in order to log in in your admin panel. Even when you are connected and your internet slow, you still need to waste sometimes before getting access. The reason is that the admin web application loads the available module updates from java.net during the log-in. Worse if the java.net server is down you are almost dead !

What to do:

  1. Disable Automatic Update Checks
    Rename $GLASSFISH_INST/glassfish/modules/console-updatecenter-plugin.jar to console-updatecenter-plugin.jar.disabled
  2. Disable News and other Internet-Dependent Admin GUI Features
    Set the following System Property (you can do that in the Admin GUI -provided that you can open it- in Configuration > JVM Settings > JVM Options > Add JVM Option : to get an empty textfield entry.
    -Dcom.sun.enterprise.tools.admingui.NO_NETWORK=true

Now restart your server (but if GF is embedded with an IDE like netbeans restart netbeans instead)and enjoy it. Special thank goes to Mike for his inspiring Idea. If you have anything to share regarding this article please feel free to drop a comment.

Wednesday, February 19, 2014

Cannot find login page in drupal

A time comes when you are completely log out of your drupal site, in fact you are sent out of your own home. But how can you get the login page ? How can you get back the control of your site ?
If you are new to drupal, please just cool down Drupal has a made it easy for you.
For all Drupal sites you can have acces to the login page by just suffixing your url with a /user.
www.yourURL.com/?q=user

So final I hope you are back into your home, so is Drupal really rocking ?

Insert data from Excel to Oracle in Java

It is tutorial I would show you how you can easily load your data from an excel file to Oracle in Java.

Database: Oracle 10g
Excel: 97-2003 (.xls)
Oracle Driver: ojdbc14 from here or here
Poi jar: from here or here  (for this tutorial I use version 3.8)
IDE: netbeans 7.1.1

I suppose that you know how to create a java project and add libraries to a project .

1. Create a java Project and add ojdbc14 and poi jars to it.
  After adding jars under project properties you will have something like this under project lib folder.

2. Create a table called STUDENTS.


 

CREATE TABLE students
   ( id varchar2(5) PRIMARY KEY,
     stname varchar2(50),
     country varchar2(30),
     types varchar2 (2)
   )

  
3. Prepare your excel file  and make sure you have saved it as a 1997-2003 (.XLS) file
  
4. Here is your code



public static void main( String [] args ) throws ClassNotFoundException, InstantiationException, SQLException, IllegalAccessException {

    String fileName="C:\\book\\list.xls";
    Vector dataHolder=xlsReader(fileName);
    printCellDataToConsole(dataHolder);
   }
   public static Vector xlsReader(String fileName)
   {
   
     Vector cellVectorHolder = new Vector(); //Vector definition

    try{
   
    FileInputStream myInput = new FileInputStream(fileName); //stream creation
    POIFSFileSystem file = new POIFSFileSystem(myInput); //POIFSFileSystem Object
    HSSFWorkbook workBook = new HSSFWorkbook(file);
    HSSFSheet mySheet = workBook.getSheetAt(0);  //getting the first sheet from the WorkBook
    Iterator rowIter = mySheet.rowIterator(); //cells iterator

      while(rowIter.hasNext()){
          HSSFRow row = (HSSFRow) rowIter.next();
          Iterator cellIter = row.cellIterator();
          Vector cellStoreVector=new Vector();
          while(cellIter.hasNext()){
              HSSFCell cell = (HSSFCell) cellIter.next();
              cellStoreVector.addElement(cell);
          }
          cellVectorHolder.addElement(cellStoreVector);
      }
      
    }catch (Exception e){e.printStackTrace(); }
    return cellVectorHolder;
  }

  private static void printCellDataToConsole(Vector dataHolder) throws ClassNotFoundException, InstantiationException, SQLException, IllegalAccessException 
  {
     
    String id="";
    String name="";
    String country="";
    String type="";
    
    for (int i=0;i
 
5.Finally run your project, Yep ! You  made it, Congratulations !!!
 If you face any problem along then don't hesitate to drop a comment.

Tuesday, February 18, 2014

Rounding Financial Numbers in Java with HALF_EVEN: what you should know

Dealing with financial application is always appealing and also sensitive. I will rather leave the appealing part to you and go to the sensitive part. I had a bad luck to develop an application for accounting. Every things seemed ok till the D-day came.  Hey Soulemane what have you done ?  Then what really happen ?
Trust me these accounts people worship numbers, they don't even tolerate a slight deviation of 0.0000001 cent. 

 Now coming back to HALF EVEN what does javadoc really say about it ?

Rounding mode to round towards the "nearest neighbor"  unless both neighbors are equidistant, in which case, round  towards the even neighbor. Behaves as for   RoundingMode.HALF_UP if the digit to the left of the   discarded fraction is odd; behaves as for  RoundingMode.HALF_DOWN if it's even. Note that this   is the rounding mode that statistically minimizes cumulative   error when applied repeatedly over a sequence of calculations.   It is sometimes known as "Banker's rounding," and is   chiefly used in the USA. This rounding mode is analogous to   the rounding policy used for float and double   arithmetic in Java. 
Example:

Input NumberInput rounded to one digit
with HALF_EVEN rounding *
5.5 6
2.5 2
1.6 2
1.1 1
1.0 1
-1.0 -1
-1.1 -1
-1.6 -2
-2.5 -2
-5.5 -6

In addition to that I would rather add the following explanation when you are in the middle i.e 5  :



Before the account take his/her calculator and start arguing with you get prepare as he might what 12. 455  to be 12. 46 instead of 12. 45. 

However this remain an opened issue feel free to share your experience by dropping a comment.

Sunday, February 16, 2014

MySQL Server Logs

MySQL Server has several logs that can help you find out what activity is taking place.

Log TypeInformation Written to Log
Error logProblems encountered starting, running, or stopping mysqld
ISAM logChanges to the ISAM tables (used only for debugging the ISAM code)
General query logEstablished client connections and statements received from clients
Update logStatements that change data (this log is deprecated)
Binary logStatements that change data (also used for replication)
Relay logData changes received from a replication master server
Slow query logQueries that took more than long_query_time seconds to execute

By default, all log files are created in the data directory: in windows C:\xampp\mysql\data

Saturday, February 15, 2014

Error: MySQL shutdown unexpectedly.

Just go to C:\xampp\mysql\data\ibdata1 delete it and restart your database. it should work now.

Tuesday, February 11, 2014

Location of php.ini configuration file

Even though this may seem silly at glance, often when time comes you will probably waste some precious minutes to look for this location. And maybe you have already done so while reading this post. Now where is the location of the php.ini file in your xampp folder ?
It is located just here  C:\xampp\php


Tuesday, February 4, 2014

Oracle JDBC connection in java under Netbeans

1. Create your project:

2. Project name: jdbcProject
3.Downoad the oracle jar ojdbc14.jar from here or here

4. Add the jar to your project:
   - by right clicking your oracle project
   -Click on Properties
   -Under Categories at the left Select Libraries
   -Click on Add Jar/Folder button at the right
   -Go to the jar location , select it and Open, OK, OK

5. Create a table in your oracle database:
create table student (name varchar(20), country varchar(20));
6. Write code
imports:
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;

 Your Code:

public class JdbcProject {

    
    public static void main(String[] args) {
       
        try {  
          String sid="orcl";  //your oracle sid
          String username="user"; 
          String password= "pass";  
          DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());  
          Connection connection = DriverManager.getConnection(  
                "jdbc:oracle:thin:@localhost:1521:"+sid, username, password);  

        //Statement statement = connection.createStatement();  
           
          String name="soulemane";
          String country="cameroon";
          String query = " insert into student(name,country)values(?,?)";
          PreparedStatement preparedStmt = connection.prepareStatement(query);
           //System.out.println("Data is inserted:");
           preparedStmt.setString(1, name);
           preparedStmt.setString(2,country);

            // execute the preparedstatement
           preparedStmt.execute();
           connection.close(); 
          } catch (Exception e) {  
            e.printStackTrace();  
          }  
           System.out.println("Data is inserted:");
    }
}
  
 7. Final RUN your project and have fun

create a user for Oracle Enterprise Manager or EM

Sometime many oracle newbies have difficulties creating a user in oracle with EM access. However in this post I try to provide you the instruction for performing such an operation.
create user john identified by abc;
grant create session,connect to john;
grant select_catalog_role, select any dictionary to john;
         Then connect as normal

These statements create a user with a minimal privilege required to login into the EM.

Monday, February 3, 2014

ORA-12514: TNS:listener does not currently know of service requested in connect descriptor

How did I even get into this ?
I just happen restart my web server which is connected to oracle 10g many time. Suddently this issue came out.
But how to get out ?

If you try to look for this solution over the web you would certainly have many suggestion among them, the most common is:

  1. Check if a database instance up and running
  2. Check the output of the lsnrctl service command and see what services are registered.
  3. Check if you has SERVICE_NAME correctly specified when connecting to the instance.
  4. If it happens that database instance stared before listener did sometimes you just need to wait a little or you can execute alter system register in order to register the instance.
But please don't turn everything upside down. Cool down and especially don't change any thing.
Do this.
Check the listener status: 
cmd> set oracle_sid = yourSid
 cmd> lsnrctl status

If it is successful withou any error, your half blessed.


Stop all programs currently running in your PC, and RESTART IT

Then after restarting:

cmd> set oracle_sid = yourSid
cmd> sqlplus /nolog
sql> connect username/password@yourSid

Congratulation you should now be in...otherwise throw me some comments.



 

Sunday, February 2, 2014

hide fields in django forms

Suppose we have the following model:

models.py:

from django.db import models

# Create your models here.
class Article(models.Model):
    name= models.CharField(max_length=200)
    country= models.TextField()
    bdate = models.DateTimeField('date published')
    age= models.IntegerField(default=1, null=True, blank=True)

forms.py:

from django import forms
from models import Article

class ArticleForm(forms.ModelForm):

    class Meta:
        model = Article

The above form will show all the four (04) fields.
To hide may be the age of the student, we'll modify the forms.py as follows:

forms.py:

from django import forms
from models import Article

class ArticleForm(forms.ModelForm):

    class Meta:
        model = Article
        fields = ('name', 'country', 'bdate')

 

Done !!

Django model : defautl, blank and null

from django.db import models

# Create your models here.
class Student(models.Model):
    age= models.IntegerField(default=1, null=True, blank=True)


No comment

Saturday, February 1, 2014

ORA-01033: ORACLE initialization or shutdown in progress

 Sometime ORACLE  just make you crazy and this is one of those scenarios. Here I share with one of my dirty hour with ORACLE.

cmd> sqlplus /nolog
sql> connect / as sysdba
sql> startup mount

if ORA-01081: cannot start already-running ORACLE - shut it down first

sql> shutdown abort
sql> startup mount
sql> alter database archivelog
sql> alter database open

if not successful and getting extra error like:
 ORA-16038: log 1 sequence# blah blan cannot be archived
 ORA-19809: limit exceeded for recovery files
 and more ....

sql>e exit
cmd> sqlplus /nolog
sql> connect / as sysdba
sql> alter database open

 if error like:
  ORA-16014
  ORA-00312

sql> recover database using backup controlefile until cancel;

   
  some stuff appear
  ORA - ...
 Specify log: {<RET>=suggested | filename | AUTO | CANCEL}

 Press ENTER and wait till it finishes and you get sql>!!!

sql> alter database open resetlogs;

Congratulation your in.!!!

ORA-12560: TNS:protocol adapter error

There two things that you have to look at:
  1.  Make sure you have specify the correct SID: 
  2. cmd> set oracle_sid=yourSid
  3.   Make sure you use the full login expression indicating your sid:
  4. cmd> sqlplus username/pass@yourSid
Hope it paves your way ahead.