peech Therapy, Apraxia Articulation Word FlashCards

Speech Therapy, Apraxia Articulation Word FlashCards


Contact: kidsappbaba@gmail.com or Call : +1-980-APRAXIA

Joomla automated backup to Cloud service

Well.. what's the use of the backup if you can't have it when you need it the most. I learned it the hard way. I had joomla website which is backup using Akeeba. Being on the free version, had to settle for cron job that triggers the backup. 

Following is the php snippet that trigger Akeeba backup profile.

$curl_handle=curl_init();
curl_setopt($curl_handle,CURLOPT_URL,
SITEURL.'/index.php?option=com_akeeba&view=backup&key='.
SECRETKEY.'&profile='.PROFILE);
curl_setopt($curl_handle,CURLOPT_FOLLOWLOCATION,TRUE);
curl_setopt($curl_handle,CURLOPT_MAXREDIRS,10000); 
curl_setopt($curl_handle,CURLOPT_RETURNTRANSFER,1);
$buffer = curl_exec($curl_handle);
curl_close($curl_handle);


So far good. But to be real useful your backup needs to somewhere else. And what better than free cloud service like Dropbox or Google drive. Akeeba professional has out the box integration with Dropbox. For google Drive, you can get it done by following below steps

1. Firs you Need to create a Google Drive service account. Here is nice post that has detailed steps about it 
2. Get the latest google drive client API.
3. Use cp2goole that has helper methods to connect to Google drive
4. As I was on PHP 5.2 has to hack two things
  •   to get around finfo to get MIME type, use the system command//$fi = new finfo( FILEINFO_MIME ); //$mimeType = explode( ';', $fi->buffer(file_get_contents($path)));
    $mime = exec('file -b --mime-type ' . $path);
  •  Google_P12Signer.php , use the hack  
  • 5. then write script that is specific to your needs
    $dir = "backupsDir";
    $dh  = opendir($dir);
    $strToSreach = "NameOfThebackpFile".date("Ymd");
    printf($strToSreach);
    $nameOfFile = "";

    //Search the file
    while (false !== ($filename = readdir($dh))) {
       
      if( substr($filename,-4) == ".sql" && substr($filename,0,15) == $strToSreach ) {
            printf("Found the file: ".$filename);
            $nameOfFile = $filename;
        }
    }

    $path  = $dir."/".$nameOfFile;

    printf("zipping the file: ".$nameOfFile ."
    ");

    exec('gzip  ' . $path);

    $path  = $dir."/".$nameOfFile.".gz";


    printf( "Uploading %s to Google Drive\n", $path ."
    ");

    $service = new DriveServiceHelper( CLIENT_ID, SERVICE_ACCOUNT_NAME, KEY_PATH );
    And with this, if you run this script, your backup should get triggered, it should create a joomla backup with SQL file, it should get zipped and sent to your google drive and your should get an email that says Backup has been shared with your email account !




PMP Preparation

I found below simulator very useful.





First RESTful Webservice

To create RESTful webservice using plain JDK, tomcat and Jersey (JAX-RS sample implementation)

Pre Requisite:
  1. JDK
  2. Tomcat ( any other servlet container)
  3. Jersey - Its sample JAX-RS implementation. It uses servlet controller that handle REST URLS.
Steps :
1. Create eclipse project with following structure
WEB-INF
--classes
--lib
--web.xml

2. Download latest Jersey jars from http://download.java.net/maven/2/com/sun/jersey/jersey-archive/ and extract it under lib folder.

3. Create following java class under src and make sure to set output folder in eclipse to WEB-INF/classes.

package com.rahul.ws;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;

@Path("helloworld")
public class HelloWorldResource {
    @GET
    @Produces("text/plain")
    public String getMessage() {
        return "This is sample REST service";
    }
}

4. Add entry into web.xml for Jersey controller


    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
        http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
   
        RestfulContainer
        com.sun.jersey.spi.container.servlet.ServletContainer
       
            com.sun.jersey.config.property.packages
            com.rahul.ws
       

        1
   

   
        RestfulContainer
        /resources/*
   


5. Create war file using "%JAVA_HOME%\bin\jar" cvf restful.war WEB-INF

6. Deploy this war under tomcat and access the service using
    http://localhost:9090/restful/resources/helloworld
7. That's it !!


Changing Timezone for OpenBibilo Library system

OpenBibilo is an open source, simple, easy to use but a power library management system. It highly  suitable for low to mid volume libraries having low budget.

Last week I was implementing it for one of the library that wanted to use Singapore time. By default OpenBibilo follows the timezone of your hosted environment and there is no configuration to use a different timezone.

But you could easily change  it by following below steps:
  • Replace all occurances of sysdate() used in SQL queries to UTC timestamp and add the required offset. There are around 19 occurances in the PHP files ( for version 0.0.7) ,   e.g sysdate() -->  (UTC_TIMESTAMP()+ INTERVAL 8 HOUR)
  • There is one occurance of now(), that need to be replaced as well                                 e.g  now() -->(UTC_TIMESTAMP()+ INTERVAL 8 HOUR)
  • These steps takes care of database timezone,
  • One last step needed to maek sure your php dates are too on the same timezone. It can be done by setting timezone in shared\common.php. Just add below line in common.php date_default_timezone_set('Asia/Singapore');
That's it! Your timezone is set to whatever you want. Of course there is a better way of having this done in some common place. But this is quick way to set timezone at this point.

Joomla website weird problem of wrong URLs

I have one joomla site which was working fine for last 2 years. Suddenly I noticed that the most of the links on my site are weird. Some of the links content actual IP address of the website, some link contained ftp user name ( xx.com/~xx/index.php). I was sure that nothing has been changed no the website and had no clue why its happening.

Upon careful observation, I noticed that someone accessed the website using adding IP address and user name (~xx) as context root (it was same as website name..so he must have guessed it). And since the joomla caching was enabled, all the pages were cached that contained these links. any new hits were served using this pages and even newly cached pages were following same context root !

Once the problem was identified, solution was simple. Simply clear the cache/ (or disable it for time being).


Oracle: Check for special character in SQL

select str, dump(str)
from test
where translate(upper(str),
CHR(0)||'QWERTYUIOPASDFGHJKLZXCVBNM ,.<>/?;:''"[{]}1234567890-=!@#$%^&*()_+\|`~',
CHR(0)
) IS NOT NULL

Weblogic: Changing context root and redirection

Sometime you might have to change the context root(CR) of the application deployed on weblogic from CR1 to CR2. This can be easily done by updating the context root in the application.xml file in your ear file.

But then if you might also want to redirect all the old URL references to this new context root. So if somebody access http://yourhost/CR1 it should redirect to http://yourhost/CR2. It’s easy to do in Apache server using mod_rewrite module. But weblogic as such don’t provide this functionality.

 

So here is quick handy way to achieve this:

1.    Create a dummy web module under CR1.

2.    Update application.xml as follows:

   

<module > 

       <web>

         <web-uri>newAppDir</web-uri>

         <context-root>/CR2</context-root>

      </web>

   </module>

    <module> 

       <web>

         <web-uri>oldAppDir</web-uri>

         <context-root>/CR1</context-root>

      </web>

   </module>

     

3.    Configure web.xml for this dummy web application such that all the requests will be handled by a single JSP, redirector.jsp

a.    Set the welcome file as redirector.jsp

b.    Add Following servlet mapping to catch all the URLs and let it handle by redirector.jsp

 

<servlet-name>wlRedirector</servlet-name>

<jsp-file>/redirector.jsp</jsp-file>

</servlet>

<servlet-mapping>

     <servlet-name>wlRedirector</servlet-name>

     <url-pattern>/*</url-pattern>

 </servlet-mapping>

 

4.    In the redirector.jsp add code to change the CR1 to CR2 and sendRedirect to CR2

                                String recvUrl = request.getRequestURI();

          recvUrl = "/CR2" + recvUrl;

         if (request.getQueryString() != null) {

          recvUrl += '?' + request.getQueryString();

         }

URL reconstructedURL = new URL(request.getScheme(),

                               request.getServerName(),

                               request.getServerPort(),

                               recvUrl);

response.sendRedirect (reconstructedURL.toString());

 

 

Rahul Ner

 

Recursive and Non-Recursive find in Unix

Recursive Find in Unix for "*.log"
find . -name "*.log" -print -type f


Non-Recursive Find in Unix for "*.log": Just current directory
find . \( ! -name . -prune \) -name "*.log" -print -type f

Protect your email address from automated spammer

<SCRIPT TYPE="text/javascript">
emailE=('xxx' + '@' + 'ccc.org')
document.write('<A href="mailto:' + emailE + '">' + emailE + '</a>')
</script>

Book Publishing on joomla website

1. Convert word to PDF using cutePDF write/PDF 999
2. Convert PDF to images using converter http://www.officeconvert.com/purchase.htm
3. Resize to 50% using fastStone
4. Display using any book modules. e.g.

Analyzing thread dump for your Java application

Is your J2EE application responding slowly ? Is it getting hanged every now and then ?

The best way to start is take thread dump whenever you think performance is not to up to the mark and then analyze it.

Taking Thread Dump:

On unix system , you just have to first find out PID of your java process. You can use PS –alf | grep –in ‘java’ to find out the same.

Once you have PID, simply execute Following command:

 kill -3 PID

This will inform JVM to take current snapshot. It will be then copy to your standard log file/stdout file.

On windows, you have to execute ctr-break on the command prompt.


Analyzing Thread Dump:

If you don’t have right to tool for this, then it’s very hard to grasp what’s going on. I have used TDA http://www.ohloh.net/p/tda . This one is very nice, simple, easy and free tool. Once you open your log file (containing dump) in this tool, it will show all threads in tree structure, along with details of each thread. Most important of it is the thread state which could be like runnable, wait, wait on monitor, wait on conditions etc. Also it will show sleeping and locking threads separately. This will help you to identify the object on which threads are waiting and thereby identifying bottleneck in the system.

It has one feature to compare multiple thread dumps. It helps in finding out long running threads instantly.

If you have set -XX:+PrintClassHistogram JVM option while starting it, in thread dump it will also provide information of number of instance create for each classes along with the total bytes required for those objects. This should give you a fair idea of what classes and which modules are the one to look first for the optimization.


Rahul Ner

(RNer)

Creating web service from java class using Axis

Axis provides excellent platform for web service creation and deployment. Let's say you have a plain java class that you would like to expose as a web service. You can achieve this in few minutes. I assume here axis.war is already deployed on to your app server.

1. Create your java class with the method that you want to expose. (Its not web service aware.. so you don’t need to implement any interface etc.)

2. Now, register your web service with Axis. Simply add entry following entry to axis.war\WEB-INF\server-config.wsdd.

 <service name="WebServiceDemo" provider="java:RPC">

                       <parameter name="className" value="test.wbservice.Demo"/>

  <parameter name="allowedMethods" value="*"/>

                                           <parameter name="wsdlTargetNamespace" value="http://test.wbservice"/>

                                                                                </service>

 

 Class Name is fully qualified name of the class created in step 1. Now copy demo.class file to axis.war\WEB-INF\lib. If you prefer, You can create jar file containing this class and copy that to lib directory.


3. Restart your app server

4. Now you have deployed web successfully. You can check that using http://appsever_url/axis/services/webserviceDemo

    You can generate WSDL file containing all information of your web service using  http://appsever_url/axis/services/webserviceDemo?wsdl

5. Now You can generate client side stubs and classes required using WSDL2Java tool provided by axis.

   You have to execute this class passing wsdl to it.

java -cp axis.jar;commons-discovery.jar;commons-logging.jar;jaxrpc.jar;saaj.jar;log4j-1.2.8.jar;xml-apis.jar;xerces.jar;wsdl4j.jar org.apache.axis.wsdl.WSDL2Java   http://appsever_url/axis/services/webserviceDemo?wsdl


This will create all required file at the client side.


6.Generate client

        DemoServiceLocator demoLocator  = new DemoServiceLocator ();

       Demo demo = demoLocator .getWebServiceDemo();

        Demo.call_your_method()


Rahul Ner

Asset Depreciation query

SELECT temp.*, (COST - acc_dcost) final_cost
FROM (SELECT asset.code, deprec.yr, COST, deprec.dcost dcost_year,
SUM (dcost) OVER (PARTITION BY deprec.code ORDER BY yr)

acc_dcost
FROM (SELECT 1003 code, 10000 COST
FROM DUAL) asset,
(SELECT 2001 yr, 1003 code, 163 dcost
FROM DUAL
UNION ALL
SELECT 2002, 1003, 161
FROM DUAL
UNION ALL
SELECT 2003, 1003, 158
FROM DUAL) deprec) temp
Artist performaing at Milenia Walk

Incredible India !




A nice add campaign by Incredible India !

Missile Man in Singapore



Great Indian Scientist and former President of India Dr. A.P.J Abdul Kalam sharing his dream in Singapore.

Zooooooooooommmmmmmmmm.......... at 300 plus speed

First F1 night race is going to be hosted in Singpaore on coming Sunday...Today they had a practice session. I was fortunate to view cars racing just few meters away ! The fierce sound of the moving object at the speed more than 350 km/hours is just awesome ! Have a look at the video taken around 4 o'clock today near Marina Square.