Check whether current time lies between start hour and end hour (PHP)

I started to think of a function in PHP that checks the current time whether it lies between start hour and end hour. This was a task from my boss a couple of weeks ago. He asked this function to write in order to turn down our web application from 900PM to 400AM and display an appropriate message. I googled for a few minutes and compiled the code below:

[dfads params=’groups=-1′]

[code]
function checkTime($current_time, $start, $end){
/* $current_time = "9:00 pm";
$start = "9:00 pm";
$end = "4:00 am"; */

$date1 = DateTime::createFromFormat(‘H:i a’, $current_time);
$date2 = DateTime::createFromFormat(‘H:i a’, $start);
$date3 = DateTime::createFromFormat(‘H:i a’, $end);

//echo $date1;
if ($date1 >= $date2 || $date1 < $date3)
{
return 1;
}
else{
return 0;
}
}

$curTime = date(‘h:i a’);
$curTime = "9:00 pm";
//echo $curTime;
if(checkTime($curTime, "9:00 pm", "4:00 am")==1){
echo "Server Under Maintenance !!
<div style="color: #cc503f; border: 2px solid red; border-radius: 6px; margin-left: auto; margin-right: auto; width: 600px; height: 200px; padding: 10px; text-align: center;">
<h2>Notice!!!</h2>
<h3>Portal under Maintenance from 9PM to 4AM. Please visit back soon.</h3>
</div>
";
exit;
}
[/code]

[dfads params=’groups=-1′]

I cannot help myself, I am a Farmer

I went on helplessly watching his tears, continuously rolling down his innocent eyes, physically weaving the fish net but mentally somewhere in a deep thought or pain. He gradually went on sighing without feeling any disturbance made by the children play aside and fighting to concentrate on his job.

This is one of the unforgettable moment of my life. I always asked my self, the reason behind his tears.

It took me more than a decade to understand the incident, the incident of that old man who was sitting at the corner and trying to weave the fish net.

Today, I can feel the same pain that the old man felt years ago when I found my two buffaloes dead which I bought a month ago in 70K*2 = 1.4lacs rupees and someone poisoned my fish pond which had more than 1K small fishes which I bought last week in 1K*10 = 10K rupees. Then my wife shouts at me “Bastard, why don’t you go and die with those fishes in the pond?”

I don’t have a clue, what to do now except weaving my fish net and gradually cry from the within. I don’t blame you god, this is my fortune I am born with. I don’t blame you god, I am a helpless farmer.

94162

[dfads params=’groups=-1′]

How do I use Java with the Google Chrome browser?

 

NPAPI support by Chrome

The Java plug-in for web browsers relies on the cross platform plugin architecture NPAPI, which has long been, and currently is, supported by all major web browsers. Google announced in September 2013 plans to remove NPAPI support from Chrome by “the end of 2014”, thus effectively dropping support for Silverlight, Java, Facebook Video and other similar NPAPI based plugins.

[dfads params=’groups=-1′]

 

 

 

 Enabling NPAPI in Chrome Version 42 and later

As of Chrome Version 42, an additional configuration step is required to continue using NPAPI plugins.

  1. In your URL bar, enter:
    chrome://flags/#enable-npapi
  2. Click the Enable link for the Enable NPAPI configuration option.
  3. Click the Relaunch button that now appears at the bottom of the configuration page.

Java plug-in needs permission

 

If you see a message within Chrome that says Java(TM) needs your permission to run, you will need to respond to the Chrome options in order to run plug-ins on the page. Options vary according to the version of Chrome.

Chrome plug-in blocked icon (in address bar)

Look for the blocked plug-in icon in the Chrome address bar. Clicking on the icon will display Plug-ins were blocked on this page and plug-in options

  • Click Always allow plug-ins on [name of site] to allow plug-ins (including Java) to run on all this site’s pages.
  • Click Run all plug-ins this time to allow the plug-in (including Java) content on the page to run only until you leave this page.
  • Click Continue blocking plug-ins to prevent plug-ins from running on the page.

In addition, you can manage permissions on a site basis through the Manage plug-in blocking option.

Chrome message bar

  • Click Run this time to allow the Java content on the page to run only until you leave this page.
  • Click Always run on this site to allow Java to run on all this site’s pages. You will not see this message again for pages on this site.

Additional plug-in required

If you see a message bar within Chrome that says Java(TM) is required to display some elements on this page, click on Install plug-in in the Chrome message bar, or download from java.com.

[dfads params=’groups=-1′]

Plug-in out of date

