Tuesday, 7 December 2021

Top 8 Interview Questions in Python

  1. What is the difference between List and Tuples in Python?
  2. Python an interpreted language explain
  3. What is Pep8?
  4. What are Python Namespaces?
  5. What are Decorators in Python?
  6. What are Dict and List comprehension?
  7. What is the difference between .py and .pyc files?
  8. What is Slicing in Python?

Friday, 16 October 2020

Ubuntu — Certificate error after upgrade to 20.04

ssl_ctx_use_certificate:ca md too weak

I upgraded my ubuntu server to 20.04. After this process, doing calls passing certificate gives the following error

error: Error: [(‘SSL routines’, ‘SSL_CTX_use_certificate’, ‘ca md too weak’)]

openssl version : OpenSSL 1.1.1f 31 Mar 2020

I found the solution, according to the accepted answer of this question: Ubuntu 20.04 — how to set lower SSL security level?

In particular, the openSSL configuration file /etc/ssl/openssl.cnf shall be modified in the following way.

At the beginning, add

openssl_conf = default_conf

At the end, add

[ default_conf ]

ssl_conf = ssl_sect

[ssl_sect]

system_default = ssl_default_sect

[ssl_default_sect]

MinProtocol = TLSv1.2

CipherString = DEFAULT:@SECLEVEL=0

After this modification, the certificate is recognized without security errors.

Sunday, 11 June 2017

Javascript - In time and out time difference


	inTimeHHMM 			= inTime.split(":");
	outTimeHHMM 		= outTime.split(":");
	var today 			= new Date();
	var dateInTime 		= new Date(today.getFullYear(), today.getMonth(), today.getDate(), inTimeHHMM[0], inTimeHHMM[1], 0);
	var dateOutTime 	= new Date(today.getFullYear(), today.getMonth(), today.getDate(), outTimeHHMM[0], outTimeHHMM[1], 0);
	if(dateInTime<=dateOutTime){
	}else{
		dateOutTime.setDate(dateOutTime.getDate() + 1);
	}
	var diff =(dateOutTime.getTime() - dateInTime.getTime()) / 1000;
	diff /= 60;
	workingMinutes = Math.abs(Math.round(diff));

Monday, 10 April 2017

Daterangepicker set min time


Date.prototype.addHours = function(h) {    
   this.setTime(this.getTime() + (h*60*60*1000)); 
   return this;   
}
var currDate = new Date().addHours(5); // 5 is the hours
 
$('#fromDate').daterangepicker({
 minDate: currDate,
 timePicker: true,  
 singleDatePicker: true, 
 timePickerIncrement: 1,
 format: 'DD/MM/YYYY hh:mm A'
});

Thursday, 23 February 2017

jQuery validation - IP address


/* 
 ValidIpAddressRegex = "^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$";
 ValidHostnameRegex = "^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])$";
*/
$.validator.addMethod('ipChecking', function(value) {
 //var ip = "^(?:(?:25[0-5]2[0-4][0-9][01]?[0-9][0-9]?)\.){3}" +"(?:25[0-5]2[0-4][0-9][01]?[0-9][0-9]?)$";
 validIpAddressRegex = "^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$";
 ipCheckFlag = true;
 ipLists = value.split(',');
 for(ip=0; ip<ipLists.length; ip++){
  if(!ipLists[ip].trim().match(validIpAddressRegex)){
   ipCheckFlag = false;
  }
 }
 return ipCheckFlag;  
});

Monday, 19 December 2016

PHP Array to stdClass Array – stdClass Object

<?php
$_TestAry = $this->_TestModel->getTestData();
if( isset($_TestAry) && !empty($_TestAry) && count($_TestAry) > 0){

 $_TestAry[count(_TestAry)+1]   = new StdClass; 
        // avoid warning creating default object from empty value

 $_TestAry[count(_TestAry)+1]->id   = 11;

 $_TestAry[count(_TestAry)+1]->name   = 'Jayakumar';

}
?>

Git merge branch to another branch

$ git checkout develop $ git pull $ git checkout test-branch $ git merge develop $ git push