If you see a message bar within Chrome that says Java(TM) was blocked because it is out of date, click on Update plug-in in the Chrome message bar to get the latest Java.

Reference:

https://java.com/en/download/faq/chrome.xml

Alternatives to NPAPI plugin

After upgrading the earlier versions of Chromium browsers to later versions greater than 42, internet users have started complaints that the JAVA plugins are not supported by chrome. After a bit research, found that chromium browsers have disabled NPAPI plugin-in on their latest versions. The deprecation of NPAPI plug-in caused the JAVA plugins to be blocked in Chrome. 

[dfads params=’groups=-1′]

What is NPAPI plug-in? (Source: Wiki)

Netscape Plugin Application Programming Interface (NPAPI) is a cross-platform plugin architecture used by many web browsers.

It was first developed for Netscape browsers, starting in 1995 with Netscape Navigator 2.0, but was subsequently adopted in Internet Explorer 3 in 1996 and implemented by many other browsers, although some browsers later dropped support.

For stability and security reasons, Google Chrome decided, in 2013, to start phasing out support for NPAPI. As of Chrome version 42, NPAPI is disabled by default and must be re-enabled explicitly. Google intends to remove support entirely in version 45, due in September 2015. 

Alternatives to NPAPI (Source: chromium.org)

With the deprecation of NPAPI, some developers have asked which modern technologies can be used to implement features which in the past would have relied on a platform-specific NPAPI plug-in. In answer to these questions we have composed the following list of common NPAPI use cases and web platform alternatives.

In general, the core standards-based web technologies (HTML/CSS/JS) are suitable for most client software development. If your application requires access to features outside the web sandbox, myriad Chrome Extension and App APIs offer access to OS features.

Video and audio

A common use case for NPAPI plug-ins on the modern web is embedded video and/or audio. A range of modern web technologies exist to facilitate media streaming.  The basic building blocks are WebRTC and media elements:

HTML5 Media Elements:  The HTML5 Specification provides a rich media platform through the <audio> and <video> elements. More complicated use cases can be achieved using the <canvas> element (for example check out the Video FX Chrome Experiment).

WebRTC:  WebRTC was designed for real time communication between peers and the technology can also be used for applications like live streaming media and data. Google’s Chromecast device uses WebRTC to stream HD video between a browser and TV.

Several features on top of these building blocks support more advanced use cases:

Adaptive Streaming

The ability to adapt media streaming to an individual consumer is critical in delivering high-quality content to a large audience. In the past this capability has been provided by technologies such as Silverlight’s smooth streaming and Quicktime’s HTTP live streaming. The Media Source Extensions to the HTML media element provide the capability to adapt a stream to an individual consumer on the modern web. Html5rocks has put together a great example of how to use the Media Source Extensions to implement some of these common use cases.

Video Conferencing

Several of the most popular NPAPI extensions including Facebook Video Chat and Google Talk provide video conferencing functionality within the browser. With the introduction of WebRTC video conferencing is facilitated directly through JavaScript APIs. The Cube Slam Chrome Experiment provides an example of peer to peer video conferencing via WebRTC.

Digital Rights Management

Encrypted Media Extensions give HTML5 video the DRM capabilities that previously would have required the use of a platform specific plug-in. The WebM project has provided a demo which performs video playback using the Encrypted Media Extensions of the video element.  For more information, check out the EME HTML5 Rocks article.

Closed Captioning

WebVTT and the <track> element (a child element of <video>) enable web developers to add timed-text captioning capabilities to their HTML apps.

Communicating with native applications

Try the Native Messaging API for Chrome Apps and Extensions.

Games & 3D

Native Client (NaCL) provides a rich environment for cross-platform game development. Many games have already been ported to or designed for NaCL. A number of examples and detailed tutorials to get started with NaCL are available on the NaCL development site. The WebGL specification provides a high-performance platform for hardware-accelerated 3D graphics in the browser. Chrome experiments has an entire category dedicated to examples and demos of various WebGL use cases.

Security

Some services have relied on NPAPI-based security techniques.  We recommend switching to TLS or, soon, Web Crypto.

Hardware access

In the past it has often been necessary to write platform specific plug-ins to access system hardware such as webcams, microphones, USB devices, and bluetooth. Direct access to local media streams such as webcams and microphones can now be requested directly from the web via the WebRTC Media Capture specification. Chromium also provides an App API for access to USB hardware and another API for accessing Bluetooth devices.

Screen capture

Chrome extensions can perform screen capture or streaming using either Desktop Capture for full screen capture or the Tabs API captureVisibleTab for individual tab content capture. 

[dfads params=’groups=-1′]

Reference:

http://www.chromium.org/developers/npapi-deprecation

http://en.wikipedia.org/wiki/NPAPI

Import large database tables from CSV files using oracle_loader driver in Oracle External Table

After trying various techniques to import csv data to oracle tables, I found this as the simplest and the fastest way to import large databases into oracle tables. This technique uses oracle_loader driver in Oracle External Table. The basic is that external table displays data by reading from a physical file.

[dfads params=’groups=-1′]

Steps:
1. Create a physical directory in one of your drive. Paste your csv data into the same directory.

2. Execute the script below on sqldeveloper.

3. Congratulations, play with your data tables.

[code]
create or replace directory my_data_app as ‘D:my_data_app’;

CREATE TABLE BULK_KYC_UPLOAD_BY_EMPLOYER_AI
( office_id number(11) ,
uan varchar2(12) ,
cur_mid varchar2(25) ,
document_type varchar2(1) ,
document_name varchar2(85) ,
document_no varchar2(25) ,
ifsc_code varchar2(11) ,
employee_name varchar2(100) ,
expiry_date varchar2(50) ,
edu_quali_flag varchar2(1) ,
phy_hand_flag varchar2(1) ,
phy_hand_cat_flag varchar2(1) ,
gender_flag varchar2(1) ,
number_worker_flag varchar2(1) ,
martial_status_flag varchar2(1) ,
establishment_id varchar2(15) ,
scan_document_flag number(11) ,
alredy_veryfied_flag number(11) ,
document_scan_image varchar2(100) ,
dob varchar2(50) ,
doj varchar2(50) ,
doe varchar2(50) ,
father_husband_name varchar2(85) ,
fs_flag varchar2(1) ,
bulk_kyc_tracking_id varchar2(15) ,
text_file_upload_date varchar2(50) ,
online_verification number(1),
ts_online_verification varchar2(50) ,
employer_verification number(1) ,
ts_employer_verification varchar2(50) ,
field_office_verification number(1),
ts_field_office_verification varchar2(50) ,
added_by varchar2(1) ,
missing_detail_source_flag varchar2(1) ,
ts varchar2(50),
duplicate_flag varchar2(2),
duplicate_ts varchar2(50)
)
ORGANIZATION EXTERNAL
(
TYPE ORACLE_LOADER
DEFAULT DIRECTORY my_data_app
ACCESS PARAMETERS
(
RECORDS DELIMITED BY NEWLINE
SKIP 1
LOGFILE my_data_app:’data.log’
BADFILE my_data_app:’data.bad’
DISCARDFILE my_data_app:’data.disc’
fields terminated by ‘,’
OPTIONALLY ENCLOSED BY ‘"’
MISSING FIELD VALUES ARE NULL
(
office_id,
uan ,
cur_mid ,
document_type ,
document_name,
document_no,
ifsc_code,
employee_name,
expiry_date,
edu_quali_flag,
phy_hand_flag,
phy_hand_cat_flag,
gender_flag,
number_worker_flag,
martial_status_flag,
establishment_id,
scan_document_flag,
alredy_veryfied_flag,
document_scan_image,
dob,
doj,
doe,
father_husband_name,
fs_flag,
bulk_kyc_tracking_id,
text_file_upload_date,
online_verification,
ts_online_verification,
employer_verification,
ts_employer_verification,
field_office_verification,
ts_field_office_verification,
added_by,
missing_detail_source_flag,
ts,
duplicate_flag,
duplicate_ts
)
)
LOCATION (my_data_app:’kyc_16012015.csv’)
)reject limit unlimited;

select * from BULK_KYC_UPLOAD_BY_EMPLOYER_AI;

select * from BULK_KYC_UPLOAD_BY_EMPLOYER_AF rownum < 200;

drop table BULK_KYC_UPLOAD_BY_EMPLOYER_AI;

insert into bulk_kyc_upload_by_employer_af select * FROM bulk_kyc_upload_by_employer_ai;
commit;
[/code]

In order to Export large database table into a dump file using oracle_datapump driver in Oracle External Table, Click Here
[dfads params=’groups=-1′]

Export large database table into a dump file using oracle_datapump driver in Oracle External Table

[dfads params=’groups=-1′]

There are various ways to export oracle database tables. Here, I was dealing with large database tables when I was working at one of the india’s biggest government company. I had to import and export crores of tuples from and to csv files.
Following is the simplest example to unload data from huge oracle database to a dump file using oracle_datapump driver in Oracle External Table.

[code]create or replace directory my_data_app as ‘D:my_data_app’;

create table bulk_kyc_xt
ORGANIZATION EXTERNAL
(
TYPE ORACLE_DATAPUMP
DEFAULT DIRECTORY my_data_app
LOCATION (‘bulk_kyc_xt.dmp’)
)
AS SELECT * FROM bulk_kyc_upload_by_employer_af;

select * from bulk_kyc_xt;

drop table bulk_kyc_xt;

[/code]

In order to import oracle table from a csv file using oracle external table, click here.

[dfads params=’groups=-1′]

Eport data to excel using Codeigniter and Oracle (OCI)

Below is a simple code snippet that will help you to export data to CSV/Excel format using Codeigniter and Oracle. Yes, it is obvious that you must have knowledge regarding Codeigniter and Oracle before you proceed further reading.

[dfads params=’groups=-1′]

The code below contains few PHP variables and function calls. I hope that you understand the same in a better way and please give your feedback if you feel this needs.

$sql = "SELECT * FROM your_table_name";
$filename = "Name_of_the_file.csv";
$countRow = functionCountRow();

$this->searchkyc_model->ExportToExcel($sql,$filename,$countRow);

public function ExportToExcel($sql,$filename,$countRow) { 	

		$output = "";

		$this->epfo_db = $this->load->database('EPFO', true);		

		$stmt = oci_parse($this->epfo_db->conn_id, $sql);

		oci_execute($stmt);

		$ncols = oci_num_fields($stmt);

		for ($i = 1; $i <= $ncols; ++$i) { 			
                    $colname = oci_field_name($stmt, $i);			 			
                    $output .= '"'.$colname.'",'; 		
                 } 		
                $output.="n"; 		 		
                $row = oci_fetch_all($stmt, $result); 		
                oci_free_statement($stmt); 		
                oci_close($this->epfo_db->conn_id);	

		// Get Records from the table
		for($i=0;$i<$countRow;$i++){ 				 				                
                    foreach($result as $key=>$val){
					$output.='"'.$val[$i].'",';
		          }
				$output.="n";
		}

		// Download the file	
		header('Content-type: application/csv');
		header('Content-Disposition: attachment; filename='.$filename);

		echo $output;
		exit;

	 }

[dfads params=’groups=-1′]

ORA-24408: could not generate unique server group name

After continuous google for more than 10 hours, I finally came to a conclusion that the problem “ORA-24408: could not generate unique server group name” was not with oracle instanclient or the connection string oci_connect(). The only problem was with the mis-match of the hostnames of the application server defined in /etc/sysconfig/network & /etc/hosts.

[dfads params=’groups=-1′]

After modifying the hostnames in both the file to a single name, the problem was solved.

 $ vi /etc/sysconfig/network

NETWORKING=yes
HOSTNAME=RHEL65
$vi /etc/hosts

$ vi /etc/hosts
#127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
127.0.0.1    RHEL65

$service network restart

The above steps helped me save my valuable time. Thanks to the bloggers.

I hope these information would help you too. Best wishes!

[dfads params=’groups=-1′]

[Source: http://ahmadzainuddinzakaria.blogspot.in/2012/06/warning-ociconnect-functionoci-connect.html]

How do I setup proxy in Red Hat Enterprise Linux to access internet?

To setup the proxy environment variable as a global variable, open /etc/profile file:

# vi /etc/profile

Add the following information:

export http_proxy=http://proxy-server.name.or.ip:3128/

OR

export http_proxy=http://USERNAME:PASSOWRD@proxy-server.mycorp.com:3128/

Save and close the file.

[dfads params=’groups=-1′]

VMware Player unrecoverable error: (vmx)

When I opened my VMware today, following error was displayed:

VMware Player unrecoverable error: (vmx)

Exception 0xc0000006 (disk error while paging) has occurred.

A log file is available in "C:UsersacerDocumentsVirtual MachinesRed Hat Enterprise Linux 6 64-bitvmware.log".

You can request support.

To collect data to submit to VMware technical support, run "vm-support".

We will respond on the basis of your support entitlement.

[dfads params=’groups=-1′]

Solution: Remove the following two files from the VMware installed directory. You can check the installed directory from Player -> Manage -> Virtual Machine Settings -> Options

  1. Red Hat Enterprise Linux 6 64-bit-93cd0331.vmem
  2. Red Hat Enterprise Linux 6 64-bit-93cd0331.vmss

[Source: http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1002347]